React Native项目的链接阶段出现问题。库libRCTMapboxGL.a
导致了此问题。
错误:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool:找不到以下文件:-lPods RCTMapboxGL
错误:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool:file:-lPods RCTMapboxGL不是对象文件(库中不允许)
由于-lPods-RCTMapboxGL
出现错误,文件libRCTMapboxGL.a
未在/Users/user/Developer/RNProject/ios/build/Build/Products/Debug-iphonesimulator/
中创建。然而,这些文件似乎存在:
/Users/user/Developer/RNProject/nod_modules/areact native mapbox gl/ios/Pods/Target Support Files/Pods RCTMapboxGL/Pods-RCTMapbox gl.debug.xconfig
/Users/user/Developer/RNProject/nod_modules/areact native mapbox gl/ios/Pods/Target Support Files/Pods RCTMapboxGL/Pods-RCTMapbox gl.release.xcconfig
Pods RCTMapboxGL不是对象文件在错误消息中看起来很奇怪,文件的内容是:
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public"
OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public"
OTHER_LDFLAGS = $(inherited) -ObjC
PODS_BUILD_DIR = $BUILD_DIR
PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}/Pods
设置是根据本教程完成的。首先使用CocoaPods,然后手动验证是否所有设置和文件都已到位。
完整错误日志:
Libtool /Users/user/Developer/RNProject/ios/build/Build/Products/Debug-iphonesimulator/libRCTMapboxGL.a normal x86_64
cd /Users/user/Developer/RNProject/node_modules/react-native-mapbox-gl/ios
export IPHONEOS_DEPLOYMENT_TARGET=8.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only x86_64 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk -L/Users/user/Developer/RNProject/ios/build/Build/Products/Debug-iphonesimulator -L/Users/bobby/Downloads/mapbox-gl-ios-0.2.17 -L/Users/user/Developer/RNProject/node_modules/react-native-mapbox-gl/ios/RCTMapboxGL -filelist /Users/user/Developer/RNProject/ios/build/Build/Intermediates/RCTMapboxGL.build/Debug-iphonesimulator/RCTMapboxGL.build/Objects-normal/x86_64/RCTMapboxGL.LinkFileList -lPods-RCTMapboxGL -o /Users/user/Developer/RNProject/ios/build/Build/Products/Debug-iphonesimulator/libRCTMapboxGL.a
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lPods-RCTMapboxGL
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lPods-RCTMapboxGL is not an object file (not allowed in a library)
问题是我在MapboxGL目录中使用了pod init
,它创建了额外的文件。删除生成的文件解决了问题。