amplitude / Amplitude-Swift

Native iOS/tvOS/macOS/watchOS SDK
MIT License
26 stars 20 forks source link

Possible duplication of sqlite3 library causes multiple error #220

Open doganaltinbas opened 2 weeks ago

doganaltinbas commented 2 weeks ago

I have project that sqlite3 pod already installed to manipulate data stored in app. After I installed Amplitude via SPM I got following errors when I run the project. I got Could not build Objective-C module 'SQLite3' for many files and many redefinition method errors like following:

sqlite3pod/src/sqlite3.h:654:8 Redefinition of 'sqlite3_file'
sqlite3pod/src/sqlite3.h:752:8 Redefinition of 'sqlite3_io_methods'
sqlite3pod/src/sqlite3.h:1234:8 Redefinition of 'sqlite3_vfs'

Would that be related if Amplitude also utilizes the sqlite? Any ideas on how to fix it?

Environment

crleona commented 2 weeks ago

Hi @doganaltinbas we do link to the system Sqlite3 distribution to be able to import files from our legacy SDK. Is there a reason you are importing sqlite via a pod vs just using the system distribution?

doganaltinbas commented 2 weeks ago

The legacy code I'm working with uses SQLite pod to cache bulk data for offline mode. I resolved the issue by converting the wrapper I wrote for Amplitude into Objective-C. However, I'm still unsure why the Amplitude wrapper causes errors when used with Swift.

crleona commented 2 weeks ago

@doganaltinbas ObjC is generally a bit less strict with linking issues. The core issue is that we link with the system sqlite3 distribution, and you are linking to an external one, and there's no namespacing with C APIs. Generally using the system library is encouraged as it leads to smaller app sizes and launch times. You may need the pod if you need a specific SQLite3 version or using non-standard compilation options, but these tend to be extremely uncommon cases. Do you have a specific use case as to why you can't use the system SQLite distribution?

doganaltinbas commented 1 week ago

@crleona We've used it to save custom objects and implement custom flags that the standard Apple SQLite3 library doesn't support.