3

I am sharing the realm between containing app and extension (custom Keyboard), and it works ok on simulator, but when I'm trying to run this app on the real device I have the following error:

Cannot load underlying module for 'RealmSwift'

It's kinda strange that it is not an issue with simulator but ok. Let's add pods.framework to Link Binary With Libraries for my extension.

.../Pods/Bolts/Bolts/Common/BFCancellationTokenRegistration.h:19:1: Duplicate interface definition for class 'BFCancellationTokenRegistration'

OK. Let's remove it.

Cannot load underlying module for 'RealmSwift'

Can't argue that. Let's try to add RealmSwift.framework to the extension.

.../Pods/Bolts/Bolts/Common/BFCancellationTokenRegistration.h:19:1: Duplicate interface definition for class 'BFCancellationTokenRegistration'

OK. After several iterations there are several Pods.framework in my project folder and RealmSwift.framework too. Let's remove them all except one Pods.framework. Let's change target membership for this framework to the app and the extension.

.../Pods/Bolts/Bolts/Common/BFCancellationTokenRegistration.h:19:1: Duplicate interface definition for class 'BFCancellationTokenRegistration'

and

Cannot load underlying module for 'RealmSwift'

together.

How could this be fixed?

Update: I am using Realm and Parse cocoapods.

lithium
  • 1,272
  • 1
  • 14
  • 28

1 Answers1

0

It should just be a matter of creating a second section in your Podfile to let you specify the dependencies for your app extension as well as your main app.

target 'MyApp' do
   pod 'RealmSwift'
end

target 'MyAppExtension' do
   pod 'RealmSwift'
end

CocoaPods does a lot of extra steps in setting up the dependencies and installing them into your target at compile time, so I don't think simply copying Pods.framework to the extensions build steps will work.

If you've got multiple references to the same files floating around, then it may be a good idea to completely delete every CocoaPods-related file/folder from your project, and running pod install again to make sure it's all set up again properly.

Let me know how you go!

TiM
  • 15,812
  • 4
  • 51
  • 79