让 CocoaPods 与 React Native 一起工作的问题
Posted
技术标签:
【中文标题】让 CocoaPods 与 React Native 一起工作的问题【英文标题】:Problems getting CocoaPods working with React Native 【发布时间】:2016-11-06 18:06:11 【问题描述】:说明
我安装了 CocoaPods 并在 Xcode 中打开了 xcworkspace,但在尝试构建时出现此错误:
Ld /Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Products/Debug-iphonesimulator/CocoaPodsFailure.app/PlugIns/CocoaPodsFailureTests.xctest/CocoaPodsFailureTests normal x86_64
cd /Users/Robert/Code/_Playing/react-native-cocoapods/CocoaPodsFailure/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/clang -arch x86_64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk -L/Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Products/Debug-iphonesimulator -F/Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -filelist /Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Intermediates/CocoaPodsFailure.build/Debug-iphonesimulator/CocoaPodsFailureTests.build/Objects-normal/x86_64/CocoaPodsFailureTests.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -mios-simulator-version-min=8.0 -bundle_loader /Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Products/Debug-iphonesimulator/CocoaPodsFailure.app/CocoaPodsFailure -Xlinker -object_path_lto -Xlinker /Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Intermediates/CocoaPodsFailure.build/Debug-iphonesimulator/CocoaPodsFailureTests.build/Objects-normal/x86_64/CocoaPodsFailureTests_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -ObjC -framework XCTest /Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Products/Debug-iphonesimulator/libReact.a -lPods-CocoaPodsFailureTests -Xlinker -dependency_info -Xlinker /Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Intermediates/CocoaPodsFailure.build/Debug-iphonesimulator/CocoaPodsFailureTests.build/Objects-normal/x86_64/CocoaPodsFailureTests_dependency_info.dat -o /Users/Robert/Library/Developer/Xcode/DerivedData/CocoaPodsFailure-eqajgeoxnquybpakipqqptcwudjt/Build/Products/Debug-iphonesimulator/CocoaPodsFailure.app/PlugIns/CocoaPodsFailureTests.xctest/CocoaPodsFailureTests
Undefined symbols for architecture x86_64:
"std::__1::__next_prime(unsigned long)", referenced from:
std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::rehash(unsigned long) in libReact.a(RCTJSCExecutor.o)
"std::__1::mutex::lock()", referenced from:
-[RCTModuleData setUpInstanceAndBridge] in libReact.a(RCTModuleData.o)
cachedSystemFont(double, double) in libReact.a(RCTFont.o)
"std::__1::mutex::unlock()", referenced from:
-[RCTModuleData setUpInstanceAndBridge] in libReact.a(RCTModuleData.o)
cachedSystemFont(double, double) in libReact.a(RCTFont.o)
"std::__1::mutex::~mutex()", referenced from:
-[RCTModuleData .cxx_destruct] in libReact.a(RCTModuleData.o)
cachedSystemFont(double, double) in libReact.a(RCTFont.o)
"std::terminate()", referenced from:
___clang_call_terminate in libReact.a(RCTJSCExecutor.o)
"operator delete[](void*)", referenced from:
-[RCTJSCExecutor dealloc] in libReact.a(RCTJSCExecutor.o)
executeRandomAccessModule(RCTJSCExecutor*, unsigned int, unsigned long, unsigned long) in libReact.a(RCTJSCExecutor.o)
readRAMBundle(std::__1::unique_ptr<__sFILE, int (*)(__sFILE*)>, RandomAccessBundleData&) in libReact.a(RCTJSCExecutor.o)
RandomAccessBundleData::~RandomAccessBundleData() in libReact.a(RCTJSCExecutor.o)
"operator delete(void*)", referenced from:
std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::~__hash_table() in libReact.a(RCTJSCExecutor.o)
std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::__deallocate(std::__1::__hash_node<std::__1::__hash_value_type<unsigned long, unsigned long>, void*>*) in libReact.a(RCTJSCExecutor.o)
____ZL37installBasicSynchronousHooksOnContextP9JSContext_block_invoke_6 in libReact.a(RCTJSCExecutor.o)
std::__1::unique_ptr<std::__1::__hash_node<std::__1::__hash_value_type<unsigned long, unsigned long>, void*>, std::__1::__hash_node_destructor<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned long, unsigned long>, void*> > > > std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::__construct_node_hash<std::__1::pair<unsigned long const, unsigned long> const&>(unsigned long, std::__1::pair<unsigned long const, unsigned long> const&&&) in libReact.a(RCTJSCExecutor.o)
std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::__rehash(unsigned long) in libReact.a(RCTJSCExecutor.o)
std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::erase(std::__1::__hash_const_iterator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned long, unsigned long>, void*>*>) in libReact.a(RCTJSCExecutor.o)
"operator new[](unsigned long)", referenced from:
executeRandomAccessModule(RCTJSCExecutor*, unsigned int, unsigned long, unsigned long) in libReact.a(RCTJSCExecutor.o)
readRAMBundle(std::__1::unique_ptr<__sFILE, int (*)(__sFILE*)>, RandomAccessBundleData&) in libReact.a(RCTJSCExecutor.o)
"operator new(unsigned long)", referenced from:
std::__1::unique_ptr<std::__1::__hash_node<std::__1::__hash_value_type<unsigned long, unsigned long>, void*>, std::__1::__hash_node_destructor<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned long, unsigned long>, void*> > > > std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::__construct_node_hash<std::__1::pair<unsigned long const, unsigned long> const&>(unsigned long, std::__1::pair<unsigned long const, unsigned long> const&&&) in libReact.a(RCTJSCExecutor.o)
std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, unsigned long>, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, unsigned long> > >::__rehash(unsigned long) in libReact.a(RCTJSCExecutor.o)
"___cxa_begin_catch", referenced from:
___clang_call_terminate in libReact.a(RCTJSCExecutor.o)
"___cxa_guard_acquire", referenced from:
cachedSystemFont(double, double) in libReact.a(RCTFont.o)
"___cxa_guard_release", referenced from:
cachedSystemFont(double, double) in libReact.a(RCTFont.o)
"___gxx_personality_v0", referenced from:
-[RCTjavascriptContext initWithJSContext:onThread:] in libReact.a(RCTJSCExecutor.o)
-[RCTJavaScriptContext init] in libReact.a(RCTJSCExecutor.o)
-[RCTJavaScriptContext invalidate] in libReact.a(RCTJSCExecutor.o)
+[RCTJSCExecutor runRunLoopThread] in libReact.a(RCTJSCExecutor.o)
-[RCTJSCExecutor setBridge:] in libReact.a(RCTJSCExecutor.o)
-[RCTJSCExecutor init] in libReact.a(RCTJSCExecutor.o)
-[RCTJSCExecutor initWithUseCustomJSCLibrary:] in libReact.a(RCTJSCExecutor.o)
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
复制
设法用一个新项目重现它:
react-native init
react-native run-ios
(运行正常)
pod init && pod install
(未添加依赖项)
从 XCode(或 react-native run-ios
)构建
这是一个示例项目(只需运行 npm install
和 react-native run-ios
即可使用此示例项目重现)
CocoaPodsFailure.zip
附加信息
React Native 版本:0.36.1 平台:iOS 操作系统:MacOS【问题讨论】:
您使用的是哪个版本的 xcode?这可能是个问题。 【参考方案1】:遇到了同样的问题。在我找到建议添加该行的帖子之前尝试了各种方法:
使用框架
到您的 PodFile。它使我能够克服链接错误。
【讨论】:
以上是关于让 CocoaPods 与 React Native 一起工作的问题的主要内容,如果未能解决你的问题,请参考以下文章
CocoaPods 找不到 pod "React/Core" 的兼容版本
Cocoapods 总是安装旧的 React (0.11.0)