SQLite.swift icon indicating copy to clipboard operation
SQLite.swift copied to clipboard

Class SQLiteXXX is implemented in both LinkServices.framework and MyApp error logs

Open guillaumealgis opened this issue 2 years ago • 15 comments

Build Information

  • SQLite.swift 0.14.1
  • Xcode 14.1 (14B47b) / macOS 12.6.1 (21G217)
  • Swift Package manager

Issue

Hi,

We're seeing worrisome errors from the ObjC runtime in our logs when running an app linking both SQLite.swift and the PSPDFKit framework (https://github.com/PSPDFKit/PSPDFKit-SP / https://pspdfkit.com):

Class _TtC6SQLite6Backup is implemented in both /Applications/Xcode-14.1.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/LinkServices.framework/LinkServices (0x1b8c21b70) and /[redacted]/SQLiteConnectionConflict.app/SQLiteConnectionConflict (0x1005a6538). One of the two will be used. Which one is undefined. 

This is reported for several classes : SQLiteBackup, SQLiteConnection, SQLiteStatement, SQLiteTableBuilder.

Full logs
objc[67969]: Class _TtC6SQLite6Backup is implemented in both /Applications/Xcode-14.1.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/LinkServices.framework/LinkServices (0x1b8c21b70) and /[redacted]/SQLiteConnectionConflict.app/SQLiteConnectionConflict (0x100c26538). One of the two will be used. Which one is undefined.
objc[67969]: Class _TtC6SQLite10Connection is implemented in both /Applications/Xcode-14.1.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/LinkServices.framework/LinkServices (0x1b8c218a8) and /[redacted]/SQLiteConnectionConflict.app/SQLiteConnectionConflict (0x100c26788). One of the two will be used. Which one is undefined.
objc[67969]: Class _TtC6SQLite9Statement is implemented in both /Applications/Xcode-14.1.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/LinkServices.framework/LinkServices (0x1b8c21aa0) and /[redacted]/SQLiteConnectionConflict.app/SQLiteConnectionConflict (0x100c26948). One of the two will be used. Which one is undefined.
objc[67969]: Class _TtC6SQLite12TableBuilder is implemented in both /Applications/Xcode-14.1.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/LinkServices.framework/LinkServices (0x1b8c21460) and /[redacted]/SQLiteConnectionConflict.app/SQLiteConnectionConflict (0x100c27ef0). One of the two will be used. Which one is undefined.

You can reproduce the issue by creating a new iOS app in Xcode, and adding both SQLite.swift and PSPDFKit to the app with SwiftPM. A sample project is attached. Run the app and the message will immediately appear in the logs.

Can you help us understand why this error is reported and how we should fix it please?

Thanks for your help!

PS: This issue has also been reported to the PSPDFKit team, I'll update here if I get some updates on the other side.

SQLiteConnectionConflict.zip

guillaumealgis avatar Dec 08 '22 17:12 guillaumealgis

The nice support folks at PSPDFKit pointed out that the problem is not PSPDFKit in and of itself, but the fact that PSPDFKit imports (directly of indirectly) the LinkServices.framework:

I looked at the example project, and it seems the SQLite package has naming collision with one of the private Apple frameworks (LinkServices). If you use any framework that has the transient dependency on this private framework you will get this warnings.

In your example including PSPDFKit triggered the inclusion of LinkServices, however you will experience the same if you import any Apple framework that has the same dependency, for example QuickLook.

They also updated the sample project to demonstrate the problem even without PSPDFKit included: SQLiteConnectionConflict_NoPSPDFKit.zip

(notice the import QuickLook in the AppDelegate.swift)


Also, I was mistaken earlier: I was (manually) demangling the symbols names wrong, and the conflicting symbols are indeed SQLite.Backup, SQLite.Connection, SQLite.Statement, SQLite.TableBuilder.

(which makes much more sense as the classes don't have a SQLite prefix in this library)


Honestly I'm not quite sure how to fix this problem though. It seems it's a known Swift issue, and the solution for now is to use names for packages that are "clear and specific, avoiding common phrases and terms that will overlap".

Is renaming the package something you'd be open to? 😬

guillaumealgis avatar Dec 12 '22 12:12 guillaumealgis

This is impacting us at Airbnb as well.

shepting avatar Jan 09 '23 17:01 shepting

Can adding an alias in both packages solve the problem? You can reference types using the alias if you cannot differentiate initial symbols. We cannot rename original types as it would break their uses. It's the same kind of fix that I did here: https://github.com/Kitura/Kitura-CouchDB/pull/117

nathanfallet avatar Feb 15 '23 10:02 nathanfallet

same here

Tayphoon avatar Apr 18 '23 15:04 Tayphoon

This also happens when an app uses both SQLite.swift and imports and uses the AppIntents system framework, so it's a problem even without other third-party libraries.

jbafford avatar Jun 08 '23 00:06 jbafford

Same issue here. Seems to be causing bugs for others too: https://stackoverflow.com/questions/77206338/xcode-15-ios-17-objc3422-class-ttc6sqlite-is-implemented-in-both-one-o, any updates on this issue?

Highflyer94 avatar Sep 30 '23 12:09 Highflyer94

same here

anyhong avatar Oct 10 '23 13:10 anyhong

Same problem here. Can't seem to track any systematic fix / resolution. Any suggestions?

gvhconnect avatar Oct 10 '23 14:10 gvhconnect

same here

iworkcloud avatar Nov 08 '23 02:11 iworkcloud

To resolve this I just forked the repo and renamed package from SQLite to SQLiteSwift

andrewtheis avatar Dec 08 '23 23:12 andrewtheis

Its a real shame, this issue has been reported multiple times including myself in Apr last year and still not resolved https://github.com/stephencelis/SQLite.swift/issues/1201 https://github.com/stephencelis/SQLite.swift/issues/1226

waelsaad avatar Jan 18 '24 11:01 waelsaad

Still no update?

arnauddorgans avatar Apr 25 '24 16:04 arnauddorgans

What are the consequences of having this conflict in my project? I haven't noticed any issues so far. Was I just lucky that the correct classes were randomly chosen, or isn't there a real problem associated with this conflict?

R1Daneel avatar May 30 '24 09:05 R1Daneel

@nathanfallet I tried with the typealias but it did not solve the issue. Have you considered prefixing all the classes and releasing a major version?

R1Daneel avatar Jul 10 '24 07:07 R1Daneel