React-native: [iOS] Undefined symbols for architecture x86_64

Created on 10 Jul 2017  路  26Comments  路  Source: facebook/react-native

Is this a bug report?

Yes

Have you read the Bugs section of the Contributing to React Native Guide?

Yes

Environment

  1. react-native -v: react-native-cli: 2.0.1 - react-native: 0.46.1
  2. node -v: v7.5.0
  3. npm -v: 4.1.2

Then, specify:

  1. Target Platform (e.g. iOS, Android): iOS
  2. Development Operating System (e.g. macOS Sierra, Windows 10): macOS Sierra 10.12.5

Steps to Reproduce

  1. Have a new project based on 0.46.1 react native.
  2. Use "babel-preset-react-native": "^2.0.0"
  3. I don't know if there is a library or what that does this but its really weird

Expected Behavior

I expect the react-native run-ios to build the app properly!
Because react-native run-android works fine and lets me build and run the android app!

Actual Behavior

 /Users/snorreedwin/Code/entur/entur-clients/native/ios/build/Build/Products/Debug-iphonesimulator/React/React.framework/React

Undefined symbols for architecture x86_64:
  "_JSNoBytecodeFileFormatVersion", referenced from:
      +[RCTJavaScriptLoader loadBundleAtURL:onProgress:onComplete:] in RCTJavaScriptLoader.o
      +[RCTJavaScriptLoader attemptSynchronousLoadOfBundleAtURL:runtimeBCVersion:sourceLength:error:] in RCTJavaScriptLoader.o
  "facebook::react::parseTypeFromHeader(facebook::react::BundleHeader const&)", referenced from:
      +[RCTJavaScriptLoader attemptSynchronousLoadOfBundleAtURL:runtimeBCVersion:sourceLength:error:] in RCTJavaScriptLoader.o
  "facebook::react::customJSCWrapper()", referenced from:
      -[RCTDevSettings isJSCSamplingProfilerAvailable] in RCTDevSettings.o
      -[RCTDevSettings toggleJSCSamplingProfiler] in RCTDevSettings.o
      _RCTNSErrorFromJSErrorRef in RCTJSCErrorHandling.o
      -[RCTSamplingProfilerPackagerMethod handleRequest:withResponder:] in RCTSamplingProfilerPackagerMethod.o
  "facebook::react::systemJSCWrapper()", referenced from:
      -[RCTDevSettings isJSCSamplingProfilerAvailable] in RCTDevSettings.o
      -[RCTDevSettings toggleJSCSamplingProfiler] in RCTDevSettings.o
      _RCTNSErrorFromJSErrorRef in RCTJSCErrorHandling.o
      -[RCTSamplingProfilerPackagerMethod handleRequest:withResponder:] in RCTSamplingProfilerPackagerMethod.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 /Users/snorreedwin/Code/entur/entur-clients/native/ios/build/Build/Products/Debug-iphonesimulator/React/React.framework/React normal x86_64
(1 failure)

Installing build/Build/Products/Debug-iphonesimulator/reactnativetidr.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/reactnativetidr.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Reproducible Demo

I'm not sure how to easily reproduce this, other than telling about our setup.
We are running CocoaPods and Swift, which makes it a bit different from an init project.
This is our dependencies:

  "dependencies": {
    "@mapbox/polyline": "^0.2.0",
    "axios": "^0.15.3",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "better-npm-run": "0.0.14",
    "file-butler": "[email protected]:enturas/file-butler.git",
    "moment": "^2.18.1",
    "native-base": "^2.2.1",
    "react": "16.0.0-alpha.12",
    "react-native": "0.46.1",
    "react-native-config-swift": "[email protected]:enturas/react-native-config-swift.git",
    "react-native-easy-grid": "^0.1.11",
    "react-native-fabric": "^0.4.1",
    "react-native-maps": "^0.15.3",
    "react-native-vector-icons": "~4.1.1",
    "react-navigation": "^1.0.0-beta.11",
    "react-redux": "^5.0.3",
    "react-router-redux": "^4.0.8",
    "redux": "^3.6.0",
    "redux-devtools-extension": "^2.13.0",
    "redux-logger": "^2.8.2",
    "redux-saga": "^0.14.3",
    "stacktrace-js": "^2.0.0",
    "url-parse": "^1.1.9"
  },
  "devDependencies": {
    "babel-eslint": "^7.2.3",
    "babel-jest": "18.0.0",
    "babel-plugin-module-resolver": "^2.7.0",
    "babel-preset-react-native": "^2.0.0",
    "eslint": "^3.19.0",
    "eslint-config-airbnb": "^14.1.0",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-react": "^7.0.1",
    "eslint-watch": "^3.1.0",
    "jest": "18.1.0",
    "jsx-control-statements": "^3.2.5",
    "react-test-renderer": "15.4.2",
    "reactotron-react-native": "^1.10.0",
    "reactotron-redux": "^1.10.0",
    "reactotron-redux-saga": "^1.10.0",
    "source-map": "^0.5.6",
    "wml": "0.0.82"
  },
Locked

Most helpful comment

Adding BatchedBridge as a subspec in your Podfile resolves the issue as @javache indicates. The tutorial at https://facebook.github.io/react-native/docs/integration-with-existing-apps.html should be updated to reflect this, as of right there is an error.

All 26 comments

same issue in my project...

screen shot 2017-07-11 at 2 25 55 pm

+1

+1

You need to add a dependency on the RCTBatchedBridge subspec (if using 0.46) or RCTCxxBridge (if newer).

In my case (0.46.3), I added React/BatchedBridge into the dependencies in Podfile and the problem went away.

Adding BatchedBridge as a subspec in your Podfile resolves the issue as @javache indicates. The tutorial at https://facebook.github.io/react-native/docs/integration-with-existing-apps.html should be updated to reflect this, as of right there is an error.

Duplicate of #14423

@RobertWSaunders Saved my night, thanks ;)

screen shot 2017-10-12 at 02 28 33

BatchedBridge is deprecated.

The following should work:

platform :ios, '9.0'
inhibit_all_warnings!
use_frameworks!

abstract_target 'All' do
  # React-Native
  pod 'React', path: '../node_modules/react-native', subspecs: %w(
    Core ART CxxBridge DevSupport
    RCTAnimation RCTImage RCTLinkingIOS RCTNetwork
    RCTPushNotification RCTText RCTWebSocket
  )

  # React-Native dependencies
  pod 'DoubleConversion', podspec: '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'Folly', podspec: '../node_modules/react-native/third-party-podspecs/Folly.podspec'
  pod 'GLog', podspec: '../node_modules/react-native/third-party-podspecs/GLog.podspec'
  pod 'yoga', path: '../node_modules/react-native/ReactCommon/yoga'

  target 'Your-Target-Name'
end

Replace BatchedBridge with CxxBridge and add DoubleConversion, Folly, and GLog. I'm not sure why we need all those libraries, React-Native is becoming more and more moving parts (that unfortunately can cause their own problems).

I'm sticking with BatchedBridge for now. After waiting 15 minutes for my poor Mac Mini to install boost (another dependency that popped up) I cancelled it.

Adding CxxBridge as suggested by @Zyphrax worked for me. My podfile for 0.51:

# The target name is most likely the name of your project.
target 'EmbedRN' do

    # Your 'node_modules' directory is probably in the root of your project,
    # but if not, adjust the `:path` accordingly
    pod 'React', :path => '../node_modules/react-native', :subspecs => [
      'Core',
      'CxxBridge',
      'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
      'RCTText',
      'RCTNetwork',
      'RCTWebSocket', # needed for debugging
      # Add any other subspecs you want to use in your project
    ]
    # Explicitly include Yoga if you are using RN >= 0.42.0
    pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

    # Third party deps podspec link
    pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
    pod 'GLog', :podspec => '../node_modules/react-native/third-party-podspecs/GLog.podspec'
    pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  end

Adding CxxBridge doesn't save my ass. Even adding DoubleConversion, Folly,GLog, the linking error stands still. My podfile is also for 0.51. What a nightmare!

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'reactTest' do
  #Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  #use_frameworks!
  #Pod react-native
  react_native = "../node_modules/react-native"
  pod 'React', :path => react_native, :subspecies => [
  'Core',
  'CxxBridge',
  'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
  'RCTText',
  'RCTNetwork',
  'RCTWebSocket', # needed for debugging
  ]

  #Pod yoga support for react-native
  pod 'yoga', :path => "#{react_native}/ReactCommon/yoga"
end

This makes me crazy. Any one can tell me what is wrong with my Podfile.

# Uncomment the next line to define a global platform for your project
platform :ios, '8.0'

target 'reactTest' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pod react-native
  react_native = "../node_modules/react-native"
  pod 'React', :path => react_native, :subspecies => [
  'Core',
  'CxxBridge',
  'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
  'RCTText',
  'RCTNetwork',
  'RCTWebSocket', # needed for debugging
  ]

  #Pod yoga support for react-native
  pod 'yoga', :path => "#{react_native}/ReactCommon/yoga"

  # Third party deps podspec link
  pod 'DoubleConversion', :podspec => "#{react_native}/third-party-podspecs/DoubleConversion.podspec"
  pod 'GLog', :podspec => "#{react_native}/third-party-podspecs/GLog.podspec"
  pod 'Folly', :podspec => "#{react_native}/third-party-podspecs/Folly.podspec"

end

God bless! This morning I rebuilt my project with the same package.js file, same Podfile file, but install node modules with yarn(previously with npm). It works incredibly fine! I'm considering what dark magic the yarn have done for me!

@MemoryReload Yeah, when in doubt, remove npm/yarn lockfiles, remove node_modules and install with yarn. That works for me 99.9% of times too 馃槃

@Zyphrax Yarn is too important for reat-native, I think. 馃槀

i still face this error

+1

+1, it only happend when i archive the project, i can successfully run and build it but when it comes to archive there are the following errors

Showing Recent Issues
: "facebook::react::parseTypeFromHeader(facebook::react::BundleHeader const&)", referenced from:

: +[RCTJavaScriptLoader attemptSynchronousLoadOfBundleAtURL:runtimeBCVersion:sourceLength:error:] in libReact.a(RCTJavaScriptLoader.o)

: "_JSNoBytecodeFileFormatVersion", referenced from:

: +[RCTJavaScriptLoader loadBundleAtURL:onProgress:onComplete:] in libReact.a(RCTJavaScriptLoader.o)

: +[RCTJavaScriptLoader attemptSynchronousLoadOfBundleAtURL:runtimeBCVersion:sourceLength:error:] in libReact.a(RCTJavaScriptLoader.o)

: Symbol(s) not found for architecture arm64

: Linker command failed with exit code 1 (use -v to see invocation)

@calcal12 If you sure that you have the correct settings in your project Podfile and have installed all the dependences. You may try this npm link in your project main folder. It works for me and I don't know why. But it works. Good luck, buddy.

@calvinkei Did you resolve this? Any idea?

@BenBach I eventually started a new react native project and transfer all my js code, and install every native module one by one again, it works but it is painful

@calvinkei Are you using cocoapods? And have both debug build and archive working?

I now have debug, release and archive working. Using two targets. The second one is a duplicate with the react modules manually linked as well, allowing the debug build to work. While the first one only links the libPods. This way the pod installation doesn't issue any warnings, and the target.remove_from_project part can be removed.

Was this page helpful?
0 / 5 - 0 ratings