When installing "react-native-firebase" and running pod install, "LoadError" occurs

52 Views Asked by At

I'm developing an iOS app with expo and ReactNative.

I wanted to use Firebase Crashlytics, so I installed "@react-native-firebase/crashlytics". However, when I try to install Pod, a "LoadError" occurs and it fails.

I tried this solution since it's an M1 Mac, but nothing changed.

How to run CocoaPods on Apple Silicon (M1)

What should I do? Below are the error details, code, and steps to reproduce.

Error

LoadError - dlopen(/Users/xxx/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/ffi-1.16.3/lib/ffi_c.bundle, 0x0009)

Procedure

  1. npx expo install @react-native-firebase/app @react-native-firebase/crashlytics expo-build-properties
  2. Add to “expo.plugin” in app.json
  3. cd ios
  4. pod install

File

app.json

{
  "expo": {
    "name": "app",
    "slug": "app",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./src/assets/images/icon.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./src/assets/images/splash.png",
      "resizeMode": "cover",
      "backgroundColor": "#ffffff"
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "googleServicesFile": "./GoogleService-Info.plist",
      "supportsTablet": false,
      "usesAppleSignIn": true,
      "bundleIdentifier": "xx.xx.xx"
    },
    "android": {
      "googleServicesFile": "./GoogleService-Info.plist",
      "adaptiveIcon": {
        "foregroundImage": "./src/assets/images/adaptive-icon.png",
        "backgroundColor": "#ffffff"
      },
      "package": "xx.xx.xx"
    },
    "web": {
      "favicon": "./src/assets/images/favicon.png"
    },
    "experiments": {
      "tsconfigPaths": true
    },
    "plugins": [
      "expo-apple-authentication",
      "@react-native-firebase/app",
      "@react-native-firebase/crashlytics",
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ]
    ],
    "extra": {
      "eas": {
        "projectId": "xxx"
      }
    },
    "owner": "xxx"
  }
}

package.json

{
  "name": "app",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "ts:check": "tsc"
  },
  "dependencies": {
    "@expo-google-fonts/m-plus-rounded-1c": "^0.2.3",
    "@react-native-async-storage/async-storage": "1.18.2",
    "@react-native-community/slider": "4.4.2",
    "@react-native-firebase/app": "^18.8.0",
    "@react-native-firebase/crashlytics": "^18.8.0",
    "@react-native-google-signin/google-signin": "9.0.0",
    "@react-native-masked-view/masked-view": "0.2.9",
    "@react-navigation/bottom-tabs": "^6.5.11",
    "@react-navigation/native": "^6.1.9",
    "@react-navigation/native-stack": "^6.9.17",
    "@types/react": "~18.2.14",
    "@types/react-native-dotenv": "^0.2.2",
    "axios": "^1.6.5",
    "crypto-browserify": "^3.12.0",
    "events": "^3.3.0",
    "expo": "~49.0.15",
    "expo-apple-authentication": "~6.1.0",
    "expo-blur": "~12.4.1",
    "expo-build-properties": "~0.8.3",
    "expo-font": "~11.4.0",
    "expo-linear-gradient": "~12.3.0",
    "expo-splash-screen": "~0.20.5",
    "expo-status-bar": "~1.6.0",
    "firebase": "^10.7.1",
    "oauth-1.0a": "^2.2.6",
    "react": "18.2.0",
    "react-native": "0.72.6",
    "react-native-device-info": "^10.12.0",
    "react-native-dialog": "^9.3.0",
    "react-native-dotenv": "^3.4.9",
    "react-native-gesture-handler": "~2.12.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-safe-area-context": "4.6.3",
    "react-native-screens": "~3.22.0",
    "react-native-swiper": "^1.6.0",
    "react-native-vector-icons": "^10.0.3",
    "react-native-video": "^5.2.1",
    "readable-stream": "^4.5.2",
    "ts-node": "^10.9.2",
    "typescript": "^5.1.3"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@types/react-native": "^0.73.0"
  },
  "private": true
}

Podfile

require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")

require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}

ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0'
ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR']

platform :ios, podfile_properties['ios.deploymentTarget'] || '13.0'
install! 'cocoapods',
  :deterministic_uuids => false

prepare_react_native_project!

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...), which will be excluded. To fix this,
# you can also exclude `react-native-flipper` in `react-native.config.js`
#
# ```js
# module.exports = {
#   dependencies: {
#     ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
#   }
# }
# ```
flipper_config = FlipperConfiguration.disabled
if ENV['NO_FLIPPER'] == '1' then
  # Explicitly disabled through environment variables
  flipper_config = FlipperConfiguration.disabled
elsif podfile_properties.key?('ios.flipper') then
  # Configure Flipper in Podfile.properties.json
  if podfile_properties['ios.flipper'] == 'true' then
    flipper_config = FlipperConfiguration.enabled(["Debug", "Release"])
  elsif podfile_properties['ios.flipper'] != 'false' then
    flipper_config = FlipperConfiguration.enabled(["Debug", "Release"], { 'Flipper' => podfile_properties['ios.flipper'] })
  end
end

target 'app' do
  use_expo_modules!
  config = use_native_modules!

  use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
  use_frameworks! :linkage => ENV['USE_FRAMEWORKS'].to_sym if ENV['USE_FRAMEWORKS']

  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/..",
    # Note that if you have use_frameworks! enabled, Flipper will not work if enabled
    :flipper_configuration => flipper_config
  )

  post_install do |installer|
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)

    # This is necessary for Xcode 14, because it signs resource bundles by default
    # when building for devices.
    installer.target_installation_results.pod_target_installation_results
      .each do |pod_name, target_installation_result|
      target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
        resource_bundle_target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
    end
  end

  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end
end
0

There are 0 best solutions below