未找到模块“audio_session" [英] module 'audio_session' not found

查看:31
本文介绍了未找到模块“audio_session"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在带有 M1 芯片的新 Mac 上构建现有的 Flutter 项目.我遇到以下关于缺少 audio_session 模块的错误.

I try to build an existing flutter project on a new Mac with M1 chip. I face the following error in regards that the audio_session module is missing.

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.

有什么想法吗?

推荐答案

终于找到了解决方案.

不知何故,如果我转到我的 Flutter 项目的 iOS 文件夹并输入pod init;"pod install' 生成了一个基本的 Podfile(意味着它只指定了平台).

Somehow, If I went to the iOS folder of my flutter project and type 'pod init; pod install' a basic Podfile was generated (meaning that it had specified only the platform).

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

I found a post somewhere that suggested to delete everything in the iOS folder about pod and to run flutter run in the project. Running 'flutter run' in the project folder (that integrates 'pod install' as well), generated a much detailed Podfile, but this time I faced another error in regards with the platform (listed below).

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

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

I tried to follow the suggestion to run the command shown above, but the same error occurred.

然后,我在这里找到了答案在 Apple Silicon (M1) 上运行 Cocoapods 与官方文档类似 https://github.com/flutter/flutter/wiki/Developing-with-Flutter-on-Apple-Silicon.

Then, I found an answer here Running Cocoapods on Apple Silicon (M1) that is similar with the official documentation https://github.com/flutter/flutter/wiki/Developing-with-Flutter-on-Apple-Silicon.

即便如此,在我按照以下步骤操作之前,堆栈溢出的答案并没有直接对我有用:

Even so, the answer from the stack overflow didn't work straight forward for me until I followed these steps:

  1. 打开取景器 ->实用程序
  2. 右键单击终端 ->获取信息
  3. 选中使用 Rosetta 打开"
  4. 打开一个新终端并输入gem uninstall cocoapods"
  5. sudo gem 安装 cocoapods
  6. gem 卸载 ffi
  7. arch -x86_64 sudo gem install ffi

我希望这对其他人有用.

I hope this is useful for someone else.

这篇关于未找到模块“audio_session"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆