realm-swift: Undefined symbols for architecture x86_64 "protocol descriptor for Swift.Identifiable"
Goals
I am trying to make a minimal example of RealmJS + RealmSwift to help RealmJS debug an issue. When trying to make this minimal example, I was unable to compile RealmSwift with an error: Undefined symbol: protocol descriptor for Swift.Identifiable
Expected Results
I expected to be able to compile (or at least to run into the same issue I described in the RealmJS issue).
Actual Results
Undefined symbols for architecture x86_64:
"protocol descriptor for Swift.Identifiable", referenced from:
protocol requirements base descriptor for RealmSwift.ObjectKeyIdentifiable in libRealmSwift.a(Combine.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Steps for others to Reproduce
Here is a Github repo with the sample project. It’s a react-native project, so you will need to set it up as such:
- Install npm
- Install Yarn:
npm install --global yarn - CD into the repository and run
yarn install - CD into the
iosfolder and runpod install - Open up the .xcworkspace and run the app
Code Sample
Please see above
Version of Realm and Tooling
ProductName: macOS
ProductVersion: 11.2.1
BuildVersion: 20D74
/Applications/Xcode.app/Contents/Developer
Xcode 12.4
Build version 12D4e
/usr/local/bin/pod
1.10.1
Realm (10.5.1)
RealmSwift (10.5.1)
/bin/bash
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20)
carthage not found
(not in use here)
/usr/bin/git
git version 2.24.3 (Apple Git-128)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (1 by maintainers)
I had this error for a while and fixed it by adding
"$(SDKROOT)/usr/lib/swift"in the build settings of the project forLIBRARY_SEARCH_PATHIt’s important that this is the 1st value in the list.
Your
LIBRARY_SEARCH_PATHshould look like this(No need for
use_frameworks!or:modular_headers => true)Hi @EricWiener i was able to reproduce this issue and I think I have a workaround that will help you run your project.
I would first recommend you to add
use_frameworks!to you Podfile, which tells cocoa pods to use dynamic libraries instead of static libraries. You can even removeRealmSwiftfrom the podfile, as your project is in objective-c and there is no need to import RealmSwift to you main project.You can see a sample of the Podfile that worked on my project
And then finally, i would recommend you to add a swift file into your project, this will create automatically a bridging header for your project, to tell your compiler there is some swift code within you project (your IceCream library and RealmSwift which is a subdependency of your library)
Let me know if you have anymore questions
Got it. Thanks so much for the help. I’ll look into it more. A bit puzzled because RealmJS + RealmSwift works perfectly in my existing apps (without specifying
use_frameworks!or includedRealmSwiftin the Podfile), but only works in the new app with your workaround.Regardless, thanks so much for your help and for solving this issue. I’ll mark it as closed now.