Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove use_frameworks! AND keep using swift pods on an objective-c project?

our project is an Objective-c project.

Since we're using react-native-firebase we can't use use_frameworks! in cocoapods any more.

The problem is we have a swift pod dependency (PromiseKit) and to use swift dependencies we must use use_frameworks! as far as I understand.

What I'm trying to do is have the best of both worlds, aka:

  • remove use_frameworks! so that react-native-firebase works AND
  • keep the PromiseKit swift dependency.

current Podfile:

platform :ios, '10.0'

target 'TestApp' do

    use_frameworks!

    # swift pod
    pod 'PromiseKit'

    # react-native-firebase
    pod 'Firebase/Core', '~> 5.3.0'
    pod 'Firebase/DynamicLinks', '~> 5.3.0'
    pod 'Firebase/Messaging', '~> 5.3.0'

end

I noticed there's this command :modular_headers => true or use_modular_headers which I sense may or may not be relevant to the solution I'm looking for since Cocoapods 1.5 but I can't seem to connect the dots.

Edit:

If I remove use_frameworks! (even if I replace it with use_modular_headers!) I get this error:

enter image description here Any help please?

like image 254
SudoPlz Avatar asked Oct 20 '18 23:10

SudoPlz


2 Answers

Replace use_frameworks! with use_modular_headers! in the Podfile.

From the CocoaPods 1.5 release note referenced:

With CocoaPods 1.5.0, developers are no longer restricted into specifying use_frameworks! in their Podfile in order to install pods that use Swift. Interop with Objective-C should just work. However, if your Swift pod depends on an Objective-C, pod you will need to enable "modular headers" (see below) for that Objective-C pod.

With CocoaPods 1.9.0, it is now possible to build frameworks both statically and dynamically. Use use_frameworks! :linkage => :static

like image 171
Paul Beusterien Avatar answered Oct 14 '22 05:10

Paul Beusterien


I have also faced this issue. and find a perfect solution for this.

https://github.com/joncardasis/cocoapods-user-defined-build-types

this is a plugin for cocoapods by which we can specify to use "dynamic framework" (i.e. what "use_framework" does) on a particular pod. this feature is not currently supported in cocoapods, that is why use this plugin to resolve your issue.

like image 28
Rishabh Avatar answered Oct 14 '22 05:10

Rishabh