andreacremaschi / SpatialDBKit

An Objective-C lightweight spatial RDBMS (based on SQLite/SpatiaLite)
Other
73 stars 67 forks source link

Issue with Spatial Index requests #4

Open doubotis opened 10 years ago

doubotis commented 10 years ago

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

andreacremaschi commented 10 years ago

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

scspijker commented 10 years ago

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?

andreacremaschi commented 10 years ago

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.

scspijker commented 10 years ago

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)

andreacremaschi commented 10 years ago

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..)

scspijker commented 10 years ago

You rock!

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

andreacremaschi commented 10 years ago

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