Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't compile React Native iOS app to run on physical device, issue with React Native Firebase

For some reason since recently, I cannot run my React Native app on a physical device from Xcode or even from the command line. I'm getting the following error:

duplicate symbol '_md5_block_data_order' in:
    /XXX/Library/Developer/Xcode/DerivedData/XXXX-bdrylwsxpcqgzvgkcljteyttcdmr/Build/Products/Debug-iphoneos/BoringSSL-GRPC/libBoringSSL-GRPC.a(md5.o)
    /XXX/project/ios/Pods/OpenSSL-Universal/ios/lib/libcrypto.a(md5_dgst.o)
ld: 1 duplicate symbol for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

However it works fine from a simulator. And I can upload the app to AppStoreConnect without any issue.

From what I understand it looks like the same symbol exists in 2 libraries. Not sure why, most likely one of the mobile app dependencies.

In the list of Pods installed I have both BoringSSL-GRPC (0.0.3) and OpenSSL-Universal (1.0.2.19)

BoringSSL is used by Firebase and OpenSSL is used by Flipper.

This is the list of third party dependencies I use:

  pod 'Firebase/Core', '~> 6.3.0'

  pod 'Firebase/Messaging', '~> 6.3.0'

  pod 'Firebase/Firestore', '~> 6.3.0'

  pod 'Firebase/Auth', '~> 6.3.0'

  pod 'TrustKit'

  pod 'Stripe', '16.0.0'

  pod 'Amplitude-iOS', '~> 4.5'

  pod 'Intercom', '~> 5.5.1'

  flipper_pods()

When I remove Firebase all together, it works fine and I can run my app on the device. But I need Firebase...

Any idea how to resolve this?

Thanks!

like image 426
alexmngn Avatar asked Jan 31 '20 15:01

alexmngn


People also ask

How do I run a React Native app on iOS physical device?

The first thing to do is to connect your iOS device to your Mac with a USB cable. Open your react native app's directory, navigate to ios folder, and double-click on . xcworkspace file to open the Xcode. Next, open the Product menu, go to Destination, and select your device.

Can React Native app run on iOS?

Once you have your React Native project initialized, you can run npx react-native run-ios inside the newly created project directory. If everything is set up correctly, you should see your new app running in the iOS Simulator shortly.

Can React Native run on both iOS and Android?

With React Native, developers can write real, natively rendering mobile applications for iOS and Android. It helps build apps on two platforms at once, while maintaining the look, feel, and productivity of an app built on the specific iOS or Android platform.


2 Answers

I had the same issue for latest RN and firebase modules. There is PR https://github.com/facebook/flipper/pull/1171 in the flipper, that will fix this issue, but it is still not merged to master, and it seems that 1.0.2.19 version is used for OpenSSL.

So to run your app in real devices I just disabled Flipper. To do it you need to:

  1. comment all Flipper's lines in your pod file and in AppDelegate.m file.
  2. remove yarn.lock file and pods folder
  3. run pod install again.

After these steps all will work.

like image 79
Max Avatar answered Oct 20 '22 22:10

Max


This is a problem others are noticing as well https://github.com/invertase/react-native-firebase/issues/3384

The symptoms most are seeing look like:

Pods/OpenSSL-Universal/ios/lib/libcrypto.a(bio_lib.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64

There is an upstream issue logged here https://github.com/facebook/flipper/issues/485 that was closed before it became clear it would be a bigger problem than expected.

I tested a workaround which is sub-optimal but functional for now until an OpenSSL library with bitcode is available in the transitive dependencies - the workaround is

  • disable bitcode for development (that is where flipper exists)
  • make sure you have dead code stripping turned on everywhere
  • enable bitcode for release mode

In my experience this worked for debug builds on local devices (where it failed before) and a TestFlight build in release mode worked

Hope this helps!

like image 40
Mike Hardy Avatar answered Oct 20 '22 20:10

Mike Hardy