Flutter - google_sign_in 正在为 iOS 模拟器-x86_64 构建,但尝试链接与为 iOS 模拟器-arm64 构建的文件。

16 浏览
0 Comments

Flutter - google_sign_in 正在为 iOS 模拟器-x86_64 构建,但尝试链接与为 iOS 模拟器-arm64 构建的文件。

这个问题已经有答案了:

Xcode编译iOS模拟器,但链接到为iOS构建的对象文件,架构为\'arm64\'

我正在尝试使用google_sign_in flutter插件运行我的auth-sample项目,但它无法编译。

我面临的错误是:

Launching lib/main.dart on iPhone 12 in debug mode...
Running pod install...
Running Xcode build...
Xcode build done.                                           10.9s
Failed to build iOS app
Error output from Xcode build:
↳
    objc[43499]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1fafd6b90) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1066b82c8). One of the two will be used. Which one is undefined.
    objc[43499]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1fafd6be0) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1066b8318). One of the two will be used. Which one is undefined.
    ** BUILD FAILED **
Xcode's output:
↳
    ld: warning: ignoring file /Users/myuser/Projects/test/auth_sample/build/ios/Debug-iphonesimulator/AppAuth/AppAuth.framework/AppAuth, building for iOS Simulator-x86_64 but attempting to link with file built for iOS Simulator-arm64
    ld: warning: ignoring file /Users/myuser/Projects/test/auth_sample/build/ios/Debug-iphonesimulator/PromisesObjC/FBLPromises.framework/FBLPromises, building for iOS Simulator-x86_64 but attempting to link with file built for iOS Simulator-arm64
    ld: warning: ignoring file /Users/myuser/Projects/test/auth_sample/build/ios/Debug-iphonesimulator/FirebaseAuth/FirebaseAuth.framework/FirebaseAuth, building for iOS Simulator-x86_64 but attempting to link with file built for iOS Simulator-arm64
    ld: warning: ignoring file /Users/myuser/Projects/test/auth_sample/build/ios/Debug-iphonesimulator/FirebaseCore/FirebaseCore.framework/FirebaseCore, building for iOS Simulator-x86_64 but attempting to link with file built for iOS Simulator-arm64
    ld: warning: ignoring file /Users/myuser/Projects/test/auth_sample/build/ios/Debug-iphonesimulator/FirebaseCoreDiagnostics/FirebaseCoreDiagnostics.framework/FirebaseCoreDiagnostics, building for iOS Simulator-x86_64 but attempting to link with file built for iOS Simulator-arm64
    ld: warning: ignoring file /Users/myuser/Projects/test/auth_sample/build/ios/Debug-iphonesimulator/GTMSessionFetcher/GTMSessionFetcher.framework/GTMSessionFetcher, building for iOS Simulator-x86_64 but attempting to link with file built for iOS Simulator-arm64
    ld: warning: ignoring file /Users/myuser/Projects/test/auth_sample/build/ios/Debug-iphonesimulator/GTMAppAuth/GTMAppAuth.framework/GTMAppAuth, building for iOS Simulator-x86_64 but attempting to link with file built for iOS Simulator-arm64
    ld: warning: ignoring file /Users/myuser/Projects/test/auth_sample/build/ios/Debug-iphonesimulator/GoogleDataTransport/GoogleDataTransport.framework/GoogleDataTransport, building for iOS Simulator-x86_64 but attempting to link with file built for iOS Simulator-arm64
    ld: warning: ignoring file /Users/myuser/Projects/test/auth_sample/build/ios/Debug-iphonesimulator/GoogleUtilities/GoogleUtilities.framework/GoogleUtilities, building for iOS Simulator-x86_64 but attempting to link with file built for iOS Simulator-arm64
    ld: warning: ignoring file /Users/myuser/Projects/test/auth_sample/build/ios/Debug-iphonesimulator/firebase_auth/firebase_auth.framework/firebase_auth, building for iOS Simulator-x86_64 but attempting to link with file built for iOS Simulator-arm64
    ld: warning: ignoring file /Users/myuser/Projects/test/auth_sample/build/ios/Debug-iphonesimulator/firebase_core/firebase_core.framework/firebase_core, building for iOS Simulator-x86_64 but attempting to link with file built for iOS Simulator-arm64
    ld: warning: ignoring file /Users/myuser/Projects/test/auth_sample/build/ios/Debug-iphonesimulator/Pods_Runner.framework/Pods_Runner, building for iOS Simulator-x86_64 but attempting to link with file built for iOS Simulator-arm64
    ld: warning: ignoring file /Users/myuser/Projects/test/auth_sample/build/ios/Debug-iphonesimulator/nanopb/nanopb.framework/nanopb, building for iOS Simulator-x86_64 but attempting to link with file built for iOS Simulator-arm64
    Undefined symbols for architecture x86_64:
      "_OBJC_CLASS_$_GTMOAuth2KeychainCompatibility", referenced from:
          objc-class-ref in GoogleSignIn(GIDAuthStateMigration_bdf842e92d17b12b5f020e0e721bd017.o)
      "_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_$_OIDServiceConfiguration", referenced from:
          objc-class-ref in GoogleSignIn(GIDSignIn_f05654be6d1b2af59ab6df426a0c4eb9.o)
      "_OIDResponseTypeCode", referenced from:
          -[GIDSignIn authenticateInteractivelyWithOptions:] 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_$_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_METACLASS_$_GTMAppAuthFetcherAuthorization", referenced from:
          _OBJC_METACLASS_$_GTMAppAuthFetcherAuthorizationWithEMMSupport in GoogleSignIn(GIDAuthentication_7b83cc27af8929ec7e4c9760d73a0f31.o)
         (maybe you meant: _OBJC_METACLASS_$_GTMAppAuthFetcherAuthorizationEMMChainedDelegate, _OBJC_METACLASS_$_GTMAppAuthFetcherAuthorizationWithEMMSupport )
      "_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_$_GTMAppAuthFetcherAuthorizationEMMChainedDelegate, _OBJC_CLASS_$_GTMAppAuthFetcherAuthorizationWithEMMSupport )
      "_OIDOAuthTokenErrorDomain", referenced from:
          ___46-[GIDAuthentication refreshTokensWithHandler:]_block_invoke in GoogleSignIn(GIDAuthentication_7b83cc27af8929ec7e4c9760d73a0f31.o)
      "_OBJC_CLASS_$_GTMKeychain", referenced from:
          objc-class-ref in GoogleSignIn(GIDAuthStateMigration_bdf842e92d17b12b5f020e0e721bd017.o)
      "_OBJC_CLASS_$_OIDAuthState", referenced from:
          objc-class-ref in GoogleSignIn(GIDAuthentication_7b83cc27af8929ec7e4c9760d73a0f31.o)
          objc-class-ref in GoogleSignIn(GIDSignIn_f05654be6d1b2af59ab6df426a0c4eb9.o)
      "_OBJC_CLASS_$_OIDAuthorizationRequest", referenced from:
          objc-class-ref in GoogleSignIn(GIDSignIn_f05654be6d1b2af59ab6df426a0c4eb9.o)
      "_OBJC_CLASS_$_FLTFirebaseCorePlugin", referenced from:
          objc-class-ref in GeneratedPluginRegistrant.o
      "_OBJC_CLASS_$_FLTFirebaseAuthPlugin", referenced from:
          objc-class-ref in GeneratedPluginRegistrant.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    /Users/myuser/Projects/test/auth_sample/ios/Runner.xcodeproj: warning: The linked framework 'Pods_Runner.framework' is missing one or more architectures required by this target: x86_64. (in target 'Runner' from project 'Runner')
Could not build the application for the simulator.
Error launching application on iPhone 12.

我有一台M1架构的Mac mini 2020,正在运行最新版本的xcode 13。

似乎某些库无法为arm架构编译,而iPhone模拟器使用该架构,因此构建失败。

我还为project.pbxproj文件设置了排除9386和arm64架构的选项:

"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "i386 arm64";

您有任何关于如何解决这个问题的想法吗?当我集成google_sign_in依赖项时,这个问题就开始了。

更新

flutter doctor -v的结果:

 ~/Projects/test/auth_sample: flutter doctor                                                                                                                                                                              
    [✓] Flutter (Channel stable, 2.8.0, on macOS 12.1 21C52 darwin-arm, locale en-IT)
    • Flutter version 2.8.0 at /Users/myuser/Src/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision cf44000065 (7 days ago), 2021-12-08 14:06:50 -0800
    • Engine revision 40a99c5951
    • Dart version 2.15.0
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/myuser/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Users/myuser/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7784292/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2
[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
    • Android Studio at /Users/myuser/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7784292/Android Studio.app/Contents
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[✓] Android Studio (version 2020.3)
    • Android Studio at /Users/myuser/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7678000/Android Studio.app/Contents
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[] IntelliJ IDEA Ultimate Edition (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues.
    ✗ FormatException: Unexpected extension byte (at offset 5)
    • #0      _Utf8Decoder.convertSingle (dart:convert-patch/convert_patch.dart:1789:7)
      #1      Utf8Decoder.convert (dart:convert/utf.dart:318:42)
      #2      InputStream.readString (package:archive/src/util/input_stream.dart:207:30)
      #3      new ZipDirectory.read (package:archive/src/zip/zip_directory.dart:40:30)
      #4      ZipDecoder.decodeBuffer (package:archive/src/zip_decoder.dart:19:30)
      #5      ZipDecoder.decodeBytes (package:archive/src/zip_decoder.dart:14:12)
      #6      IntelliJPlugins._findPluginXml (package:flutter_tools/src/intellij/intellij.dart:130:44)
      #7      IntelliJPlugins._readPackageVersion (package:flutter_tools/src/intellij/intellij.dart:141:40)
      #8      IntelliJPlugins.validatePackage (package:flutter_tools/src/intellij/intellij.dart:63:35)
      #9      IntelliJValidator.validate (package:flutter_tools/src/intellij/intellij_validator.dart:103:15)
      #10     asyncGuard. (package:flutter_tools/src/base/async_guard.dart:111:32)
      #11     asyncGuard. (package:flutter_tools/src/base/async_guard.dart:109:18)
      #12     _rootRun (dart:async/zone.dart:1428:13)
      #13     _CustomZone.run (dart:async/zone.dart:1328:19)
      #14     _runZoned (dart:async/zone.dart:1863:10)
      #15     runZonedGuarded (dart:async/zone.dart:1851:12)
      #16     runZoned (dart:async/zone.dart:1782:12)
      #17     asyncGuard (package:flutter_tools/src/base/async_guard.dart:109:3)
      #18     Doctor.startValidatorTasks (package:flutter_tools/src/doctor.dart:197:9)
      #19     Doctor.diagnose (package:flutter_tools/src/doctor.dart:301:47)
      #20     DoctorCommand.runCommand (package:flutter_tools/src/commands/doctor.dart:53:47)
      #21     FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1290:12)
      
      #22     FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:1140:27)
      
      #23     AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
      
      #24     CommandRunner.runCommand (package:args/command_runner.dart:209:13)
      
      #25     FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:288:9)
      
      #26     AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
      
      #27     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:236:5)
      
      #28     run.. (package:flutter_tools/runner.dart:62:9)
      
      #29     AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
      
      #30     main (package:flutter_tools/executable.dart:94:3)
      
[✓] IntelliJ IDEA Ultimate Edition (version 2021.3)
    • IntelliJ at /Users/myuser/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213.5744.223/IntelliJ IDEA.app
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2.3)
    • IntelliJ at /Users/myuser/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/212.5457.46/IntelliJ IDEA.app
    • Flutter plugin version 61.2.4
    • Dart plugin version 212.5486
[✓] VS Code (version 1.63.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.29.0
[✓] Connected device (2 available)
    • iPhone 12 (mobile) • 9B4C7C94-F3AA-4370-820E-5CEAF6E0AA18 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 96.0.4664.110

admin 更改状态以发布 2023年5月21日
0
0 Comments

要解决这个问题:

  • 执行flutter clean
  • 执行flutter pub get
  • 进入ios目录
  • 执行arch -x86_64 pod update
0