react-native 运行-ios 仅在安装 pods 后第一次工作

react-native run-ios only works the first time after pods are installed

每次我想在 iphone 模拟器上启动我的应用程序时,我都必须遵循此指南:

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

我第一次 运行 react-native run-ios 它起作用了。但是当我第二次尝试 运行ning 时,它像这样失败了:

error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening KoirapuistoApp.xcworkspace

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

ld: library not found for -lDoubleConversion...

但是在 xcode 中,如果我以 myApp.xcworkspace 打开我的应用程序,那么构建将会成功。问题是我无法通过 xcode 进行开发,我需要 react-native 运行-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

问题是,每次发出基本开发命令时,如何让应用程序正常运行?:

react-native run-ios

我的 react-native 版本:0.59.10

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

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

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

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