stephencelis / SQLite.swift

A type-safe, Swift-language layer over SQLite3.
MIT License
9.7k stars 1.56k forks source link

Xcode 13 Problem "dyld: Library not loaded: @rpath/SQLite.framework/Versions/A/SQLite" #1087

Closed RussOggi255 closed 2 years ago

RussOggi255 commented 3 years ago

I have used SQLite.swift before in an iOS project and it worked fine (Many thanks)

I recently updated to Xcode 13 and downloaded the latest SQLite.swift-master Dragged/Dropped it into my MacOS application project and it built OK but when I run it I get the errors;

_dyld: Library not loaded: @rpath/SQLite.framework/Versions/A/SQLite Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/CSS_Editor-bgoenpovwcecaffqishrfloactge/Build/Products/Debug/CSS_Editor.app/Contents/MacOS/CSS_Editor Reason: no suitable image found. Did find: /Users/username/Library/Developer/Xcode/DerivedData/CSS_Editor-bgoenpovwcecaffqishrfloactge/Build/Products/Debug/SQLite.framework/Versions/A/SQLite: code signature in (/Users/username/Library/Developer/Xcode/DerivedData/CSS_Editor-bgoenpovwcecaffqishrfloactge/Build/Products/Debug/SQLite.framework/Versions/A/SQLite) not valid for use in process using Library Validation: mapping process has no Team ID and is not a platform binary /Users/username/Library/Developer/Xcode/DerivedData/CSS_Editor-bgoenpovwcecaffqishrfloactge/Build/Products/Debug/SQLite.framework/Versions/A/SQLite: stat() failed with errno=1 /Users/username/Library/Developer/Xcode/DerivedData/CSS_Editor-bgoenpovwcecaffqishrfloactge/Build/Products/Debug/CSS_Editor.app/Contents/MacOS/../Frameworks/SQLite.framework/Versions/A/SQLite: code signature in (/Users/username/Library/Developer/Xcode/DerivedData/CSS_Editor-bgoenpovwcecaffqishrfloactge/Build/Products/Debug/CSS_Editor.app/Contents/MacOS/../Frameworks/SQLite.framework/Versions/A/SQLite) not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?) /Users/username/Library/Developer/Xcode/DerivedData/CSS_Editor-bgoenpovwcecaffqishrfloactge/Build/Products/Debug/CSSEditor.app/Contents/MacOS/../Frameworks/SQLite.framework/Versions/A/SQLite: stat() failed with errno=1

I din't remember doing anything different from what I did for iOS and MacOS. Am I missing something or is this a known issue

nikiizvorski commented 2 years ago

I am actually having the same issue right now. I don't really see how anything is changed on my side which i didn't really change and i get missing symbols

jberkel commented 2 years ago

The error message seems to indicate that it is a problem with code signing, so maybe a problem with your project setup?

nikiizvorski commented 2 years ago

This is the message i get on my framework i didn't get that before. What i have done is i updated cocoapods to 1.11.2 i believe and nothing more. One project builds with the version 13.1 which is the app and the xcframework is with the 13.0 version i am getting the the library SQLite over cocoapod dependency. Here is the output i am getting:

dyld: Symbol not found: _$s6SQLite10ConnectionC8LocationO8inMemoryyA2EmFWC Referenced from: /private/var/containers/Bundle/Application/0250C180-1202-4335-A961-C5950B7B58A3/NikiApp.app/Frameworks/TestSDK.framework/TestSDK Expected in: /private/var/containers/Bundle/Application/0250C180-1202-4335-A961-C5950B7B58A3/NikiApp.app/Frameworks/SQLite.framework/SQLite in /private/var/containers/Bundle/Application/0250C180-1202-4335-A961-C5950B7B58A3/NikiApp.app/Frameworks/TestSDK.framework/TestSDK dyld: launch, loading dependent libraries DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib (lldb)

Would really appreciate the help on this...

jberkel commented 2 years ago

@nikiizvorski in your application you have a framework which depends on SQLite? Have you tried downgrading cocoapods? Did you add the SQLite dependency to the framework target, or the app target?

nikiizvorski commented 2 years ago

Hey @jberkel we used a previous version of cocoapod that was quite old and it was working good as we tested it. Next step i will try again to downgrade to a previous version. Which one do you believe it would be the best? The dependency is added to the XCFramework and it is with Do not embed and into the test app is do not embed also but also it is been installed manually this is the usage in both:

pod 'SQLite.swift', '~> 0.13.0'

nikiizvorski commented 2 years ago

I have tried completely downgrading to 1.10.2 and same issue. After i downgraded to 1.8.4 version everything worked as expected. Seems something have to be updated. Even if it's manual i would appreciate the help for example editing the paths somehow i don't really have any good idea right now but taking suggestions. The SQLite implementation you guys have is awesome and works very very well. I even added tests to it and we are happy with it.

jberkel commented 2 years ago

Have you tried static linking with use_frameworks! :linkage => :static ?

nikiizvorski commented 2 years ago

Hey @jberkel should that be in both project or only the app side?

nikiizvorski commented 2 years ago

After using the suggestion seems to work as expected! I am using cocoapods 1.10.0 currently. Maybe i should switch to a higher version. Here is the issue i am getting right now:

objc[367]: Class PodsDummy_SQLite_swift is implemented in both /private/var/containers/Bundle/Application/7ACF543F-7E06-4FE7-95AD-6DC441A5A1A4/NikiApp.app/Frameworks/TestSDK.framework/TestSDK (0x101c9e408) and /private/var/containers/Bundle/Application/7ACF543F-7E06-4FE7-95AD-6DC441A5A1A4/NikiApp.app/NikiApp (0x101125770). One of the two will be used. Which one is undefined.
objc[367]: Class _TtC6SQLiteP33_AC67620244ED67AEDED85ABF4E1A194813SQLiteEncoder is implemented in both /private/var/containers/Bundle/Application/7ACF543F-7E06-4FE7-95AD-6DC441A5A1A4/NikiApp.app/Frameworks/TestSDK.framework/TestSDK (0x101ca5de0) and /private/var/containers/Bundle/Application/7ACF543F-7E06-4FE7-95AD-6DC441A5A1A4/NikiApp.app/NikiApp (0x101125a70). One of the two will be used. Which one is undefined.
nikiizvorski commented 2 years ago

I have tried having the following which works and i am using version 1.10.0 right now. It's used in both projects framework and app

use_frameworks! :linkage => :static 

What i get as output is the following

objc[367]: Class PodsDummy_SQLite_swift is implemented in both /private/var/containers/Bundle/Application/7ACF543F-7E06-4FE7-95AD-6DC441A5A1A4/NikiApp.app/Frameworks/TestSDK.framework/TestSDK (0x101c9e408) and /private/var/containers/Bundle/Application/7ACF543F-7E06-4FE7-95AD-6DC441A5A1A4/NikiApp.app/NikiApp (0x101125770). One of the two will be used. Which one is undefined.
objc[367]: Class _TtC6SQLiteP33_AC67620244ED67AEDED85ABF4E1A194813SQLiteEncoder is implemented in both /private/var/containers/Bundle/Application/7ACF543F-7E06-4FE7-95AD-6DC441A5A1A4/NikiApp.app/Frameworks/TestSDK.framework/TestSDK (0x101ca5de0) and /private/var/containers/Bundle/Application/7ACF543F-7E06-4FE7-95AD-6DC441A5A1A4/NikiApp.app/NikiApp (0x101125a70). One of the two will be used. Which one is undefined.

What i use and i think i need more than the static is dynamic which doesn't seem to find the dependency

use_frameworks! :linkage => :dynamic 

What i get as output is the following

dyld: Symbol not found: _$s6SQLite10ConnectionC8LocationO8inMemoryyA2EmFWC
  Referenced from: /private/var/containers/Bundle/Application/4A52E5A2-2A12-457C-A0AC-BADD4A3F6BFB/NikiApp.app/Frameworks/TestSDK.framework/TestSDK
  Expected in: /private/var/containers/Bundle/Application/4A52E5A2-2A12-457C-A0AC-BADD4A3F6BFB/NikiApp.app/Frameworks/SQLite.framework/SQLite
 in /private/var/containers/Bundle/Application/4A52E5A2-2A12-457C-A0AC-BADD4A3F6BFB/NikiApp.app/Frameworks/TestSDK.framework/TestSDK
dyld: launch, loading dependent libraries
DYLD_LIBRARY_PATH=/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib

From this i should be able to get some suggestions right? Once again it's highly appreciated. I believe with the old version it was linked dynamically because i never got duplicate symbols on 1.8.4

use_frameworks! :linkage => :dynamic on the pod and use_frameworks! :linkage => :static on the app i get the following 

What i get as output is the following

dyld: Library not loaded: @rpath/SQLite.framework/SQLite
  Referenced from: /private/var/containers/Bundle/Application/2F9208DE-8D40-4D2B-830B-DC589BDCDB81/NikiApp.app/Frameworks/TestSDK.framework/TestSDK
  Reason: image not found
dyld: launch, loading dependent libraries
DYLD_LIBRARY_PATH=/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib

If i don't put anything for example only adding the pod inside both podspec i get Framework not found error on app project.

Once again. Really appreciate the feedback and all the help you have provided. If i could get them to link dynamically would be perfect.

jberkel commented 2 years ago

It looks like the libraries are not part of the resulting binary. It's really hard to help you without access to the project, and I'm fairly sure that this is not a problem with SQLite.swift, but a problem with your project setup, so will close this issue.

I'd suggest starting a new minimal project from scratch, and see if the pod integration works there.

nikiizvorski commented 2 years ago

/Users/nikiizvorski/Library/Developer/Xcode/DerivedData/NikiApp-cueifmmncljweneycdourckmtrke/Build/Products/Debug-iphoneos/TestSDK.framework/Modules/TestSDK.swiftmodule/arm64-apple-ios.swiftinterface /Users/nikiizvorski/Library/Developer/Xcode/DerivedData/NikiApp-cueifmmncljweneycdourckmtrke/Build/Products/Debug-iphoneos/TestSDK.framework/Modules/TestSDK.swiftmodule/arm64-apple-ios.swiftinterface:12:8: Cannot load underlying module for 'SQLite'

That's the latest error get no matter how i add the dependency it will always complain. I see absolutely nothing wrong with the current project it's the same as the previous one. Maybe it could be the XCode version but i rather not switch that at this stage.