Flutter iOS构建报错AMSupportURL类重复实现 常规修复方案无效求助
objc[14025]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1efb7ac10) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x12c2b82b8). One of the two will be used. Which one is undefined.
objc[14025]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1efb7ac60) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x12c2b8308). One of the two will be used. Which one is undefined.
** BUILD FAILED **
- 在项目目录下执行
flutter clean - 执行
flutter pub get后运行pod update - 单独执行
pod update - 执行
pod repo update - 重启Xcode与Mac设备
- 执行
pod install - 执行
flutter build ios
该报错属于Xcode 14+版本常见的系统库类名重复冲突触发的编译失败,上述类重复提示本身属于系统级警告,正常不会阻断编译,绝大多数情况是链接器或架构配置异常导致警告被升级为错误拦截了编译流程,可按以下步骤排查:
- Xcode 15+链接器配置修复
打开项目ios目录下的Podfile,在post_install代码块中添加以下配置,强制使用旧版链接器并关闭相关警告拦截:post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| # 强制使用旧版链接器解决新链接器误判错误 config.build_settings['OTHER_LDFLAGS'] ||= [] config.build_settings['OTHER_LDFLAGS'] << '-ld64' # 关闭警告视为错误配置 config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'NO' config.build_settings['SWIFT_TREAT_WARNINGS_AS_ERRORS'] = 'NO' end end end - 模拟器架构排除配置
如果是M系列芯片的Mac设备,需要在Xcode项目的Build Settings中,找到Excluded Architectures选项,在Any iOS Simulator SDK的配置下添加arm64;同时在Podfile的post_install块内补充以下配置,同步Pods项目的架构规则:installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" end - 全量缓存清理重建
执行以下命令全量清理旧编译产物后重新构建:flutter clean rm -rf ios/Pods ios/Podfile.lock ios/Runner.xcworkspace flutter pub get cd ios && pod install --repo-update cd .. && flutter run -d ios - 依赖兼容性排查
检查pubspec.yaml中所有第三方依赖的版本,升级至支持你当前Xcode版本的最新稳定版,部分老旧的原生iOS插件会触发该类编译冲突。
内容的提问来源于stack exchange,提问作者Mohammed Niyaz

