16

Since Xcode 9 it is possible to use static libraries by omitting the use_frameworks! flag in the Podfile. However, when used with the Pod RealmSwift this results in the following error:

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

The Swift pod `RealmSwift` depends upon `Realm`, which do 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.

Sadly, the proposed solution with use_modular_headers! does not work.

Other things I have tried include:

  • Using the latest Realm version (3.15.0)
  • Use the Objective C version and add Swift support, this won't build and give a module not found error in the RLMSupport.swift file .
  • Adding a bridging header for the Objective C version.
  • Endless clean, rebuild, Xcode relaunches and Derived Data folder cleaning.

It would not be preferable to circumvent CocoaPods and have this dependency be installed in a separate way, since that would make updating a more complex process. I hope there is a solution that works with CocoaPods, Realm and Swift.

3 Answers 3

16

I did the job doing following:

pod 'RealmSwift', '~> 3.17', :modular_headers => true
pod 'Realm', '~> 3.17', :modular_headers => true
0
9

As far as I can tell adding use_modular_headers! to top of Podfile works.

Adding s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } to .podspec doesn't work as far as I can tell. (Cocoapods 1.6.0-beta.2)

example:

target 'Opportunity' do
    use_modular_headers!

end
1

I don't see why it wouldn't work. I got the same issue, and I added use_modular_headers! following way in the podfile and it worked.

target 'Pick Up Lines' do
    use_modular_headers!
    pod 'RealmSwift'
end

By the way, before doing any of it, make sure, you set the deployment target of the project as 11.0.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.