我尝试在带有 M1 芯片的新 Mac 上构建现有的 Flutter 项目。 我遇到以下关于缺少 audio_session 模块的错误。
Launching lib/main.dart on iPhone 12 in debug mode...
Running Xcode build...
└─Compiling, linking and signing... 340ms
Xcode build done. 4.7s
Failed to build iOS app
Error output from Xcode build:
↳
objc[7636]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x1f2fe0188) and ?? (0x117e8c2b8). One of the two will be used. Which one is undefined.
objc[7636]: Class AMSupportURLSession is implemented in both ?? (0x1f2fe01d8) and ?? (0x117e8c308). One of the two will be used. Which one is undefined.
** BUILD FAILED **
Xcode's output:
↳
/Users/user/Projects/myproject/ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: module 'audio_session' not found
@import audio_session;
~~~~~~~^~~~~~~~~~~~~
1 error generated.
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone 12.
有什么想法吗?
答案 0 :(得分:1)
你应该
1。在 xcode 中打开“Runner.xcworkspace”,而不是“Runner.xcodeproj”
2。一切顺利
答案 1 :(得分:0)
终于找到了解决方案。
不知何故,如果我转到我的 Flutter 项目的 iOS 文件夹并输入“pod init;” pod install' 生成了一个基本的 Podfile(意味着它只指定了平台)。
我在某处发现了一个帖子,建议删除 iOS 文件夹中关于 pod 的所有内容,并在项目中运行 flutter run。在项目文件夹中运行“flutter run”(也集成了“pod install”),生成了一个非常详细的 Podfile,但这次我遇到了另一个关于平台的错误(如下所列)。
Error output from CocoaPods:
↳
[!] Automatically assigning platform `iOS` with version `12.0` on target
`Runner` because no platform was specified. Please specify a platform for
this target in your Podfile. See
`https://guides.cocoapods.org/syntax/podfile.html#platform`.
Error: To set up CocoaPods for ARM macOS, run:
arch -x86_64 sudo gem install ffi
我尝试按照建议运行上面显示的命令,但发生了同样的错误。
然后,我在这里Running Cocoapods on Apple Silicon (M1)找到了与官方文档https://github.com/flutter/flutter/wiki/Developing-with-Flutter-on-Apple-Silicon类似的答案。
即便如此,堆栈溢出的答案并没有直接对我有用,直到我按照以下步骤操作:
我希望这对其他人有用。