React Native ios错误的EAS构建:以下Swift pod尚不能集成为静态库:

voj3qocg  于 2022-12-27  发布在  React
关注(0)|答案(1)|浏览(130)

我正在为我的基于expo的react原生应用程序使用eas build。我无法为ios构建,并且在安装pod期间不断收到错误,错误日志如下:
106 [!]以下Swift pod还不能集成为静态库:107 Swift pod FirebaseCoreInternal依赖于GoogleUtilities,而GoogleUtilities没有定义模块。要选择生成模块Map的目标(当构建为静态库时,这对于从Swift导入模块Map是必要的),您可以在Podfile中全局设置use_modular_headers!,或者为特定依赖项指定:modular_headers => true。108错误:未知错误。有关详细信息,请参阅日志。
我已经搜索了许多与stackoverflow相关的问题,我在node_modules/react-native/template/ios/Podfile中编辑Podfile时使用了这些问题。Podfile的摘录如下所示:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false

# added only these 5 lines to the Podfile
use_frameworks! :linkage => :static
pod 'Firebase', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
use_modular_headers!

target 'HelloWorld' do
  config = use_native_modules!

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

问题:
1.添加的5行代码是否位于代码中的适当位置?我尝试将它们添加到
1.我是否必须编辑除Podfile之外的其他代码?如果是,在哪里编辑什么代码?
已经和这个问题斗争了两个星期了。任何帮助都是最受欢迎的。
谢啦,谢啦

mklgxw1f

mklgxw1f1#

找了又找,混合又匹配,然后反复试验。下面的方法对我很有效。
在node_modules/react-native/template/ios/Podfile中,我将Podfile更改为

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '13.0'
install! 'cocoapods', :deterministic_uuids => false

target 'HelloWorld' do
  config = use_native_modules!

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

  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  $RNFirebaseAsStaticFramework = true

  use_react_native!(
    :path => config[:reactNativePath],
    # Hermes is now enabled by default. Disable by setting this flag to false.
    # Upcoming versions of React Native may rely on get_default_flags(), but
    # we make it explicit here to aid in the React Native upgrade process.
    # :hermes_enabled => true,
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
    # :flipper_configuration => FlipperConfiguration.enabled,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'HelloWorldTests' do
    inherit! :complete
    # Pods for testing
  end

  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

然后还添加了插件到我的app.config.js(如果您使用app.json,情况类似)。

module.exports = {
  expo: {
    name: "appName",
    slug: "appName",
    scheme: "appName",
    version: "1.0.0",
    orientation: "portrait",
    icon: "./assets/icon_1.png",
    userInterfaceStyle: "light",
    splash: {
      image: "./assets/entry_page.png",
      resizeMode: "contain",
      backgroundColor: "#ffffff"
    },
    updates: {
      fallbackToCacheTimeout: 0
    },
    assetBundlePatterns: [
      "**/*"
    ],
    ios: {
      supportsTablet: true,
      bundleIdentifier: "com.myaooo.appName"
    },
    android: {
      adaptiveIcon: {
        foregroundImage: "./assets/icon_1.png",
        backgroundColor: "#FFFFFF"
      },
      package: "com.myaooo.appName",
      versionCode: 5,
      config: {
        googleMaps: {
          apiKey: process.env.PLACES_API_KEY
        }
      }
    },
    web: {
      favicon: "./assets/favicon.png"
    },
    extra: {
      eas: {
        placesApiKey: process.env.PLACES_API_KEY,
        youtTubeApiKey: process.env.YOUTUBE_API_KEY,
        webApiKey: process.env.WEB_API_KEY,
        firebaseApiKey: process.env.apiKey,
        expoGoogleClientId: process.env.EXPO_GO_GOOGLE_CONSOLE_client_id,
        expoAndroidId: process.env.EXPO_GO_GOOGLE_CONSOLE_androidClientId,
        expoIosId: process.env.EXPO_GO_GOOGLE_CONSOLE_iosClientId,
        clientID: process.env.WEB_clientId,
        expoGoogleClientSecret: process.env.EXPO_GO_GOOGLE_CONSOLE_client_secret
      }
    },
    plugins: [
      [
        "expo-build-properties",
        {
        android: { 
          compileSdkVersion:31,
          targetSdkVersion:31,
          buildToolsVersion:"31.0.0"
          },
        ios: {
          deploymentTarget:"13.0",
          useFrameworks: "static"
          }
        }
      ]
    ]
  }
}

实际上,您必须对podfile(添加模块化头文件)和app.json/app.config.js(添加插件)文件进行修改。

相关问题