Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems getting CocoaPods working with React Native

Description

I installed CocoaPods and opened the xcworkspace in Xcode but I get this error when trying to build:

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)

Reproduction

Managed to reproduce it with a fresh project:

  1. react-native init
  2. react-native run-ios (running ok)
  3. pod init && pod install (no dependencies added)
  4. Build from XCode (or react-native run-ios)

Here is an example project (just run npm install and react-native run-ios to reproduce with this example project) CocoaPodsFailure.zip

Additional Information

  • React Native version: 0.36.1
  • Platform: iOS
  • Operating System: MacOS
like image 991
robertherber Avatar asked Nov 09 '22 06:11

robertherber


1 Answers

Had the same problem. Tried various things before I landed on a post that suggested to add the line:

use_frameworks

to your PodFile. It allowed me to get past the link errors.

like image 139
amahfouz Avatar answered Nov 14 '22 21:11

amahfouz