How to solve xcode build error 'Undefined symbols for architecture x86_64'
Asked Answered
E

6

10

I tried to run the project in the emulator, I encountered some problems and solved it, I finally got the following error, I tried many ways, but I can't solve it. How can I fix this, please give me some ideas, I'm new to ios development.

cpu: m1 pro

system: macOS12.3

xcode: 13.4

react native: 0.62.2

The following is the error message:


Showing Recent Errors Only

Build target tolernPowerBankApp of project demo with configuration Debug


Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_OIDURLQueryComponent", referenced from:
      objc-class-ref in GoogleSignIn(GIDSignIn_f05654be6d1b2af59ab6df426a0c4eb9.o)
  "_OBJC_CLASS_$_GTMSessionFetcher", referenced from:
      objc-class-ref in GoogleSignIn(GIDSignIn_f05654be6d1b2af59ab6df426a0c4eb9.o)
  "_OBJC_CLASS_$_OIDAuthorizationRequest", referenced from:
      objc-class-ref in GoogleSignIn(GIDSignIn_f05654be6d1b2af59ab6df426a0c4eb9.o)
  "_OIDResponseTypeCode", referenced from:
      -[GIDSignIn authenticateInteractivelyWithOptions:] in GoogleSignIn(GIDSignIn_f05654be6d1b2af59ab6df426a0c4eb9.o)
  "_OBJC_CLASS_$_OIDAuthState", referenced from:
      objc-class-ref in GoogleSignIn(GIDAuthentication_7b83cc27af8929ec7e4c9760d73a0f31.o)
      objc-class-ref in GoogleSignIn(GIDSignIn_f05654be6d1b2af59ab6df426a0c4eb9.o)
  "_OBJC_CLASS_$_OIDAuthorizationService", referenced from:
      objc-class-ref in GoogleSignIn(GIDAuthentication_7b83cc27af8929ec7e4c9760d73a0f31.o)
      objc-class-ref in GoogleSignIn(GIDSignIn_f05654be6d1b2af59ab6df426a0c4eb9.o)
  "_OIDOAuthErrorResponseErrorKey", referenced from:
      +[GIDAuthentication handleTokenFetchEMMError:completion:] in GoogleSignIn(GIDAuthentication_7b83cc27af8929ec7e4c9760d73a0f31.o)
  "_OBJC_CLASS_$_SKDescriptorMapper", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_GTMAppAuthFetcherAuthorization", referenced from:
      _OBJC_CLASS_$_GTMAppAuthFetcherAuthorizationWithEMMSupport in GoogleSignIn(GIDAuthentication_7b83cc27af8929ec7e4c9760d73a0f31.o)
      objc-class-ref in GoogleSignIn(GIDAuthentication_7b83cc27af8929ec7e4c9760d73a0f31.o)
      objc-class-ref in GoogleSignIn(GIDSignIn_f05654be6d1b2af59ab6df426a0c4eb9.o)
      objc-class-ref in GoogleSignIn(GIDAuthStateMigration_bdf842e92d17b12b5f020e0e721bd017.o)
     (maybe you meant: _OBJC_CLASS_$_GTMAppAuthFetcherAuthorizationWithEMMSupport, _OBJC_CLASS_$_GTMAppAuthFetcherAuthorizationEMMChainedDelegate )
  "_OBJC_METACLASS_$_GTMAppAuthFetcherAuthorization", referenced from:
      _OBJC_METACLASS_$_GTMAppAuthFetcherAuthorizationWithEMMSupport in GoogleSignIn(GIDAuthentication_7b83cc27af8929ec7e4c9760d73a0f31.o)
     (maybe you meant: _OBJC_METACLASS_$_GTMAppAuthFetcherAuthorizationWithEMMSupport, _OBJC_METACLASS_$_GTMAppAuthFetcherAuthorizationEMMChainedDelegate )
  "_OBJC_CLASS_$_OIDIDToken", referenced from:
      objc-class-ref in GoogleSignIn(GIDGoogleUser_2bdd4a676c033bc6ca21970e75d9159c.o)
      objc-class-ref in GoogleSignIn(GIDAuthentication_7b83cc27af8929ec7e4c9760d73a0f31.o)
      objc-class-ref in GoogleSignIn(GIDSignIn_f05654be6d1b2af59ab6df426a0c4eb9.o)
  "_OBJC_CLASS_$_OIDServiceConfiguration", referenced from:
      objc-class-ref in GoogleSignIn(GIDSignIn_f05654be6d1b2af59ab6df426a0c4eb9.o)
  "_OBJC_CLASS_$_FIRApp", referenced from:
      objc-class-ref in AppDelegate.o
  "_RCTRegisterModule", referenced from:
      +[SignWithApple load] in SignWithApple.o
  "_OBJC_CLASS_$_RNCPushNotificationIOS", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_RCTConvert", referenced from:
      __OBJC_$_CATEGORY_RCTConvert_$_GIDSignInButtonStyle in AppDelegate.o
      __OBJC_$_CATEGORY_RCTConvert_$_GIDSignInButtonColorScheme in AppDelegate.o
  "_OIDOAuthTokenErrorDomain", referenced from:
      ___46-[GIDAuthentication refreshTokensWithHandler:]_block_invoke in GoogleSignIn(GIDAuthentication_7b83cc27af8929ec7e4c9760d73a0f31.o)
  "_OBJC_CLASS_$_FlipperKitNetworkPlugin", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_FlipperKitReactPlugin", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_RCTViewManager", referenced from:
      _OBJC_CLASS_$_SignWithApple in SignWithApple.o
  "_OBJC_CLASS_$_FlipperClient", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_GTMOAuth2KeychainCompatibility", referenced from:
      objc-class-ref in GoogleSignIn(GIDAuthStateMigration_bdf842e92d17b12b5f020e0e721bd017.o)
  "_OBJC_CLASS_$_RCTLinkingManager", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_FKUserDefaultsPlugin", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_GTMKeychain", referenced from:
      objc-class-ref in GoogleSignIn(GIDAuthStateMigration_bdf842e92d17b12b5f020e0e721bd017.o)
  "_OBJC_CLASS_$_RCTBridge", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_RCTRootView", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_METACLASS_$_RCTViewManager", referenced from:
      _OBJC_METACLASS_$_SignWithApple in SignWithApple.o
  "_OBJC_CLASS_$_FlipperKitLayoutPlugin", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_SKIOSNetworkAdapter", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_RCTBundleURLProvider", referenced from:
      objc-class-ref in AppDelegate.o
  "_RCTConvertEnumValue", referenced from:
      +[RCTConvert(GIDSignInButtonStyle) GIDSignInButtonStyle:] in AppDelegate.o
      +[RCTConvert(GIDSignInButtonColorScheme) GIDSignInButtonColorScheme:] in AppDelegate.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    2022/5/23, 14:06    140.1 seconds



Doing this helped me solve this problem:

Modify the Build Settings -> Excluded Architectures option, add the Any iOS Simulator SDK option, and set the value to arm64.As shown in the figure: enter image description here

and add the following code in Podfile:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = "arm64"
    end
  end
end


This problem I'm having seems to be caused by M1. https://juejin.cn/post/7037037120158269448

Eamon answered 23/5, 2022 at 6:36 Comment(1)
The edited part should be more evident because it is the working solution. πŸ™‚ – Cerebrovascular
S
8

You can view these links maybe they can help:

Although what helped me was removing these values from the library search paths on react-native 0.64.2

Xcode -> Build Settings -> Search Paths -> Library Search Paths

  • "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"
  • "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)"

Also cleaning the project and xcode derived data can help also

  • rm -rf ~/Library/Developer/Xcode/DerivedData (clean derived data)
  • CMD + K (Clean Project from xcode)
Seedcase answered 23/5, 2022 at 6:52 Comment(0)
B
2

just choose product -> Destination -> Destination architecture -> show rosetta destinations and rebuild the app

Besnard answered 17/12, 2023 at 11:39 Comment(1)
dude you rock! I am on M3, i timemachined from an Intel Mac and having problems running my old Apps on M3. This really helped. – Motherhood
D
0

I just had to do :

rm -rf ~/Library/Developer/Xcode/DerivedData/*

and pod install (because a try pod deintegrate before)

and restart metro bundler.

I hope this will help you

Dael answered 1/12, 2022 at 11:0 Comment(2)
rm: /Users/felipe/user/Developer/Xcode/DerivedData/Runner-bmdzbfbkaoxeeedtkykbbcclcanf: Permission denied – Hilel
You can try : sudo rm – Dael
E
0

just comment out this lines in iOS/podfile:

target 'RunnerTests' do
    inherit! :search_paths
  end
Editorial answered 22/11, 2023 at 14:52 Comment(0)
U
0

The answer provided in the edit is the correct solution. To relay in thread:

Add the following to your Podfile:

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end

For a more detailed solve, read this discussion: Xcode building for iOS Simulator, but linking in an object file built for iOS, for architecture 'arm64'

Uprear answered 11/9, 2024 at 15:6 Comment(0)
A
-1

I had this problem when I was initializing react-native project.

I'm using M1 Ventura 13.1.
https://github.com/facebook/react-native/issues/35053#issuecomment-1324612311 https://fek.io/blog/how-to-set-up-react-native-on-m-1-mac-2022-edition

Following these worked perfectly on initiating a react-native project! These include specific insturctions on ruby installation(using rbenv) and using lts node, etc.
To include the details,

  1. watchman, cocoapods are installed with homebrew.
  2. ruby is installed with rbenv and after that, the version is stored in ~/.ruby-version
Argyll answered 30/12, 2022 at 22:55 Comment(1)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review – Longford

© 2022 - 2025 β€” McMap. All rights reserved.