Z Hu
Z Hu

Reputation: 1015

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

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

Upvotes: 11

Views: 34945

Answers (6)

Jake Curreri
Jake Curreri

Reputation: 23

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'

Upvotes: 0

Matthew Adel
Matthew Adel

Reputation: 81

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

Upvotes: 2

M.S Moh-
M.S Moh-

Reputation: 1

just comment out this lines in iOS/podfile:

target 'RunnerTests' do
    inherit! :search_paths
  end

Upvotes: 0

Abdullah Qureshi
Abdullah Qureshi

Reputation: 91

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)

Upvotes: 8

SKO
SKO

Reputation: 50

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

Upvotes: -1

Anroche
Anroche

Reputation: 1011

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

Upvotes: 0

Related Questions