让CocoaPods使用React Native的问题

时间:2016-11-06 18:06:12

标签: ios react-native cocoapods

描述

我安装了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)

生殖

管理用新项目重现它:

  1. react-native init
  2. react-native run-ios(正常运行)
  3. pod init && pod install(未添加依赖项)
  4. 从XCode(或react-native run-ios
  5. 构建

    这是一个示例项目(只需运行npm installreact-native run-ios来重现此示例项目) CocoaPodsFailure.zip

    其他信息

    • React Native version:0.36.1
    • 平台:iOS
    • 操作系统:MacOS

1 个答案:

答案 0 :(得分:0)

有同样的问题。在我登陆建议添加该行的帖子之前尝试了各种各样的事情:

use_frameworks

到你的PodFile。它让我可以解决链接错误。