Spatialite for iOS : Functions in modules other than base doesn't work

174 views
Skip to first unread message

Jimmy

unread,
Apr 30, 2024, 6:43:03 AMApr 30
to SpatiaLite Users
Hey,

I am trying to run spatialite on iOS by using the following repo.
https://github.com/gstf/libspatialite-ios (outdated)
https://github.com/iulian0512/libspatialite-ios (has spatialite 5.1.0)

I am able to compile successfully and link the static libraries to my Swift project after following the instructions mentioned here https://gist.github.com/aaronpk/0252426d5161bc9650d8

Now when I try to run any spatialite query containing functions from base module, I get the correct result. But it fails when I do so with functions from say GEOS module.
Example -
SELECT ST_Distance(ST_GeomFromText('POINT(1 1)'), ST_GeomFromText('POINT(10 9)')) as result;   // returns 0 or garbage value

On spatialite initialisation, I get the following output.
Screenshot 2024-04-30 at 3.53.25 PM.png

a.fu...@lqt.it

unread,
May 1, 2024, 3:02:02 AMMay 1
to spatiali...@googlegroups.com
On Tue, 30 Apr 2024 03:29:16 -0700 (PDT), Jimmy wrote:
> Now when I try to run any spatialite query containing functions from
> base module, I get the correct result. But it fails when I do so with
> functions from say GEOS module.
>

Hi Jimmy,

from what you report it seems quite clear to me that the problem lies
entirely within the GEOS library, which was probably compiled
incorrectly or in any case in such a way not compatible with the
ARM64 architecture.

I suggest you ask for assistance on the GEOS mailing list
asking if they are aware of possible problems on
ARM64 platforms.

bye Sandro

Jimmy

unread,
May 1, 2024, 5:25:27 AMMay 1
to SpatiaLite Users
Hi Sandro,

Thanks for the response.
Actually, its not just GEOS but none of the other modules (PROJ, RTTOPO, etc.) are working, apart from base module functions.
https://www.gaia-gis.it/gaia-sins/spatialite-sql-5.1.0.html

I came across this https://github.com/iulian0512/libspatialite-ios shared by one of the user in this group, thanks Iulian, which is supported on arm64 and other architectures. Although, I have managed to compile it successfully, it appears that there might be something I'm overlooking, preventing spatialite from communicating with other libraries.

Could you please guide me to any resource on how to use spatialite on iOS, if possible?

Thanks.

a.fu...@lqt.it

unread,
May 2, 2024, 4:14:52 AMMay 2
to spatiali...@googlegroups.com
On Wed, 1 May 2024 00:26:41 -0700 (PDT), Jimmy wrote:
> Hi Sandro,
>
> Thanks for the response.
> Actually, its not just GEOS but none of the other modules (PROJ,
> RTTOPO, etc.) are working, apart from base module functions.
> https://www.gaia-gis.it/gaia-sins/spatialite-sql-5.1.0.html [1]
> [2] shared by one of the user in this group, thanks Iulian, which is
> supported on arm64 and other architectures. Although, I have managed
> to compile it successfully, it appears that there might be something
> I'm overlooking, preventing spatialite from communicating with other
> libraries.
>
> Could you please guide me to any resource on how to use spatialite on
> iOS, if possible?
>

Hi Jimmy,

'm very sorry but I can't help you because I've never worked
on iOS or ARM64, my personal experience just covers Linux
and Windows, I really don't know what to tell you.

just out of curiosity, did you personally compile all the
libraries using the same compiler (and the same options)
or are you trying to put together binary stuff from the
most disparate origins?

in this case it could be that using different conventions
for function calls causes chaos, although honestly I would
rather expect some crashes or fatal errors.

bye Sandro

Spatialite iOS

unread,
Sep 12, 2024, 5:08:21 AMSep 12
to SpatiaLite Users
I'm trying to build a community for this issue. I've set up an email address spatialiteios.gmail.com I can't promise a solution, I'm just promising a forum. I'll set up a public forum if I get enough responses for people wanting a spatialite solution for iOS.

Vladyslav Shkodych

unread,
Sep 12, 2024, 9:42:41 AMSep 12
to SpatiaLite Users
Hi, Jimmy, I am faced with the same issue and I am trying to figure it out 5 days in a row, The result for now - negative( I posted a question on a github:
https://gist.github.com/aaronpk/0252426d5161bc9650d8?permalink_comment_id=5186966#gistcomment-5186966
And also found this same issue on stackoverflow:
https://stackoverflow.com/questions/78187601/st-within-st-isvalid-or-any-other-geos-or-rtreetopo-related-function-not-working

Vladyslav Shkodych

unread,
Sep 20, 2024, 7:37:13 PMSep 20
to SpatiaLite Users

It took some time to find a solution, but it was worth it.

I wrote an article with explanations to help developers like us avoid the same struggle.

Long story short - you need to initialize SpatiaLite on the C level.

Reply all
Reply to author
Forward
0 new messages