【问题标题】:react-native run-ios only works the first time after pods are installedreact-native run-ios 仅在安装 pod 后第一次工作
【发布时间】:2021-05-13 13:38:27
【问题描述】:

每次我想在 iphone 模拟器上启动我的应用程序时,我都必须遵循本指南:https://stackoverflow.com/a/55776414/4662347

我以前没有任何问题,但是自从我开始使用 pod 后,这个问题就出现了。

当我第一次运行react-native run-ios 时,它可以工作。但是当我第二次尝试运行它时,它会像这样失败:

错误无法构建 iOS 项目。我们运行了“xcodebuild”命令,但它以错误代码 65 退出。要进一步调试构建日志,请考虑通过打开 KoirapuistoApp.xcworkspace 来使用 Xcode.app 构建您的应用程序

如果我从 xcode 运行它,它会像这样失败:

ld: 找不到用于 -lDoubleConversion 的库...

但是在 xcode 中,如果我以 myApp.xcworkspace 的形式打开我的应用程序,那么构建将成功。问题是我不能通过 xcode 开发,我需要 react-native run-ios 命令才能工作。

我的 Pods 文件如下所示:

project 'MyApp.xcodeproj'

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

# Allowed sources
source 'https://github.com/CocoaPods/Specs.git'

target 'myapp' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for myapp

  # Point to the installed version
  pod 'RNDateTimePicker', :path => '../node_modules/@react-native-community/datetimepicker/RNDateTimePicker.podspec'

  # React/React-Native specific pods
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge',      # Include this for RN >= 0.47
    'DevSupport',     # Include this to enable In-App Devmenu if RN >= 0.43
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket',   # Needed for debugging
  ]

  # Explicitly include Yoga if you are using RN >= 0.42.0
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  # Third party deps podspec link
  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'

  target 'myapp-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

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

end

问题是,当我每次发出基本的 dev 命令时,如何让应用程序正常工作?:

react-native run-ios

我的 react-native 版本:0.59.10

【问题讨论】:

    标签: ios xcode react-native cocoapods


    【解决方案1】:

    能够通过将 xcode 中的构建模式设置为旧模式来解决此问题:

    文件 -> 工作区设置 -> 构建系统 -> 旧版构建系统。

    在此之后,我不再需要在每次运行后删除构建文件夹:react-native run-ios

    但由于苹果很快会移除遗留的构建系统,我认为这不是一个好的长期解决方案。如果有人想出一个合适的解决方案,我可能会接受它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-14
      • 2020-12-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多