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:

  1. Install npm
  2. Install Yarn: npm install --global yarn
  3. CD into the repository and run yarn install
  4. CD into the ios folder and run pod install
  5. 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)

Most upvoted comments

I had this error for a while and fixed it by adding "$(SDKROOT)/usr/lib/swift" in the build settings of the project for LIBRARY_SEARCH_PATH

It’s important that this is the 1st value in the list.

Your LIBRARY_SEARCH_PATH should look like this

$(SDKROOT)/usr/lib/swift
$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)
$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
$(inherited)

(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 remove RealmSwift from 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

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '10.0'
use_frameworks!

target 'RNRealm' do
  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])

  pod 'Realm', :modular_headers => true
  pod 'IceCream', :git => 'https://github.com/EricWiener/IceCream.git', :commit => '37f73610f23335de98082a96be5478749ae25fce'

  target 'RNRealmTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  # use_flipper!
  # post_install do |installer|
  #   flipper_post_install(installer)
  # end
end

target 'RNRealm-tvOS' do
  # Pods for RNRealm-tvOS

  target 'RNRealm-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

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 included RealmSwift in 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.