我正在尝试在设备上运行我的第一个React-Native应用程序,但是构建始终失败,并出现以下错误:
ld: warning: directory not found for option '-L/Users/XXXX/library/Developer/Xcode/DerivedData/nigh-hktjvygosupgnoaafsvgyowhzsqi/Build/Products/Debug-iphoneos/React'
ld: warning: directory not found for option '-L/Users/XXXX/library/Developer/Xcode/DerivedData/nigh-hktjvygosupgnoaafsvgyowhzsqi/Build/Products/Debug-iphoneos/React'
ld: warning: directory not found for option '-L/Users/XXXX/library/Developer/Xcode/DerivedData/nigh-hktjvygosupgnoaafsvgyowhzsqi/Build/Products/Debug-iphoneos/React'
ld: warning: ignoring file /Users/XXXX/Nigh/ReactNativeNigh/Nigh/ios/build/nigh/Build/Products/Debug-iphonesimulator/React/libReact.a,file was built for archive which is not the architecture being linked (arm64): /Users/XXXX/Nigh/ReactNativeNigh/Nigh/ios/build/nigh/Build/Products/Debug-iphonesimulator/React/libReact.a
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_rctbridge",referenced from:
objc-class-ref in AppDelegate.o
"_OBJC_CLASS_$_RCTBundleURLProvider",referenced from:
objc-class-ref in AppDelegate.o
"_OBJC_CLASS_$_RCTConvert",referenced from:
objc-class-ref in libRNGestureHandler.a(RNflingHandler.o)
objc-class-ref in libRNGestureHandler.a(RNForceTouchHandler.o)
objc-class-ref in libRNGestureHandler.a(RNLongPressHandler.o)
objc-class-ref in libRNGestureHandler.a(RNNativeViewHandler.o)
objc-class-ref in libRNGestureHandler.a(RNPanHandler.o)
objc-class-ref in libRNGestureHandler.a(RNGestureHandlerModule.o)
objc-class-ref in libRNGestureHandler.a(RNGestureHandler.o)
...
React directory not found error
前面几件事:
该项目在XCode模拟器上运行良好。
我正在使用cocoapods,并尝试从xcWorkspace而不是项目运行构建(尽管目标的完整路径是/Users/XXXX/Nigh/ReactNativeNigh/Nigh/ios/nigh.xcodeproj,这让我有些困惑)。
我已经删除并重新安装了节点模块,进行了链接并完成了新的pod安装。
看来我要做的就是将React添加到Debug-iphoneos文件夹中,但是我不确定该怎么做,或者这是否是解决方案。我的第一个尝试是确保React处于Scheme的构建目标中。它是列表中第一个选中所有框的项目,但出于某种原因它表示React(missing)。对于React Native / Xcode Upgrade and now RCTConvert.h not found,我从“目标”列表中删除了React(missing)并尝试再次添加React,但是React甚至没有出现在列表中。另外,pods / Products文件夹显示的libReact.a与其他.a文件不同,没有Archive(?)图标:
这是podfile:
require_relative '../node_modules/react-native-unimodules/cocoapods'
target 'nigh' do
# pods for nigh
use_frameworks!
# pod 'AWSCore','~> 2.12.0'
pod 'AWSCore','~> 2.10.2'
pod 'AWSAppSync','~> 2.14.2'
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”块,但是无论哪种方式都显示错误。
我正确地假设问题是React不在方案的构建目标中,如果是这样的话,有人知道如何将其包括在内吗?如果不是,是否有人知道真正的原因可能是/如何解决/解决它?