16

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?

SudoPlz
  • 20,996
  • 12
  • 82
  • 123
  • 1
    I'm having the same issue react-native-firebase, and according to firebase documentation This is a restriction of Cocoapods and how it interacts with Dynamic Frameworks such as Firebase. 2) Don't have the use_frameworks! flag enabled, but we need to use react-native-augment library and that explicitly requires use_frameworks! and it's base on swift, so If enable react-native-augment works but react-native-firebase (FirebaseCore/FirebaseCore.h' file not found) does not and vice verse, :( – Jan Jan 12 '19 at 19:03

3 Answers3

13

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

Paul Beusterien
  • 27,542
  • 6
  • 83
  • 139
  • 1
    I already tried that and it didn't work, I still get build errors with swift basic libraries missing. Also I don't think promise kit depends on an objective c pod – SudoPlz Oct 21 '18 at 07:25
  • Perhaps - https://stackoverflow.com/questions/50096025/it-gives-errors-when-using-swift-static-library-with-objective-c-project/50495316#50495316 – Paul Beusterien Oct 21 '18 at 17:13
  • I'll try that and post back – SudoPlz Oct 21 '18 at 17:41
  • Nope, it doesn't work, here's the error https://d2ddoduugvun08.cloudfront.net/items/291W1l1f2D133t3P2f1S/Image%202018-10-23%20at%201.51.31%20AM.png?X-CloudApp-Visitor-Id=03b13312cd72b3bc9fa013eaf62629a5&v=08ca6eeb – SudoPlz Oct 22 '18 at 22:52
  • Hmm, looks like it's still not finding the standard Swift libraries – Paul Beusterien Oct 22 '18 at 23:05
  • Yeah, it says not found for `arm64` but I can't figure out why that is. Do I somehow have to specify the architecture manually to force it to build for arm64? – SudoPlz Oct 22 '18 at 23:08
  • After six hours of extreme frustration, this is what solved it for me. – Kwaku Eshun Nov 22 '19 at 04:57
  • Can not use `use_modular_headers!` on react-native project :( It conflict with react-native, I'm still finding a workable workaround :| – Neo.Mxn0 Mar 04 '20 at 09:34
  • With CocoaPods 1.9.0, another option is `use_frameworks! :linkage => :static` – Paul Beusterien Mar 04 '20 at 15:04
9

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.

Rishabh
  • 391
  • 3
  • 13
0

I ran into a similar issue last week, so I created a basic project where I'm using Swift, Firebase but not use_frameworks!, instead using bridging headers.

Don't know if people are still having issues with this, let me know if it helps. https://github.com/jenshandersson/React-Native-Swift