2

I am trying to build my react-native project on iOS simulator and getting the below error:

error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening MyProject.xcworkspace

...

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 **

I have researched my part and tried possible solutions here and here which seem to not work.

I am using react-native version ~0.61.4 and Xcode Version 11.4.1 on macOS Catalina version 10.15.2 Even the app doesn't start on simulator.

EDIT

I cleaned the Xcode Workspace, ran pod deintregate and pod install and then react-native run-ios with gives me these following details:

Undefined symbols for architecture x86_64:
  "__swift_FORCE_LOAD_$_swiftCompatibility50", referenced from:
      __swift_FORCE_LOAD_$_swiftCompatibility50_$_Lottie in liblottie-ios.a(AnimatedButton.o)
      __swift_FORCE_LOAD_$_swiftCompatibility50_$_Lottie in liblottie-ios.a(AnimatedControl.o)
      __swift_FORCE_LOAD_$_swiftCompatibility50_$_Lottie in liblottie-ios.a(AnimationContainer.o)
      __swift_FORCE_LOAD_$_swiftCompatibility50_$_Lottie in liblottie-ios.a(AnimationSubview.o)
      __swift_FORCE_LOAD_$_swiftCompatibility50_$_Lottie in liblottie-ios.a(CompatibleAnimationView.o)
      __swift_FORCE_LOAD_$_swiftCompatibility50_$_Lottie in liblottie-ios.a(CompositionLayer.o)
      __swift_FORCE_LOAD_$_swiftCompatibility50_$_Lottie in liblottie-ios.a(NullCompositionLayer.o)
      ...
     (maybe you meant: __swift_FORCE_LOAD_$_swiftCompatibility50_$_lottie_react_native, __swift_FORCE_LOAD_$_swiftCompatibility50_$_Lottie )
  "__swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements", referenced from:
      __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_Lottie in liblottie-ios.a(AnimatedButton.o)
      __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_Lottie in liblottie-ios.a(AnimatedControl.o)
      __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_Lottie in liblottie-ios.a(AnimationContainer.o)
      __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_Lottie in liblottie-ios.a(AnimationSubview.o)
      __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_Lottie in liblottie-ios.a(CompatibleAnimationView.o)
      __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_Lottie in liblottie-ios.a(CompositionLayer.o)
      __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_Lottie in liblottie-ios.a(NullCompositionLayer.o)
      ...
     (maybe you meant: __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_lottie_react_native, __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_Lottie )
  "_main", referenced from:
     implicit entry/start for main executable
     (maybe you meant: _OBJC_IVAR_$_RCTScrollView._maintainVisibleContentPosition)

Referring to this question, I tried the solution with nothing good. Any suggestions on how to fix this?

LordAnari
  • 89
  • 1
  • 8
  • did you open xcworkspace file not xcodeproj file – Shing Ho Tan Apr 20 '20 at 03:45
  • I understand the difference, but there were no modifications on my part apart from adding `JavaScriptCore.Framework`. Also I am building from my `react-native` project directory using `react-native run-ios` – LordAnari Apr 20 '20 at 03:52
  • why did you add `JavaScriptCore.Framework`? – Shing Ho Tan Apr 20 '20 at 03:54
  • 1
    Did you do `pod install`? after pod install then open xcworkspace file and try run in xcode – Shing Ho Tan Apr 20 '20 at 03:54
  • 1
    `JavaScriptCore.Framework` was added as a trial and error from the solution I found in the first link provided since it had to be manually linked until previous verions. And yes, `pod install` had run successfully. – LordAnari Apr 20 '20 at 03:59
  • Running on Xcode gives me [this](https://i.imgur.com/BppLXme.png). I am not much familiar with Xcode or Swift. Would be good to have some guide here. – LordAnari Apr 20 '20 at 04:13
  • What are the frameworks that you added in you project ? – EL173 Apr 20 '20 at 04:41
  • @EL173 I have used a number of Frameworks, notably the Razorpay Framework through `react-native-razorpay`, however I am not adding them directly through xcode. It is probably resolved through `pod install` – LordAnari Apr 20 '20 at 08:54
  • @EL173 Is there a need to manually link all Frameworks and dependencies that I have used? – LordAnari Apr 20 '20 at 10:56

3 Answers3

1

Create a swift file inside your xcode project, it will resolve your issue.

It will include to the Header Search Path on your build settings:

$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)
$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
Ubaid
  • 737
  • 8
  • 18
0

Seems like you have installed a pod or multiple pods and you are trying to run the .xcproj (which we all do when try to install pods for the first time, me no exception :) ) which doesn't contain the libraries you need to run your app. Close xcode, go to your project folder with finder, look for the .xcworkspace file and open it. Then run it.

Murmeltier
  • 595
  • 5
  • 10
  • In my [comment](https://stackoverflow.com/questions/61314724/react-native-run-ios-fails-with-ld-symbols-not-found-for-architecture-x86-64?noredirect=1#comment108469503_61314724) I have mentioned doing the same. – LordAnari Apr 20 '20 at 08:50
-2

There was probably some issue with my Podfile.

  • Deleted Pods
  • Took back-up of the dependencies in Podfile
  • Created an empty react-native project and generated the Podfile
  • Copied the dependencies to the Podfile and replaced that in project/ios
  • ran pod install

This apparently solved the issue. Now react-native run-ios working just fine on the simulator.

LordAnari
  • 89
  • 1
  • 8