如何求解xcode构建错误'架构x86_64'的未定义符号

发布于 2025-01-31 11:20:53 字数 6373 浏览 3 评论 0 原文

我试图在模拟器中运行该项目,遇到了一些问题并解决了问题,终于遇到了以下错误,我尝试了许多方法,但是我无法解决。我该如何解决此问题,请给我一些想法,我是iOS开发的新手。

CPU:M1 PRO

系统:MACOS12.3

XCODE:13.4

REECT本地:0.62.2

以下是错误消息:


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



这样做帮助我解决了这个问题:

修改构建设置 - >排除架构选项,添加任何iOS Simulator SDK选项,并将值设置为ARM64.1所示:

并在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


我似乎是由M1引起的。 https://juejin.cn/post/70370370370371201201582694448>

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

王权女流氓 2025-02-07 11:20:53

您可以查看这些链接,也许它们可以提供帮助:

尽管有助于我从react -native 0.64.2

xcode上的库搜索路径中删除这些值的原因是 - >构建设置 - >搜索路径 - >库搜索路径

  • “ $(toolchain_dir)/usr/lib/swift-5.0/ $(platform_name)”
  • “ $(toolchain_dir)/usr/usr/lib/swift/$(platform_name)” << /code>

清洁项目和Xcode派生的数据还可以帮助

  • rm -rf〜/library/developer/xcode/deriveddata (清洁派生数据)
  • cmd + k (清洁来自Xcode的项目)

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)
迷离° 2025-02-07 11:20:53

只需选择产品 - &GT;目的地 - &GT;目标架构 - &GT;展示罗塞塔目的地并重建应用程序

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

宣告ˉ结束 2025-02-07 11:20:53

我只需要做:

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

pod install (因为尝试 pod dentegrate 之前)

和重新启动Metro Bundler。

我希望这对你有帮助

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

零度° 2025-02-07 11:20:53

只需在iOS/podfile中评论这一行:

target 'RunnerTests' do
    inherit! :search_paths
  end

just comment out this lines in iOS/podfile:

target 'RunnerTests' do
    inherit! :search_paths
  end
北城半夏 2025-02-07 11:20:53

编辑中提供的答案是正确的解决方案。要中继线程:

将以下内容添加到您的podfile:

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

要进行更详细的求解,请阅读此讨论:

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'

澜川若宁 2025-02-07 11:20:53

当我初始化反应生态项目时,我遇到了这个问题。

我正在使用M1 Ventura 13.1。
https:// https://github.com/github.com/face/face/face/react-native/issues/ 35053#issuecomment-1324612311
https:// fek.io/blog/how-to-to-to-to-up-up-react-native-on-m-1-Mac-2022-Edition

之后,这些功能非常适合启动一个React-Native Project!
其中包括有关Ruby安装(使用RBENV)和使用LTS节点等的特定启动。

为了包括详细信息,

  1. 守望者,可可录是与自制的。
  2. Ruby与RBENV一起安装,此后,该版本存储在〜/.ruby-version中

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文