React-native: clang: error: linker command failed with exit code 1 when archiving

Created on 7 Feb 2019  路  18Comments  路  Source: facebook/react-native

馃悰 Bug Report

When archiving a build for arm7 architectures, I ran into a linker exception.

However, when running on a simulator It works well. Moreover, i already deleted all caches and deintegrated my pod to install it again.

To Reproduce

Just clicking on archiving on xcode :(

Code Example

capture d ecran 2019-02-07 a 20 16 28

Environment

React Native Environment Info:
System:
OS: macOS 10.14.3
CPU: x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Memory: 35.58 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.9.0 - /usr/local/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.5.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5199772
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: ^16.8.1 => 16.8.1
react-native: ^0.58.4 => 0.58.4
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7

Bug Repro iOS Stale

Most helpful comment

upgraded cocoapods to 1.7.5 and still having this issue. impossible to find the cause from the abundant useless output and the one line that tells you nothing! this build system is a joke.

All 18 comments

I have the same issue try to run my react native project from Xcode or console.

This can happen if the React project dependency is added in both the Podfile and through a manual link on the xcodeproj file. Could you post your Podfile and Link Binary With Libraries build phase?

Sure, here it goes.

The podfile

capture d ecran 2019-02-08 a 10 05 56

And the Link

capture d ecran 2019-02-08 a 10 06 33

+1 here, the issue only exists with cocoapods 1.6.0 rc1 or newer.

+1 here with cocoapods 1.6.0

On my side, i was able to fix this bug by removing the React and relatives pods from the podfile. Indeed, seems that linking it with pod generates and manual link, as @bartolkaruza said.

On my case, only RNFirebase encourages to use pod. On the contrary only linking is necessary

Any updates here? the issue starts with cocoapods since 1.6.0 rc 1 and still remains with cocoapods 1.7.0 beta 2. Or could someone identify this belongs to React Native or Cocoapods?

@xiao99xiao did the workaround mentioned work for you?

@bartolkaruza You mean giving up using Cocoapods to integrate React? Unfortunately it's not possible for our project. I believe there are a number of projects like ours that begins as a native app and got React Native added in the half way. Cocoapods is the only possible way to make it. So the workaround doesn't work for us :(

@bartolkaruza You mean giving up using Cocoapods to integrate React? Unfortunately it's not possible for our project. I believe there are a number of projects like ours that begins as a native app and got React Native added in the half way. Cocoapods is the only possible way to make it. So the workaround doesn't work for us :(

I'm sorry, I misunderstood @alvessteve workaround, I didn't mean give up on cocoapods. Cocoapods will become the recommended approach starting from RN 0.60.0 and people are working on making the Cocoapods integration first class at the moment.

I would love to understand the root cause(s) of this issue, but it's just not appearing anymore for me. If it helps, I'm sharing my Podfile and Library link section for reference.

platform :ios, '9.0'
project './xxx.xcodeproj'

target 'xxx' do
  platform :ios, '9.0'
  # use_frameworks!

   # 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'
   # 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', # Include this for RN >= 0.47
   'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
   'RCTText',
   'RCTNetwork',
   'RCTWebSocket', # Needed for debugging
   'RCTAnimation', # Needed for FlatList and animations running on native UI thread
   'RCTActionSheet',
   'RCTBlob',
   'RCTGeolocation',
   'RCTImage',
   'RCTVibration',
   'RCTSettings',
   'RCTLinkingIOS',
   'RCTPushNotification'
   ], :modular_headers => true

  # Pods for xxx
  pod 'AppCenter/Analytics', '~> 1.9.0'
  pod 'AppCenterReactNativeShared', '~> 1.8.1'
  pod 'PhotoEditorSDK', '~> 8.6.3'
  pod 'Intercom'
  pod 'Firebase/Core', '~> 5.15.0'
  pod 'Firebase/Messaging', '~> 5.15.0'
  pod 'GoogleAppMeasurement', '~> 5.4.0'

   # Keep this here to prevent `react-native link` from adding it again
  #pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
  #pod 'react-native-config', :path => '../node_modules/react-native-config'
  #pod 'RNFS', :path => '../node_modules/react-native-fs'
  #pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'
  #pod 'react-native-intercom', :path => '../node_modules/react-native-intercom'

  pod 'react-native-fbsdk', :path => '../node_modules/react-native-fbsdk'
  # CodePush plugin dependency
  pod 'CodePush', :path => '../node_modules/react-native-code-push'

end



post_install do |installer|
  system("mkdir -p Pods/Headers/Public/FirebaseCore && cp Pods/FirebaseCore/Firebase/Core/Public/* Pods/Headers/Public/FirebaseCore/")

  # From https://github.com/facebook/react-native/issues/20492#issuecomment-422958184
  installer.pods_project.targets.each do |target|

    # The following is needed to ensure the "archive" step works in XCode.
    # It removes React & Yoga from the Pods project, as it is already included in the main project.
    # Without this, you'd see errors when you archive like:
    # "Multiple commands produce ... libReact.a"
    # "Multiple commands produce ... libyoga.a"

    targets_to_ignore = %w(React yoga)

    if targets_to_ignore.include? target.name
      target.remove_from_project
    end

  end
end

Screenshot 2019-03-13 at 21 09 05

A first notable difference is that there is no libReact.a in the Linked Frameworks and Libraries section.

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

This issue is resolved for me since Cocoapods 1.7.0

upgraded cocoapods to 1.7.5 and still having this issue. impossible to find the cause from the abundant useless output and the one line that tells you nothing! this build system is a joke.

I did following steps helped me to resolve the issue.
removed package-lock.json /yarn.lock & pod.lock and deleted node_modules.
Reinstall all the module and pods then you all good to go

Hi! Is there anybody find answer of this problem?
I was chaning value of [Build Setting - Other linker flag]
After I got error, I change it back. But The Linker error still comes out.
Hope anybody can help.
pacakge.json

"dependencies": {
    "react": "16.11.0",
    "react-native": "0.62.0",
    "react-native-my-library": "./react-native-my-library"
  },
  "devDependencies": {
    "@babel/core": "^7.9.0",
    "@babel/runtime": "^7.9.2",
    "@react-native-community/eslint-config": "^1.0.0",
    "babel-jest": "^25.2.4",
    "eslint": "^6.8.0",
    "jest": "^25.2.4",
    "metro-react-native-babel-preset": "^0.59.0",
    "react-test-renderer": "16.11.0"
  },
  "jest": {
    "preset": "react-native"
  }

Podfile

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

def add_flipper_pods!
  version = '~> 0.33.1'
  pod 'FlipperKit', version, :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitLayoutPlugin', version, :configuration => 'Debug'
  pod 'FlipperKit/SKIOSNetworkPlugin', version, :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitUserDefaultsPlugin', version, :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitReactPlugin', version, :configuration => 'Debug'
end

# Post Install processing for Flipper
def flipper_post_install(installer)
  installer.pods_project.targets.each do |target|
    if target.name == 'YogaKit'
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '4.1'
      end
    end
  end
end

target 'kakaodie' do
  # Pods for kakaodie
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true

  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'

  target 'kakaodieTests' do
    inherit! :complete
    # Pods for testing
  end

  use_native_modules!

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  add_flipper_pods!
  post_install do |installer|
    flipper_post_install(installer)
  end
end

target 'kakaodie-tvOS' do
  # Pods for kakaodie-tvOS

  target 'kakaodie-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

I got the same error, I can run with run-react native, I can Archive on Xcode but I cannot build a on device with Xcode I get the
Apple Match-O error :
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've tried most of the things said above.

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

Was this page helpful?
0 / 5 - 0 ratings