【问题标题】:Why is React(missing) in xcode scheme build targets list?为什么 xcode 方案构建目标列表中的 React(missing)?
【发布时间】:2020-03-05 01:42:13
【问题描述】:

我正在尝试使用 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)

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

Screenshot of build targets list

如果我单击“+”按钮,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

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

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

Also in the Pods/Products file libReact.a does not have an icon like the other .a files do

谁能告诉我为什么会这样和/或如何解决/解决它?

【问题讨论】:

  • 如果你使用的是最新的 React Native,Podfile 不应该是这样的。见update helper
  • 我使用的是 0.59.10。是否无法在使用此版本的设备上运行项目,还是需要更新和更改所有文件?
  • 我的产品 -> 编辑方案显示为 React Missing。有什么解决办法吗?
  • 我认为这个问题确实与使用 Expo 有关,因为 Expo 似乎没有使用最新版本的 react native(感谢@Ziyo)。从长远来看,它还需要更多的摆弄,并且缺少一些本机功能,所以在未来,除非我正在构建的东西是好的和轻量级的,否则我将避免使用 Expo。我最终用 react native cli 创建了一个新项目,一切都像发条一样运行。对于那些想尝试我的解决方案、重新启动 sans Expo 的人,请在 [facebook.github.io/react-native/docs/getting-started] 上选择 React Native Cli Quickstart
  • @Bend'Straw 你解决了这个问题吗?有更新吗?

标签: ios xcode react-native dependency-injection podfile


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-01
    • 1970-01-01
    • 2014-01-05
    • 1970-01-01
    • 1970-01-01
    • 2014-03-17
    • 1970-01-01
    相关资源
    最近更新 更多