为什么在 xcode 方案构建目标列表中出现 React(missing)?

Ben*_*raw 9 xcode dependency-injection ios react-native podfile

我正在尝试使用 xcode 在 ios 设备上运行我的第一个 React-Native 应用程序并不断收到此错误:

ld: warning: directory not found for option '-L/Users/XXXX/Library/Developer/Xcode/DerivedData/nigh-hktjvygosupgnoaafsvgyowhzsqi/Build/Products/Debug-iphoneos/React'

ld: library not found for -lReact
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

我假设原因与我的 Scheme 的构建目标列表中缺少 React 的事实有关。React 是列表中的第一个,所有复选框都被选中,但它显示的是 React(missing) 而不是 React:

构建目标列表的屏幕截图

如果我点击“+”按钮,React 不是一个选项。这是我的 podfile:

platform :ios, '10.0'

require_relative '../node_modules/react-native-unimodules/cocoapods'

target 'nigh' do
  # Pods for nigh
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTBlob',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
  ]

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

  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'
  pod 'RNGestureHandler', :podspec => '../node_modules/react-native-gesture-handler/RNGestureHandler.podspec'
  pod 'RNReanimated', :podspec => '../node_modules/react-native-reanimated/RNReanimated.podspec'
  pod 'react-native-google-maps', path: '../node_modules/react-native-maps'  # Uncomment this line if you want to support GoogleMaps on iOS
  pod 'GoogleMaps'  # Uncomment this line if you want to support GoogleMaps on iOS
  pod 'Google-Maps-iOS-Utils' # Uncomment this line if you want to support GoogleMaps on iOS

  use_unimodules!


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

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

  pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'

  pod 'react-native-slider', :path => '../node_modules/@react-native-community/slider'

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

  pod 'react-native-cameraroll', :path => '../node_modules/@react-native-community/cameraroll'

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

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

end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-google-maps'
      target.build_configurations.each do |config|
        config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
      end
    end
    if target.name == "React"
      target.remove_from_project
    end
  end
end

Run Code Online (Sandbox Code Playgroud)

我尝试删除 if target.name == "React" 块,但仍然出现相同的错误。我还从 .xcworkspace 而不是 .xcodeproject 打开 xcode,因为我使用的是 cocoapods。我尝试从 DerivedData 文件夹中删除所有内容并清理构建,还尝试使用旧构建系统进行构建。Legacy Build 系统在几乎所有读取“缺少依赖目标‘React’”的库上都会显示警告。

我需要将我的包名称从 org.reactjs.native.example.nigh 更改为 org.reactjs.native.name.nigh,这有什么责任吗?我知道在某些时候 React 并没有出现在目标列表中。尽管 React 缺少该应用程序,但它仍然可以在 xcode iphone 模拟器上正常运行。

同样在 Pods/Products 文件中,libReact.a 没有像其他 .a 文件那样的图标

谁能告诉我为什么会发生这种情况和/或如何解决/解决它?

小智 -4

我通过系统偏好设置 -> 安全和隐私解决了这个问题。在隐私选项卡下,我允许 Xcode 访问我的文件和文件夹。

实际发生的事情是我将操作系统升级到 Catalina。不知何故,Xcode 未授予对文件和文件夹的访问权限,因此 xcode 无法读取该文件,因此您会遇到此问题。

安全和隐私设置窗格