clemensg / sqlite3pod

The repository for the sqlite3 podspec used in CocoaPods.
https://www.sqlite.org
MIT License
29 stars 17 forks source link

Compile error #21

Closed gennaios closed 8 months ago

gennaios commented 1 year ago

Hello,

Apologies as I haven’t tried too much troubleshooting yet. Since some version of sqlite3pod, I believe 3.39.2, I haven’t been able to compile this module. The error:

(1447, 9) 'sqlite3_vfs' has different definitions in different modules; first difference is defined here found field 'xOpen' with type 'int (*)(sqlite3_vfs *, const char *, sqlite3_file *, int, int *)' (aka 'int (*)(struct sqlite3_vfs *, const char *, struct sqlite3_file *, int, int *)')

Podfile:

platform :osx, '10.15'
use_modular_headers!

def testing_pods
  pod 'Nimble', '~> 9'
end

target 'App' do
  pod 'GRDB.swift', '~> 5'
  pod 'sqlite3', inhibit_warnings: true
  pod 'sqlite3/fts5'
  pod 'sqlite3/snapshot'
  pod 'sqlite3/stat4'
  pod 'ZippyJSON', :inhibit_warnings => true

  target 'AppTests' do
    pod 'GRDB.swift', '~> 5'
    pod 'sqlite3', inhibit_warnings: true
    pod 'sqlite3/fts5'
    pod 'sqlite3/snapshot'
    pod 'sqlite3/stat4'
    pod 'ZippyJSON', :inhibit_warnings => true
    testing_pods
  end

  target 'AppUITests' do
    inherit! :complete
    testing_pods
  end
end

post_install do |installer|
  installer.pods_project.targets.select { |target| target.name == "GRDB.swift" }.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['OTHER_SWIFT_FLAGS'] = "$(inherited) -D SQLITE_ENABLE_FTS5"
    end
  end
  installer.pods_project.targets.select { |target| target.name == "sqlite3" }.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['OTHER_CFLAGS'] = "$(inherited) -DSQLITE_DQS=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_OMIT_DECLTYPE=1 -DSQLITE_OMIT_PROGRESS_CALLBACK=1 -DSQLITE_OMIT_SHARED_CACHE=1 -DSQLITE_USE_ALLOCA=1 -DSQLITE_ENABLE_NULL_TRIM=1"
    end
  end
end

Such has worked until some months ago. This is on Ventura. Some options are set since others use an older version of macOS to compile thus platform 10.15. I’ve tried removing the custom SQLite build settings though that didn’t do anything.

Maybe it is some recent changes to SQLite itself, or some build settings. I haven’t tried to narrow such down yet. As it seems no one else has mentioned such, maybe indeed it is something in my setup. Any help would be appreciated.

clemensg commented 1 year ago

(1447, 9) 'sqlite3_vfs' has different definitions in different modules; first difference is defined here found field 'xOpen' with type 'int ()(sqlite3_vfs , const char , sqlite3_file , int, int )' (aka 'int ()(struct sqlite3_vfs , const char , struct sqlite3_file , int, int )')

Does it also say where the second definition is? Removing all CocoaPods files/cache dirs and installing again does not help I guess?

gennaios commented 1 year ago

Removing the Pods folder worked. Didn’t think of that. Thank you!

gennaios commented 1 year ago

The last compile maybe was a fluke. I had build after pod install but since then haven't been able to successfully build. A more complete error:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sqlite3.h:1447:9 'sqlite3_vfs' has different definitions in different modules; first difference is defined here found field 'xOpen' with type 'int (*)(sqlite3_vfs *, const char *, sqlite3_file *, int, int *)' (aka 'int (*)(struct sqlite3_vfs *, const char *, struct sqlite3_file *, int, int *)')

But in 'sqlite3.sqlite3' found field 'xOpen' with type 'int (*)(sqlite3_vfs *, sqlite3_filename, sqlite3_file *, int, int *)' (aka 'int (*)(struct sqlite3_vfs *, const char *, struct sqlite3_file *, int, int *)')

In file included from <module-includes>:2:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sqlite3ext.h:36:8 Type 'struct sqlite3_api_routines' has incompatible definitions in different translation units

Field 'create_filename' has type 'char *(*)(const char *, const char *, const char *, int, const char **)' here

Field 'create_filename' has type 'const char *(*)(const char *, const char *, const char *, int, const char **)' here
gennaios commented 1 year ago

I think 3.39.2 is the last working version. Considering the Xcode error, I would guess that corresponds to changes in SQLite and some changes to sqlite3_vfs. I’m surprised such doesn’t occur with all versions of Xcode that include the older SQLite source.

Instead of use_modular_headers, I tried use_frameworks though that didn’t work either. Maybe that setting I can experiment with. Thought if it is indeed some conflict of later changes to SQLite, maybe I need to wait for a future Xcode that includes SQLite 3.39.3+. Still I find it surprising no one else has mentioned such as possibly occurring in general on Ventura and or 3.39.3+.

clemensg commented 8 months ago

They are now shipping SQLite 3.43.2 with the current SDK, so this problem should no longer occur. Please reopen if it still does.