'module 'audio_session' not found
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.
Any thoughts?
Solution 1:[1]
Finally, found a solution.
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).
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.
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:
- Open finder -> Utilities
- Right click on the Terminal -> Get Info
- Check 'Open with Rosetta'
- Open a new terminal and type 'gem uninstall cocoapods'
- sudo gem install cocoapods
- gem uninstall ffi
- arch -x86_64 sudo gem install ffi
I hope this is useful for someone else.
Solution 2:[2]
You should
1 . open "Runner.xcworkspace" in xcode , Not "Runner.xcodeproj"
2 . everything going well
Solution 3:[3]
18 nov 2020. M1, macOS Monterey.
Have the same issue with audio_session, but only in iPhone 15 simulator.
- Download previous version on iOS.
- Run without any other hacks.
Solution 4:[4]
For me, it build succesfully after I ran flutter clean
.
flutter clean
flutter pub get
flutter build ios
It worked for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | capdev |
Solution 3 | |
Solution 4 | Anirban Das |