Swift Pod还不能集成为静态图书馆Firebasecoreintern-library

发布于 2025-01-30 03:29:45 字数 707 浏览 3 评论 0 原文

我正在flutter flutter构建一个应用程序。我在执行“ pod install ”或“ pod install-repo-update ”或“ pod update ”和pod时,我收到了此错误消息。安装失败并停止。

错误消息:

[!]以下迅速豆荚还不能集成为静态 库:

Swift Pod firebasecoreintern-library-library 取决于 Google-utilities-library ,该不定义模块。选择 这些目标生成模块地图(这是导入的必要条件 它们是从Swift构建为静态库时),您可以设置 use_modular_headers!在您的podfile中或指定 :modular_headers => true 针对特定依赖关系。

我的podfile:

platform :ios, '11.0'

...

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

...

I am building an app by Flutter. I got this error message when doing "pod install" or "pod install --repo-update" or "pod update" and the pod install failed and stopped.

The error message:

[!] The following Swift pods cannot yet be integrated as static
libraries:

The Swift pod FirebaseCoreInternal-library depends upon
GoogleUtilities-library, which does not define modules. To opt into
those targets generating module maps (which is necessary to import
them from Swift when building as static libraries), you may set
use_modular_headers! globally in your Podfile, or specify
:modular_headers => true for particular dependencies.

My Podfile:

platform :ios, '11.0'

...

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(27

北陌 2025-02-06 03:29:45

您可能不需要使用 use_frameworks! use_modular_headers!,因为它与use_flipper发生冲突,

您可以在iOS/podfile中添加以下内容,而无需在iOS/podfile中使用它们

  platform :ios, '12.4'
  ...
  ...
  
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true

  #....add any library need headers

You may not need to use use_frameworks! or use_modular_headers! because it's getting conflict with use_flipper

You can add the following without using them in ios/Podfile:

  platform :ios, '12.4'
  ...
  ...
  
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true

  #....add any library need headers

Best

留一抹残留的笑 2025-02-06 03:29:45

对于 firebase的最新版本15.1.1 带有 react-native 0.69.1 无需启用 use_frameworks ,因为它会导致部署中的错误实际设备

,因此您只需要添加 firebase 模块化,然后将标题设置为true。

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

并继续使用Flipper,

  use_flipper!()

我在真实设备上都在Android和iOS上测试了它,并且效果很好!

For newest version of firebase 15.1.1 with react-native 0.69.1 no need to enable use_frameworks because it will lead to errors in deploying in real devices

So you just need to add the firebase modulars and set headers to true.

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

And keep using flipper

  use_flipper!()

I tested it on both Android and IOS on real devices and it works great! ????

Here is what my Podfile looks like

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
    
    target 'myApp' do
      config = use_native_modules!
      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],
        # to enable hermes on iOS, change `false` to `true` and then install pods
        :hermes_enabled => flags[:hermes_enabled],
        :fabric_enabled => flags[:fabric_enabled],
        # An absolute path to your application root.
        :app_path => "#{Pod::Config.instance.installation_root}/.."
      )
    
      target 'myAppTests' do
        inherit! :complete
        # Pods for testing
      end
    
      # Enables Flipper.
      #
      # Note that if you have use_frameworks! enabled, Flipper will not work and
      # you should disable the next line.
      use_flipper!()
    
      post_install do |installer|
        react_native_post_install(installer)
        __apply_Xcode_12_5_M1_post_install_workaround(installer)
      end
    end

-

UPDATED 20/Jul

If you wanted to use rich content notifications like notifications with images. Following this article by firebase will ask you to enable use_frameworks as well so my solution for that is to use modular_headers => true for the following packages

target 'richNotification' do
    pod 'FirebaseCoreInternal', :modular_headers => true
    pod 'Firebase/Messaging', :modular_headers => true
    pod 'GoogleUtilities', :modular_headers => true
end

NOTE: Make sure richNotification target is at the bottom of the podfile. see below how my final podfile looks like

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

target 'MyApp' do
  config = use_native_modules!
  flags = get_default_flags()

#     use_frameworks! :linkage => :static
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  $RNFirebaseAsStaticFramework = true
  # Flags change depending on the env values.


  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

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

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()

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

target 'richNotification' do
    pod 'FirebaseCoreInternal', :modular_headers => true
    pod 'Firebase/Messaging', :modular_headers => true
    pod 'GoogleUtilities', :modular_headers => true
end

I tested it on both Android and IOS, it works great!! ????

For Testing
Send the following JSON data to https://fcm.googleapis.com/fcm/send as a"POST", and make sure to put in the headers "mutable-content": "1", See the screenshot below

{
        "to": " Put here your mobile fcm token ",
        "notification": {
            "title": "You have received a new request",
            "body": "Radiohead - Street Spirit (Fade Out)",
            "content_available" : "true",
            "priority" : "high",
            "sound":"defualt",
            "image": "https://i.ytimg.com/vi/LCJblaUkkfc/hq720.jpg"
        },
        "android": {
          "priority": "high",
          "notification": {
            "imageUrl": "https://www.youtube.com/watch?v=o3mP3mJDL2k"
          }
        },
        "apns": {
          "payload": {
            "aps": {
              "mutable-content": "1",
              "content-available": "true",
            },
            "imageUrl": "https://i.ytimg.com/vi/panR4xwt0wM/hqdefault.jpg",
            "fcm_options": {
              "imageUrl": "https://i.ytimg.com/vi/panR4xwt0wM/hqdefault.jpg"
            }
          },
          "headers": {
            "mutable-content": "1",
            "apns-push-type": "background",
            "apns-priority": "5", 
            "apns-topic": "com.paidtabs" 
          }
        },
        "webpush": {
          "headers": {
            "image": "https://koenig-media.raywenderlich.com/uploads/2021/01/good_news_petsicon.png"
          }
        },
        "data":{
          "passingDataToApp" : "Mario",
          "body" : "great match!",
          "Room" : "PortugalVSDenmark"
        }
      }

Headers look like
headers

酷到爆炸 2025-02-06 03:29:45

pod“ google utilities”,:modular_headers =>真的;

将此行添加到podfile

pod 'GoogleUtilities', :modular_headers => true;

add this line to podfile

居里长安 2025-02-06 03:29:45

这也对我有用。 @virluz刚刚添加到您的答案

版本的firebase 16.5,with react-native 70.5

添加

pod 'GoogleUtilities', :modular_headers => true;

只是在以下代码之间

flags = get_default_flags()

    pod 'GoogleUtilities', :modular_headers => true;


  use_react_native!(
    :path => config[:reactNativePath],

:之后您可以运行

arch -x86_64 pod install

This worked for me too. @virluz just adding to your answer

Version of firebase 16.5 with react-native 70.5

Just add

pod 'GoogleUtilities', :modular_headers => true;

Between below code :

flags = get_default_flags()

    pod 'GoogleUtilities', :modular_headers => true;


  use_react_native!(
    :path => config[:reactNativePath],

After that you can run

arch -x86_64 pod install
情场扛把子 2025-02-06 03:29:45

删除 use_frameworks ,因为与 use_flipper 相冲突并添加所有这些libs for me

  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true  
  pod 'FirebaseStorageInternal', :modular_headers => true
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseAppCheckInterop', :modular_headers => true
  pod 'FirebaseAuthInterop', :modular_headers => true
  pod 'FirebaseMessagingInterop', :modular_headers => true
  pod 'GTMSessionFetcher', :modular_headers => true
  pod 'FirebaseAppCheckInterop', :modular_headers => true
  pod 'FirebaseAuthInterop', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true

>和 firebasestorage-h.swift 需要 use_frameworks ,因此您可能对这些文件有错误。也许您可能更喜欢使用 Axios 或类似的lib来调用您的端点API和/或 aws s3 来保存文件。

Removing use_frameworks because is conflicting with use_flipper and adding all this libs worked for me

  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true  
  pod 'FirebaseStorageInternal', :modular_headers => true
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseAppCheckInterop', :modular_headers => true
  pod 'FirebaseAuthInterop', :modular_headers => true
  pod 'FirebaseMessagingInterop', :modular_headers => true
  pod 'GTMSessionFetcher', :modular_headers => true
  pod 'FirebaseAppCheckInterop', :modular_headers => true
  pod 'FirebaseAuthInterop', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true

Heads up! FirebaseFunctions-h.swift and FirebaseStorage-h.swift requires use_frameworks, so probably you may have an error with these files. Perhaps you may prefer use axios or similar lib to invoke your endpoint api and/or aws s3 to save your file instead.

瞄了个咪的 2025-02-06 03:29:45

❗️ArectNative Developers:

我询问了 React-Native-Firebase 的维护者,关于这里找到的解决方案,他们说该应用程序最终会随着这些解决方法而破裂,因为模块转换为迅速。 firebaseFunctions-h.swift firebasestorage-h.swift 已经无法正常工作。这是粘贴答案的副本:

这是避免使用use_frameworks的不可支撑的解决方法,它充其量是暂时适合您的,如果您使用存储或功能模块,则无法正常工作,而其他模块将在完全转换为Swift时停止工作。我强烈建议任何人使用它。

正确的解决方案是合并USE_FRAMEWORKS和不支持它或在这些存储库中工作的依赖项,以使其受支持

原始答案:

“ 这也是React本土社区的正式讨论: https://github.com/reaeact-native-community/discussions-and-proposals/discussions/546#discussioncomment-4168642

❗️ React Native developers:

I asked the maintainers of react-native-firebase about the solutions found here and they said the app will eventually break with these workarounds as modules are converted to Swift. FirebaseFunctions-h.swift and FirebaseStorage-h.swift already won't work. Here's the copy pasted answer:

that's an unsupportable workaround to avoid use_frameworks, it is temporarily working for you at best, does not work already if you use storage or functions modules, and other modules will stop working as they fully convert to Swift. I strongly discourage anyone from using that.

The correct solution is to incorporate use_frameworks and drop dependencies that don't support it or work in those repos that you cannot drop such that it is supported

Original answer: https://github.com/invertase/react-native-firebase/issues/6594#issuecomment-1303612795

EDIT: Here's also an official discussion from the React Native community: https://github.com/react-native-community/discussions-and-proposals/discussions/546#discussioncomment-4168642

維他命╮ 2025-02-06 03:29:45

但是

  1. ​-properties
  2. app.config.js add:<<<<<关键步骤
 plugins: [
      "@react-native-firebase/app",
      [
        "expo-build-properties",
        {
          ios: {
            useFrameworks: "static",
          },
        },
      ],
  1. 我的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 File.join(File.dirname(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules")

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

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

target 'ProjectName' do
  use_expo_modules!
  config = use_native_modules!

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

  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true  
  pod 'FirebaseStorageInternal', :modular_headers => true
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseAppCheckInterop', :modular_headers => true
  pod 'FirebaseAuthInterop', :modular_headers => true
  pod 'FirebaseMessagingInterop', :modular_headers => true
  pod 'GTMSessionFetcher', :modular_headers => true
  pod 'FirebaseAppCheckInterop', :modular_headers => true
  pod 'FirebaseAuthInterop', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true

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

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => flags[:hermes_enabled] || podfile_properties['expo.jsEngine'] == 'hermes',
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Dir.pwd}/.."
  )

  # Uncomment to opt-in to using Flipper
  # Note that if you have use_frameworks! enabled, Flipper will not work
  #
  # if !ENV['CI']
  use_flipper!()
  # end

  post_install do |installer|
    react_native_post_install(installer)
    __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
  1. 不要忘记 cd ios&& POD安装
  2. 运行您的构建,例如 EAS构建-Platform iOS- profile Development- -local

rnfirebase版本

    "@react-native-firebase/analytics": "15.4",
    "@react-native-firebase/app": "15.4",
    "@react-native-firebase/auth": "15.4",
    "@react-native-firebase/crashlytics": "15.4",
    "@react-native-firebase/firestore": "15.4",
    "@react-native-firebase/perf": "15.4",

None of the previously suggested solutions worked for me (I also use Expo), however, adding the following snippet to app.config.js solved it for me:

  1. Run npx expo install expo-build-properties
  2. In app.config.js add: <<<< CRITICAL STEP Referenced here
 plugins: [
      "@react-native-firebase/app",
      [
        "expo-build-properties",
        {
          ios: {
            useFrameworks: "static",
          },
        },
      ],
  1. My 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 File.join(File.dirname(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules")

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

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

target 'ProjectName' do
  use_expo_modules!
  config = use_native_modules!

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

  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true  
  pod 'FirebaseStorageInternal', :modular_headers => true
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseAppCheckInterop', :modular_headers => true
  pod 'FirebaseAuthInterop', :modular_headers => true
  pod 'FirebaseMessagingInterop', :modular_headers => true
  pod 'GTMSessionFetcher', :modular_headers => true
  pod 'FirebaseAppCheckInterop', :modular_headers => true
  pod 'FirebaseAuthInterop', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true

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

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => flags[:hermes_enabled] || podfile_properties['expo.jsEngine'] == 'hermes',
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Dir.pwd}/.."
  )

  # Uncomment to opt-in to using Flipper
  # Note that if you have use_frameworks! enabled, Flipper will not work
  #
  # if !ENV['CI']
  use_flipper!()
  # end

  post_install do |installer|
    react_native_post_install(installer)
    __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
  1. Don't forget to cd ios && pod install
  2. Run your build, e.g. eas build --platform ios --profile development --local

RNFirebase versions

    "@react-native-firebase/analytics": "15.4",
    "@react-native-firebase/app": "15.4",
    "@react-native-firebase/auth": "15.4",
    "@react-native-firebase/crashlytics": "15.4",
    "@react-native-firebase/firestore": "15.4",
    "@react-native-firebase/perf": "15.4",
番薯 2025-02-06 03:29:45

关于博览会管理,这是我制作的配置插件,并为我工作

const fs = require('fs');
const path = require('path');
const generateCode = require('@expo/config-plugins/build/utils/generateCode');
const configPlugins = require('@expo/config-plugins');

const code = `  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  $RNFirebaseAsStaticFramework = true`;

const withReactNativeFirebase = (config) => {
  return configPlugins.withDangerousMod(config, [
    'ios',
    async (config) => {
      const filePath = path.join(
        config.modRequest.platformProjectRoot,
        'Podfile'
      );
      const contents = fs.readFileSync(filePath, 'utf-8');

      const addCode = generateCode.mergeContents({
        tag: 'withReactNativeFirebase',
        src: contents,
        newSrc: code,
        anchor: /\s*get_default_flags\(\)/i,
        offset: 2,
        comment: '#',
      });

      if (!addCode.didMerge) {
        console.error(
          "ERROR: Cannot add withReactNativeFirebase to the project's ios/Podfile because it's malformed."
        );
        return config;
      }

      fs.writeFileSync(filePath, addCode.contents);

      return config;
    },
  ]);
};

module.exports = withReactNativeFirebase;

Regarding Expo managed, here's a config plugin that I've made, and works for me

const fs = require('fs');
const path = require('path');
const generateCode = require('@expo/config-plugins/build/utils/generateCode');
const configPlugins = require('@expo/config-plugins');

const code = `  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  $RNFirebaseAsStaticFramework = true`;

const withReactNativeFirebase = (config) => {
  return configPlugins.withDangerousMod(config, [
    'ios',
    async (config) => {
      const filePath = path.join(
        config.modRequest.platformProjectRoot,
        'Podfile'
      );
      const contents = fs.readFileSync(filePath, 'utf-8');

      const addCode = generateCode.mergeContents({
        tag: 'withReactNativeFirebase',
        src: contents,
        newSrc: code,
        anchor: /\s*get_default_flags\(\)/i,
        offset: 2,
        comment: '#',
      });

      if (!addCode.didMerge) {
        console.error(
          "ERROR: Cannot add withReactNativeFirebase to the project's ios/Podfile because it's malformed."
        );
        return config;
      }

      fs.writeFileSync(filePath, addCode.contents);

      return config;
    },
  ]);
};

module.exports = withReactNativeFirebase;
青朷 2025-02-06 03:29:45

最后,经过很多问题,答案是对用户flipper和modular_header的答案,最后我的Pod文件看起来像这样: -

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

target 'MyPregnancy' do
  config = use_native_modules!

  # Flags change depending on the env values.
  flags = get_default_flags()
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
  
  target 'MyPregnancyTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()

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

Finally after going through so many questions the answer was to user Flipper and modular_header in same time, finally my Pod file looks like this :-

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

target 'MyPregnancy' do
  config = use_native_modules!

  # Flags change depending on the env values.
  flags = get_default_flags()
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
  
  target 'MyPregnancyTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()

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

留一抹残留的笑 2025-02-06 03:29:45

我只添加了这2行

  use_frameworks!
  use_modular_headers!

Podfile(ios)

target 'Runner' do
  use_frameworks!
  use_modular_headers!
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

I added only these 2 lines

  use_frameworks!
  use_modular_headers!

Podfile (IOS)

target 'Runner' do
  use_frameworks!
  use_modular_headers!
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
薯片软お妹 2025-02-06 03:29:45

当我尝试将Firebase存储库中的React Native CLI项目实施时,我遇到了同样的问题。我将以下代码添加到podfile

  use_frameworks! :linkage => :static
  $RNFirebaseAsStaticFramework = true
  pod 'GoogleUtilities', :modular_headers => true;
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true

中下面代码之后的podfile

target 'YourApp' do
  config = use_native_modules!

I faced the same issue when I tried implementing the Firebase storage library into my React Native CLI project. I added the following code to the Podfile

  use_frameworks! :linkage => :static
  $RNFirebaseAsStaticFramework = true
  pod 'GoogleUtilities', :modular_headers => true;
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true

Put above code right after the code below in the PodFile

target 'YourApp' do
  config = use_native_modules!
最舍不得你 2025-02-06 03:29:45

添加到POD文件中

use_frameworks! :linkage => :static

target 之前,将其

Add this in the Pod file before the target

use_frameworks! :linkage => :static

This work well for React Native Application

转角预定愛 2025-02-06 03:29:45
  • REACT 18.2.0反应
  • 本地0.72.6
  • @react-native-firebase/app 18.7.1

添加在豆荚文件的目标部分内:

target xxx
   use_frameworks! :linkage => :static
   $RNFirebaseAsStaticFramework = true
   config = use_native_modules!

并禁用flipper

# :flipper_configuration => flipper_config,
  • react 18.2.0
  • react-native 0.72.6
  • @react-native-firebase/app 18.7.1

Add inside your target section of Pods file:

target xxx
   use_frameworks! :linkage => :static
   $RNFirebaseAsStaticFramework = true
   config = use_native_modules!

And disable flipper

# :flipper_configuration => flipper_config,
铁轨上的流浪者 2025-02-06 03:29:45

如果您正在使用Apple Silicon M机器使用React Native版本0.73.2,并且正在尝试安装React Firebase App版本18.8.0或更高版本,则在打算保持 use_flipper Active时,您可能会遇到一些问题。最初,您可能会认为在podfile中包含以下几行,以解决潜在的兼容性或链接问题的库:

pod 'Firebase', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true

但是,此设置可能无法解决问题,尤其是在构建过程中遇到“未找到-lfirebase”错误的“未找到-lfirebase”错误的情况下。

我在Firebase Pod或Xcframeworks的构建路径中没有发现任何firebase静态lib。

以我的经验,仅包括以下豆荚来简化podfile可以解决问题:

pod 'FirebaseCore', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true

此问题的根本原因可能与Firebase Pod从使用静态库向XCFrameworks的过渡有关。

If you're working on an Apple Silicon M machine with React Native version 0.73.2 and are trying to install React Native Firebase App version 18.8.0 or above while intending to keep use_flipper active, you might encounter some issues. Initially, you might think to include the following lines in your Podfile to address potential compatibility or library linking problems:

pod 'Firebase', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true

However, this setup might not resolve the issue, particularly if you encounter a "library not found for -lFirebase" error during the build process.

I didn't find any Firebase static lib in the build path for the Firebase pod, or xcFrameworks either.

In my experience, simplifying the Podfile by only including the following pods can solve the problem:

pod 'FirebaseCore', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true

The underlying cause of this issue might be related to the transition of the Firebase pod from using static libraries to XCFrameworks.

季末如歌 2025-02-06 03:29:45

对于 React Native Expo :在SDK50

npx expo install expo-build-properties

和App.json上进行测试,更新 expo.plugins as

{
  "expo": {
    "plugins": [
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ]
    ]
  }
}

For REACT NATIVE EXPO: Tested on SDK50

npx expo install expo-build-properties

and in app.json, update expo.plugins as

{
  "expo": {
    "plugins": [
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ]
    ]
  }
}
彩虹直至黑白 2025-02-06 03:29:45

添加到Podfile并更新POD

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

Add to Podfile and update pod

  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers =>
true
  $RNFirebaseAsStaticFramework = true
栩栩如生 2025-02-06 03:29:45

我面对的firebase版本(^18.7.3)。在您的情况下,它可以是其他的。
我在全球上添加了这条代码行,正是错误的:

use_modular_headers!

在Podfile顶部的这两条线下方

platform :ios, min_ios_version_supported
prepare_react_native_project!

,POD安装对我来说是成功的。错误在下面

。 alt =“错误是这样的样子的某些情况”>

The similer issue I faced with firebase version (^18.7.3). it can be any other in your case.
I added this line of code globally as it is mentioned in error:

use_modular_headers!

below these two lines at the top of podfile

platform :ios, min_ios_version_supported
prepare_react_native_project!

and the pod installation succeed for me. The error is below

.the error was some how like this as occured in this image

日记撕了你也走了 2025-02-06 03:29:45

对我来说,问题仅仅是因为Podfile的版本与新版本的Firebase模块不兼容。

我正在研究 React Native ,因此生成的Podfile版本不是最新的。因此,我的火箱模块在podfile中需要其他东西。

这是一个易于修复的修复程序,可以添加podfile

use_modular_headers!

但是,您还可以关注包装的历史。
我对6月发布的本地0.69做出了反应。当时我刚刚检查了Firebase打包版本,并且已经安装了这些版本。
这也有效。

For me the issue was simply because the version of the Podfile was not compatible with the new version of Firebase modules.

I am working on React Native, so the version of Podfile generated was not the latest one. Due to this my Firebase modules required something else in the Podfile.

It was an easy fix to add in the Podfile:

use_modular_headers!

However, you can also keep an eye on the history of your packages.
I had React Native 0.69 that was released in June. I just checked the Firebase packaged version at that time and I have installed those ones.
This works as well.

烟沫凡尘 2025-02-06 03:29:45

对于本机应用程序项目,这是 firebase apple sdk apple sdk sdk版本(版本9.0。 0)

Cocoapods用户

打破变化:podfiles必须包括 use_frameworks! use_frameworks! :linkage =&gt; :static

只需在您的Podfile中添加任何一行即可。文档中解释了差异: link firebase依赖性在统计上或动态上均为。

For native app projects, here's the Firebase Apple SDK Release Notes (Version 9.0.0):

CocoaPods Users

Breaking change: Podfiles must include use_frameworks! or use_frameworks! :linkage => :static.

Just add either line in your Podfile. The difference is explained in the document: Link Firebase dependencies statically or dynamically.

怂人 2025-02-06 03:29:45
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

target 'SeRemo' do
  config = use_native_modules!
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  $RNFirebaseAsStaticFramework = true
  # Flags change depending on the env values.
  flags = get_default_flags()

  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,
    :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 'SeRemoTests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enable`enter code here`d => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end
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

target 'SeRemo' do
  config = use_native_modules!
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  $RNFirebaseAsStaticFramework = true
  # Flags change depending on the env values.
  flags = get_default_flags()

  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,
    :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 'SeRemoTests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enable`enter code here`d => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end
初雪 2025-02-06 03:29:45

将其放在Podfile&amp;运行POD安装

pod 'FirebaseCoreInternal', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true

Solved after put this to Podfile & run pod install

pod 'FirebaseCoreInternal', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
空‖城人不在 2025-02-06 03:29:45

对于在2024年面临同一问题的任何人,我建议您只使用博览会构建;特别是如果您仍在研究该项目,并且可能以后添加其他软件包。

两个步骤:

1. npx expo install expo-build-properties
  1. 然后在您的app.json文件中添加以下内容:

“插件”:[
“博览会”,
“博览会”,
[
“博览会 - 企业”,
{
“ ios”:{
“ useframeworks”:“静态”,
“ podfileproperties”:{
“ use_modular_headers!”:true
}
}
}
这是给出的
]

您可以运行NPX Expo Prebuild -CLEAN或NPX EXPO PREBUILD

For anyone facing this same issue in 2024, I Will recommend you just use expo-build-properties; especially if you are still working on the project and might add other packages later.

Two steps:

1. npx expo install expo-build-properties
  1. then add the following in your app.json file:

"plugins": [
"expo-font",
"expo-router",
[
"expo-build-properties",
{
"ios": {
"useFrameworks": "static",
"podfileProperties": {
"use_modular_headers!": true
}
}
}
]
]

And you can run npx expo prebuild --clean or npx expo prebuild

梦晓ヶ微光ヅ倾城 2025-02-06 03:29:45

只要使用最新的软件包,您可能会急切地试图解决此问题,您可能最终会处理“仅在iOS 15中支持并发”。那看起来是一个死胡同。降级包装并等待React Native +70.0可能符合您的最大利益。

Just a heads up for those desperately trying to fix this, using the newest packages, you may end up dealing with the warning "concurrency is only supported in IOS 15". That looks to be a dead end. It may be in your best interest to downgrade the package and wait for react native +70.0.

揽月 2025-02-06 03:29:45

我关注 kvba 的config插件。
我正在强迫FirebasesDkversion到10.1.0:

const fs = require('fs')
const path = require('path')
const generateCode = require('@expo/config-plugins/build/utils/generateCode')
const configPlugins = require('@expo/config-plugins')

const code = `  $RNFirebaseAsStaticFramework = true

  # Override Firebase SDK Version
  $FirebaseSDKVersion = '10.1.0'`

const withReactNativeFirebase = config => {
  return configPlugins.withDangerousMod(config, [
    'ios',
    async config => {
      const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile')
      const contents = fs.readFileSync(filePath, 'utf-8')

      const addCode = generateCode.mergeContents({
        tag: 'withReactNativeFirebase',
        src: contents,
        newSrc: code,
        anchor: /\s*get_default_flags\(\)/i,
        offset: 2,
        comment: '#',
      })

      if (!addCode.didMerge) {
        console.error(
          "ERROR: Cannot add withReactNativeFirebase to the project's ios/Podfile because it's malformed.",
        )
        return config
      }

      fs.writeFileSync(filePath, addCode.contents)

      return config
    },
  ])
}

module.exports = withReactNativeFirebase

I followed kvba 's config plugin.
I'm forcing the FirebaseSDKVersion to 10.1.0:

const fs = require('fs')
const path = require('path')
const generateCode = require('@expo/config-plugins/build/utils/generateCode')
const configPlugins = require('@expo/config-plugins')

const code = `  $RNFirebaseAsStaticFramework = true

  # Override Firebase SDK Version
  $FirebaseSDKVersion = '10.1.0'`

const withReactNativeFirebase = config => {
  return configPlugins.withDangerousMod(config, [
    'ios',
    async config => {
      const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile')
      const contents = fs.readFileSync(filePath, 'utf-8')

      const addCode = generateCode.mergeContents({
        tag: 'withReactNativeFirebase',
        src: contents,
        newSrc: code,
        anchor: /\s*get_default_flags\(\)/i,
        offset: 2,
        comment: '#',
      })

      if (!addCode.didMerge) {
        console.error(
          "ERROR: Cannot add withReactNativeFirebase to the project's ios/Podfile because it's malformed.",
        )
        return config
      }

      fs.writeFileSync(filePath, addCode.contents)

      return config
    },
  ])
}

module.exports = withReactNativeFirebase

献世佛 2025-02-06 03:29:45

当我在使用Firebase Analytics时尝试使用Google Tag Manager时,我遇到了同样的问题。

  firebase_core: ^2.24.2
  firebase_analytics: ^10.7.4

对我有用的解决方案是在>“ googletagmanager” 中添加 target'runner'do 不在外面。

像这样:

target 'Runner' do
  pod 'GoogleTagManager'
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

I faced the same issue when i try to use Google Tag Manager while I was using Firebase Analytics.

  firebase_core: ^2.24.2
  firebase_analytics: ^10.7.4

the solution that worked for me is to add the pod 'GoogleTagManager' inside the target 'Runner' do NOT out side it.

like this:

target 'Runner' do
  pod 'GoogleTagManager'
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
黯然 2025-02-06 03:29:45

我使用文档中知道的步骤解决了这个问题。在步骤中:更改 cocoapods 首先使用框架

,添加 podfile

use_frameworks! :linkage => :static
$RNFirebaseAsStaticFramework = true

运行命令:

pod install --repo-update
npx expo run:ios

我的项目使用:使用:

"expo": "~49.0.18",
"react-native": "0.72.6",

I resolved this problem using the steps informed in docs https://rnfirebase.io/. in step: Altering CocoaPods to use frameworks

first, add in Podfile

use_frameworks! :linkage => :static
$RNFirebaseAsStaticFramework = true

after running the commands:

pod install --repo-update
npx expo run:ios

My project using:

"expo": "~49.0.18",
"react-native": "0.72.6",
栩栩如生 2025-02-06 03:29:45

您应该切换到使用React Native Firebase,因为Expo-Firebase-Analytics目前在Android和iOS上都面临许多问题。即使您设法解决了iOS上的所有错误,Expo-Firebase-Analytics仍然无法在Gradle 8(Android)上运行。

这是迁移从博览会 - 循环分析的指南,以反应本地燃料。我已经应用和测试了它,现在一切都可以在两个平台上完美运行。

从Expo Firebase(Expo-Firebase-Analytics)迁移以反应本地燃料

然后阅读此文档,以获取有关本机firebase的更多详细信息:
https://rnfirebase.io/#expo

[firebase]自动收集的事件

you should switch to using React Native Firebase because expo-firebase-analytics is currently facing numerous issues on both Android and iOS.
Even if you manage to resolve all the errors on iOS, expo-firebase-analytics still cannot run on Gradle 8 (Android).

Here is a guide to migrating from expo-firebase-analytics to React Native Firebase.
I have applied and tested it, and everything is now working perfectly on both platforms.

Migrating from Expo Firebase (expo-firebase-analytics) to React Native Firebase
https://github.com/expo/fyi/blob/main/firebase-migration-guide.md

Then read this document for more details about React Native Firebase:
https://rnfirebase.io/#expo

[Firebase] Automatically collected events
https://support.google.com/analytics/answer/9234069?hl=en&ref_topic=13367566&sjid=3847978116116908888-AP

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文