13

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?

Alexandru Rusu
  • 569
  • 1
  • 5
  • 21
  • make sure you have added `audio_session` package in `pubspec.yml` file. after then run the command `flutter pub get` and `flutter run` – Ranjit Shrestha Mar 18 '21 at 13:38
  • I don't use this package at all. I think somehow it is a dependency. – Alexandru Rusu Mar 18 '21 at 13:57
  • 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. – Alexandru Rusu Mar 18 '21 at 13:59
  • Running into the same problem. I'm using [just_audio](https://pub.dev/packages/just_audio/versions) which depends on `audio_session`. – kohjakob Mar 18 '21 at 15:50
  • Okay, I think my problem was opening `ios/Runner.xcodeproj ` instead of `ios/Runner.xcworkspace`. More on that [here](https://stackoverflow.com/a/63970985/13793197) – kohjakob Mar 18 '21 at 15:56
  • @kohjakob, check my answer below. – Alexandru Rusu Mar 19 '21 at 04:52

5 Answers5

14

You should

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

2 . everything going well

capdev
  • 257
  • 1
  • 7
5

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.

Alexandru Rusu
  • 569
  • 1
  • 5
  • 21
2

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

flutter clean
flutter pub get
flutter build ios

It worked for me.

Anirban Das
  • 1,035
  • 1
  • 18
  • 22
1

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

General Grievance
  • 4,555
  • 31
  • 31
  • 45
-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.
Kherel
  • 14,882
  • 5
  • 50
  • 80