【问题标题】:Problems bundling React Native iOS app using CocoaPods使用 CocoaPods 捆绑 React Native iOS 应用程序的问题
【发布时间】:2019-08-02 08:35:45
【问题描述】:

我正在使用 https://github.com/invertase/react-native-firebase 构建一个应用程序,它建议最好的安装方式是通过 CocoaPods,但是,当我尝试归档我的应用程序时,我遇到了 10000 个问题。

我想知道使用 React Native 和 Cocoapods 时的最佳做法是什么,以及如何导入/加载内容,以及是否是 CocoaPods 实际影响了我的应用程序。

我最终完成了这一步,它在模拟器中运行,但是我不确定我是否需要对不同 pod 的所有引用,即使我可能通过npm install 安装它们。

任何提示都将不胜感激,因为我想完全放弃 CocoaPods 并尝试从头开始安装。

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'myApp' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for myApp
  pod 'Firebase/Core'
  pod 'Firebase/Auth'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  # Add yoga.
  # https://github.com/facebook/react-native/issues/13046#issuecomment-350523190
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  # Set React to be from node_modules.
  pod 'React', :path => '../node_modules/react-native'
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'DevSupport',
    'CxxBridge',
    'RCTNetwork',
  ]

  target 'myApp-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
    # pod 'react-native-video', :path => '../node_modules/react-native-video'

    pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

    pod 'SentryReactNative', :path => '../node_modules/react-native-sentry'

    pod 'react-native-in-app-utils', :path => '../node_modules/react-native-in-app-utils'

    pod 'react-native-camera', :path => '../node_modules/react-native-camera'

    pod 'RNIap', :path => '../node_modules/react-native-iap'

    # pod 'RNShare', :path => '../node_modules/react-native-share'

    pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob'

  end

  target 'myApp' do
    inherit! :search_paths
    # Pods for testing
  end

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == "React"
        target.remove_from_project
      end
    end
  end

end

【问题讨论】:

  • 文档本身不建议将 Cocoapod 用于 React Native Firebase。太好了,你从那个切换了。请特别发布您面临的任何问题。
  • @Vishu RNFirebase 声明 Firebase 建议使用 CocoaPods 安装 Firebase。 rnfirebase.io/docs/v5.x.x/installation/…
  • 非常真实的@Karl,但同时它不推荐将CocoaPods 用于RNFirebase。
  • @Vishu 我不明白你在说什么。文档在第 1.3 节 rnfirebase.io/docs/v5.x.x/installation/… 中明确建议使用选项 1:Cocoapods(推荐)。请不要发布不正确和无用的信息。
  • 如果你低头看 '2. React Native Firebase Installation Recommended installation' 部分,它显然不建议将 CocoaPods 用于 RNFirebase。

标签: javascript node.js express google-cloud-platform


【解决方案1】:

答案是响亮的是的。 CocoaPods确实会导致 React Native 应用出现问题。

在注释掉大部分其他 Pod 之后。我的应用程序构建良好第一次尝试并上传到应用商店。

我的建议。如果不需要,不要向 CocoaPods 添加东西。

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'myApp' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for myApp
  pod 'Firebase/Core'
  pod 'Firebase/Auth'

  # pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  # pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  # pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  # Add yoga.
  # https://github.com/facebook/react-native/issues/13046#issuecomment-350523190
  # pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  # # Set React to be from node_modules.
  # pod 'React', :path => '../node_modules/react-native', :subspecs => [
  #   'Core',
  #   'DevSupport',
  #   'CxxBridge',
  #   'RCTNetwork',
  # ]

  target 'myApp-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
    # pod 'react-native-video', :path => '../node_modules/react-native-video'

    # pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

    # pod 'SentryReactNative', :path => '../node_modules/react-native-sentry'

    # pod 'react-native-in-app-utils', :path => '../node_modules/react-native-in-app-utils'

    # pod 'react-native-camera', :path => '../node_modules/react-native-camera'

    # pod 'RNIap', :path => '../node_modules/react-native-iap'

    # pod 'RNShare', :path => '../node_modules/react-native-share'

    # pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob'

  end

  target 'myApp' do
    inherit! :search_paths
    # Pods for testing
  end

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == "React"
        target.remove_from_project
      end
    end
  end

end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-16
    • 2016-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-14
    • 1970-01-01
    相关资源
    最近更新 更多