facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.01k stars 24.18k forks source link

ld: symbol(s) not found for architecture x86_64 #11900

Closed anshul-kai closed 7 years ago

anshul-kai commented 7 years ago

After unsuccessfully upgrading 0.39 to 0.40 via react-native-git-upgrade and reverting back using git --reset hard, I can no longer successfully compile using the command line. It keeps throwing the error below. I've tried all suggestions of clearing DerivedData, adding -lc++, creating a new scheme and removing the test target with no luck. Xcode seems to build successfully and run fine.

Undefined symbols for architecture x86_64:
  "_RCTParseTypeFromHeader", referenced from:
      loadTaggedScript(NSData*, NSURL*, RCTPerformanceLogger*, RandomAccessBundleData&, NSError* __autoreleasing*) in libReact.a(RCTJSCExecutor.o)
  "facebook::react::customJSCWrapper()", referenced from:
      _RCTNSErrorFromJSErrorRef in libReact.a(RCTJSCErrorHandling.o)
  "facebook::react::systemJSCWrapper()", referenced from:
      _RCTNSErrorFromJSErrorRef in libReact.a(RCTJSCErrorHandling.o)
  "facebook::react::parseTypeFromHeader(facebook::react::BundleHeader const&)", referenced from:
      +[RCTJavaScriptLoader attemptSynchronousLoadOfBundleAtURL:runtimeBCVersion:sourceLength:error:] in libReact.a(RCTJavaScriptLoader.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **

The following build commands failed:
    Ld build/Build/Products/Debug-iphonesimulator/MyProject.app/MyProject normal x86_64
(1 failure)

Any suggestions?

anshul-kai commented 7 years ago

Re-cloning the repository fixed the problem. react-native-git-upgrade must have messed up some files that are ignored by git.

drewwells commented 7 years ago

Also have been running into this issue. _RCTParseTypeFromHeader ld: symbol(s) not found for architecture x86_64. It came after downgrading back down to 0.40. The git-upgrade tool seemed to have caused it.

git-upgrade tool annotates the code in such a way that the merges have to be handled manually, which to me is more difficult than just doing it the git way.

anshul-kai commented 7 years ago

I agree @drewwells. I was able to successfully upgrade using react-native upgrade in the past but using react-native-git-upgrade didn't work as well. I'm sure they'll improve it with time.

ncuillery commented 7 years ago

@a-koka After reverting the changes in your source files, you need to bring back the old version of RN in your node_modules directory. Maybe running npm i --save react-native@0.39.2 after the revert could have resolved your issue.

@drewwells I wrote a SO answer to explain how to resolve conflicts with "the Git way": http://stackoverflow.com/q/41143471/769006

anshul-kai commented 7 years ago

Thanks @ncuillery! I did kill node_modules and re-run npm i and that didn't help much. Good to know how to resolve conflicts 'The Git Way' though. Thanks again.

mslipper commented 7 years ago

I was able to fix this by emptying the contents of ios/build/Build/Products and ios/build/Build/Intermediates.

MagLiC commented 7 years ago

thx,problem is sovled.

newtechfellas commented 6 years ago

I had to delete ios/build directory completely to get this working again.