2

After updating to React Native 0.61.5 I am having problems linking libraries that can be linked only dynamically (@react-native-mapbox-gl/maps).

The solution would normally be to enable dynamic libraries in the Podfile (setting use_frameworks!). However, as result this makes all libraries dynamic and causes problems with libraries that can only be linked statically (react-native-firebase).

Is there any solution that would satisfy these conflicting requirements?

When use_frameworks! is set, this error gets thrown at runtime:

dyld: Library not loaded: @rpath/MapboxMobileEvents.framework/MapboxMobileEvents
  Referenced from: /private/var/containers/Bundle/Application/4A4F5BC3-2A1D-4949-9423-71EF7EFE79FD/ImmoWert2Go.app/Frameworks/Mapbox.framework/Mapbox
  Reason: image not found

When use_frameworks! is not set, pod install throws this error:

[!] The 'Pods-ImmoWert2Go' target has transitive dependencies that include statically linked binaries: (FirebaseCore, FirebaseCoreDiagnostics, GoogleDataTransportCCTSupport, GoogleDataTransport, and FirebaseInstanceID)
Peter G.
  • 7,816
  • 20
  • 80
  • 154

1 Answers1

1

@react-native-mapbox-gl/maps is currently not available as a static library, so the whole project needs to be configured to use dynamic libraries, which is discouraged by Apple.

The solution was to add these lines at the beginning of the Podfile:

# Set libraries as dynamic by default
use_frameworks!

# Set specific libraries as static (react-native-firebase)
pre_install do |installer|
  installer.pod_targets.each do |pod|
    if pod.name.start_with?('RNFB')
      def pod.build_type;
        Pod::Target::BuildType.static_library
      end
    end
  end
end

Once this was done, RNFirebaseUtil.h needs to be patched from

#import <Firebase.h>

to

#import "Firebase.h"
Peter G.
  • 7,816
  • 20
  • 80
  • 154