Can't add RealmSwift pod to a React Native project "Undefined symbol: protocol description for Swift.Identifible ... for libRealmSwift"

Viewed 188

I've discovered its not possible to add RealmSwift to an Xcode project which was auto-generated by React Native.

If I manually create an Xcode project and then create a pod file and add the following lines to it, then everything builds successfully:

  pod 'Realm', :modular_headers => true
  pod 'RealmSwift', :modular_headers => true

However if these same lines are added to the existing podfile for a React Native project then when compiling there is the following error

Undefined symbols for architecture arm64: "protocol descriptor for Swift.Identifiable", referenced from: l_got.$ss12IdentifiableMp in libRealmSwift.a(Combine.o) ld: symbol(s) not found for architecture arm64

The full podfile is

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'

workspace 'AwesomeProject'

target 'AwesomeProject' do
  config = use_native_modules!
  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  pod 'Realm', :modular_headers => true
  pod 'RealmSwift', :modular_headers => true

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
  end
end

How can I use RealmSwift in a React Native app?

(The modular_headers qualifiers are added because without them there is the following error during pod install:

[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod RealmSwift depends upon Realm, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set use_modular_headers! globally in your Podfile, or specify :modular_headers => true for particular dependencies.)

(Note: I DO NOT want to use the ReactNativeRealm component, firstly this only adds a Javascript version of Realm, secondly I only want to use Realm in the iOS version of the app, not the Android version)

0 Answers
Related