module 'audio_session' not found
Asked Answered
S

5

18

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?

Sjambok answered 18/3, 2021 at 13:20 Comment(6)
make sure you have added audio_session package in pubspec.yml file. after then run the command flutter pub get and flutter runRhearheba
I don't use this package at all. I think somehow it is a dependency.Sjambok
I cleaned the pod file and I figure out that 'flutter run' generated a more complex Podfile. Anyway, another error is generated Error: To set up CocoaPods for ARM macOS, run: arch -x86_64 sudo gem install ffi Even if I run the command that was mentioned, the same error occur.Sjambok
Running into the same problem. I'm using just_audio which depends on audio_session.Saurischian
Okay, I think my problem was opening ios/Runner.xcodeproj instead of ios/Runner.xcworkspace. More on that hereSaurischian
@kohjakob, check my answer below.Sjambok
S
8

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:

  1. Open finder -> Utilities
  2. Right click on the Terminal -> Get Info
  3. Check 'Open with Rosetta'
  4. Open a new terminal and type 'gem uninstall cocoapods'
  5. sudo gem install cocoapods
  6. gem uninstall ffi
  7. arch -x86_64 sudo gem install ffi

I hope this is useful for someone else.

Sjambok answered 18/3, 2021 at 14:58 Comment(1)
should we install cocoapods back?Ethelyn
T
20

You should

1 . open "Runner.xcworkspace" in xcode , Not "Runner.xcodeproj"

2 . everything going well

Tashia answered 14/5, 2021 at 12:28 Comment(4)
In my case I used the terminal to build, by running flutter run. I already posted an answer down below.Sjambok
okay , i got same question other day , and cause i open "Runner.xcworkspace" in xcodeTashia
Any solution to this?? I opened Runner.xcworkspace...but still get this issueApologete
I tried it with Runner.xcworkspace and it didn't workHailey
S
8

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:

  1. Open finder -> Utilities
  2. Right click on the Terminal -> Get Info
  3. Check 'Open with Rosetta'
  4. Open a new terminal and type 'gem uninstall cocoapods'
  5. sudo gem install cocoapods
  6. gem uninstall ffi
  7. arch -x86_64 sudo gem install ffi

I hope this is useful for someone else.

Sjambok answered 18/3, 2021 at 14:58 Comment(1)
should we install cocoapods back?Ethelyn
C
4

For me, it build succesfully after I ran flutter clean.

flutter clean
flutter pub get
flutter build ios

It worked for me.

Cagliari answered 10/5, 2022 at 11:56 Comment(2)
Worked for me as wellSanborn
build success but run fail with same problemSusy
V
2

In my case, I had changed the platform :ios to '13.0', but my iOS Deployment Target was '9.0'. I left the two the same and it started working again.

Make sure platform: iOS version in pod file matches with deployment info in Xcode

enter image description here

Source: thanhbinh84

Varico answered 14/7, 2022 at 16:49 Comment(0)
R
-1

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.
Real answered 18/11, 2021 at 5:13 Comment(1)
I face the problem with Product > ArchiveHaplo

© 2022 - 2024 — McMap. All rights reserved.