module 'audio_session' not found

3,962

Solution 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:

  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.

Solution 2

You should

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

2 . everything going well

Share:
3,962
Alexandru Rusu
Author by

Alexandru Rusu

πŸ‘‹ I am a Senior Flutter Developer / Consultant / Contractor / Freelancer 𝐰𝐒𝐭𝐑 πŸ•+ 𝐲𝐞𝐚𝐫𝐬 𝐨𝐟 𝐞𝐱𝐩𝐞𝐫𝐒𝐞𝐧𝐜𝐞, using my expertise to identify & implement clients’ needs with regards to their software solutions. About my skills: β€’ Cross-Platform: Flutter, Kivy β€’ Backend: Dart, Python, C, Linux, Firebase, Docker, Algorithms β€’ Software Architecture: Domain-Driven Design, Test-Driven Design, Clean code, Microservices, Unit testing β€’ Leadership: People and Communication skills, Planning, Ability to teach and mentor 🌍 Only interested in remote work. πŸ“© Drop me a message if you think my expertise could help your organization! πŸ“ž Phone: +40 768 050 010 πŸ“§ Email: [email protected] πŸ’¬ Skype: agrusu_1

Updated on December 06, 2022

Comments

  • Alexandru Rusu
    Alexandru Rusu over 1 year

    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?

    • Ranjit Shrestha
      Ranjit Shrestha about 3 years
      make sure you have added audio_session package in pubspec.yml file. after then run the command flutter pub get and flutter run
    • Alexandru Rusu
      Alexandru Rusu about 3 years
      I don't use this package at all. I think somehow it is a dependency.
    • Alexandru Rusu
      Alexandru Rusu about 3 years
      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.
    • kohjakob
      kohjakob about 3 years
      Running into the same problem. I'm using just_audio which depends on audio_session.
    • kohjakob
      kohjakob about 3 years
      Okay, I think my problem was opening ios/Runner.xcodeproj instead of ios/Runner.xcworkspace. More on that here
    • Alexandru Rusu
      Alexandru Rusu about 3 years
      @kohjakob, check my answer below.
  • Alexandru Rusu
    Alexandru Rusu almost 3 years
    In my case I used the terminal to build, by running flutter run. I already posted an answer down below.
  • capdev
    capdev almost 3 years
    okay , i got same question other day , and cause i open "Runner.xcworkspace" in xcode
  • Sandz
    Sandz about 2 years
    Any solution to this?? I opened Runner.xcworkspace...but still get this issue