提问者:小点点

找不到模块'Audio_Session'


我试着在一个带有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.

有什么想法吗?


共1个答案

匿名用户

终于,找到了解决办法。

不知怎么的,如果我进入flutter项目的iOS文件夹,输入'pod init;pod install'生成了一个基本的Podfile(这意味着它只指定了平台)。

我在某个地方发现了一个帖子,建议删除iOS文件夹中关于pod的所有内容,并在项目中运行flutter run。在project文件夹中运行“flutter run”(也集成了“pod install”),生成了一个非常详细的pod文件,但这一次我遇到了与平台有关的另一个错误(如下所列)。

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

我试图按照建议运行上面显示的命令,但发生了同样的错误。

然后,我在Apple Silicon(M1)上运行Cocoapods找到了一个与官方文档https://github.com/flutter/flutter/wiki/development-with-flutter-on-Apple-Silicon相似的答案。

即使如此,堆栈溢出的答案对我来说并没有直接起作用,直到我按照以下步骤操作:

  1. 打开查找器->实用工具
  2. 右键单击终端->获取信息
  3. 选中“使用Rosetta打开”4。打开新的终端,然后键入“gem uninstall cocoapods”
  4. sudo gem安装cocoapods 6。gem卸载FFI
  5. arch-x86_64 sudo gem安装FFI

我希望这对别人有用。