SpatialDBKit icon indicating copy to clipboard operation
SpatialDBKit copied to clipboard

Issue with Spatial Index requests

Open doubotis opened this issue 11 years ago • 7 comments

SQL requets with use of Spatial indexes fails and turn the database connection down from FMDatabase.

Error returned by database: "no such module: rtree"

Solved by adding another flag in "Other C Flags" in "Build Settings" of Pods-sqlite3 : -DSQLITE_ENABLE_RTREE=1

doubotis avatar Dec 18 '13 13:12 doubotis

Thanks, this should be added to the cocoapods podspec as a specific submodule.

andreacremaschi avatar Dec 18 '13 16:12 andreacremaschi

I ran into the same problem, but fixed it like this:

post_install do |installer_representation|
  installer_representation.project.targets.each do |target|
    target.build_configurations.each do |config|
      if target.name == 'Pods-sqlite3'
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'SQLITE_ENABLE_RTREE=1'
      end
    end
  end
end

Any way this can be included in the PodSpec?

scspijker avatar May 27 '14 08:05 scspijker

Well, this sounds a little bit hacky to me.. I'm not sure this is the best way to accomplish that. I suppose that the correct way should be to let sqlite3 pod support RTree option as a submodule (i.e. "sqlite3/rtree"), which in turn would set the correct preprocessor definitions in sqlite3's pod project.

In the meanwhile your solution should work as a patch directly in each user project's Podfile.

andreacremaschi avatar May 27 '14 09:05 andreacremaschi

there is already a subspec?

https://github.com/CocoaPods/Specs/blob/master/Specs/sqlite3/3.8.4.3/sqlite3.podspec.json

{
      "name": "rtree",
      "dependencies": {
        "sqlite3/common": [

        ]
      },
      "xcconfig": {
        "GCC_PREPROCESSOR_DEFINITIONS": "SQLITE_ENABLE_RTREE=1"
      }
    },

( Sorry, I'm kinda new to CocoaPods, I thought this might help)

scspijker avatar May 27 '14 09:05 scspijker

Hey you're right! rtree has already been added as a dependency in sqlite3's pod spec. Ok I am going to update SpatialDBKit's pod spec (time to learn the new cocoa pods trunk syntax..)

andreacremaschi avatar May 27 '14 09:05 andreacremaschi

You rock!

I hope the new trunk system for CocoaPods is unlocked soon :)

scspijker avatar May 27 '14 09:05 scspijker

Ok now I remember: I already tried to fix this some month ago but something is broken with cocoa pods and I couldn't validate the pod spec anymore. The issue is with the spatialite .podspec, I opened an issue to keep track of this: https://github.com/andreacremaschi/SpatialDBKit/issues/12

andreacremaschi avatar May 27 '14 10:05 andreacremaschi