1

I have a project that runs on android but fails on IOS. I can't understand how to debug the problem. I am using Mac m1.

Here is flutter doctor -v:

[✓] Flutter (Channel stable, 1.22.6, on macOS 11.2.2 20D80 darwin-arm, locale en-IN) • Flutter version 1.22.6 at /Users/prashantpandey/Desktop/programming/flutterhome/flutter • Framework revision 9b2d32b605 (7 weeks ago), 2021-01-22 14:36:39 -0800 • Engine revision 2f0af37152 • Dart version 2.10.5

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/prashantpandey/Library/Android/sdk • Platform android-30, build-tools 30.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.4) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.4, Build version 12D4e • CocoaPods version 1.10.1

[!] Android Studio (version 4.1) • Android Studio at /Applications/Android Studio.app/Contents ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] Connected device (1 available) • iPhone 12 Pro Max (mobile) • 4B755BC3-6207-4FB8-96EE-C5C2F23453CA • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)

Here is the debug console:

    Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
Xcode build done.                                            7.3s
Failed to build iOS app
Error output from Xcode build:
↳
    objc[2470]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x1f81ec188) and ?? (0x11668c2b8). One of the two will be used. Which one is undefined.
    objc[2470]: Class AMSupportURLSession is implemented in both ?? (0x1f81ec1d8) and ?? (0x11668c308). One of the two will be used. Which one is undefined.
    ** BUILD FAILED **
Xcode's output:
↳
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_audio_recorder-0.5.5/ios/Classes/SwiftFlutterAudioRecorderPlugin.swift:72:123: error: type 'AVAudioSession.Category' (aka 'NSString') has no member 'playAndRecord'
                    try AVAudioSession.sharedInstance().setCategory(convertFromAVAudioSessionCategory(AVAudioSession.Category.playAndRecord), with: AVAudioSessionCategoryOptions.defaultToSpeaker)
                                                                                                      ~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_audio_recorder-0.5.5/ios/Classes/SwiftFlutterAudioRecorderPlugin.swift:160:58: error: function produces expected type 'AVAudioSessionRecordPermission'; did you mean to call it with '()'?
                permission = AVAudioSession.sharedInstance().recordPermission
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
                                                                             ()
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_audio_recorder-0.5.5/ios/Classes/SwiftFlutterAudioRecorderPlugin.swift:215:15: error: value of type 'AVAudioSession.Category' (aka 'NSString') has no member 'rawValue'
            return input.rawValue
                   ~~~~~ ^~~~~~~~
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/FlutterWebViewController.swift:107:34: warning: 'keyWindow' was deprecated in iOS 13.0: Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes
                UIApplication.shared.keyWindow!.insertSubview(self.myView!, at: 0)
                                     ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/InAppBrowserManager.swift:91:64: warning: 'statusBarStyle' was deprecated in iOS 13.0: Use the statusBarManager property of the window scene instead.
                self.previousStatusBarStyle = UIApplication.shared.statusBarStyle.rawValue
                                                                   ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/InAppBrowserManager.swift:98:52: warning: 'keyWindow' was deprecated in iOS 13.0: Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes
            let baseWindowLevel = UIApplication.shared.keyWindow?.windowLevel
                                                       ^
    Command CompileSwift failed with a nonzero exit code
    Command CompileSwift failed with a nonzero exit code
    Command CompileSwift failed with a nonzero exit code
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/InAppWebViewOptions.swift:79:74: warning: 'javaScriptEnabled' was deprecated in iOS 14.0: Use WKWebPagePreferences.allowsContentJavaScript to disable content JavaScript on a per-navigation basis
                realOptions["javaScriptEnabled"] = configuration.preferences.javaScriptEnabled
                                                                             ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/MyCookieManager.swift:120:16: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
                if #available(iOS 13.0, *) {
                   ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/MyCookieManager.swift:12:7: note: enclosing scope here
    class MyCookieManager: NSObject, FlutterPlugin {
          ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/MyCookieManager.swift:149:24: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
                        if #available(iOS 13.0, *) {
                           ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/MyCookieManager.swift:12:7: note: enclosing scope here
    class MyCookieManager: NSObject, FlutterPlugin {
          ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariBrowserOptions.swift:29:16: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
                if #available(iOS 11.0, *) {
                   ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariBrowserOptions.swift:12:14: note: enclosing scope here
    public class SafariBrowserOptions: Options<SafariViewController> {
                 ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:58:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
            if #available(iOS 11.0, *) {
               ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:12:14: note: enclosing scope here
    public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate {
                 ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:62:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
            if #available(iOS 10.0, *) {
               ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:12:14: note: enclosing scope here
    public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate {
                 ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:58:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
            if #available(iOS 11.0, *) {
               ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:12:14: note: enclosing scope here
    public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate {
                 ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:62:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
            if #available(iOS 10.0, *) {
               ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:12:14: note: enclosing scope here
    public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate {
                 ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:162:17: warning: 'scanHexInt32' was deprecated in iOS 13.0
            scanner.scanHexInt32(&hexInt)
                    ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariBrowserOptions.swift:29:16: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
                if #available(iOS 11.0, *) {
                   ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariBrowserOptions.swift:12:14: note: enclosing scope here
    public class SafariBrowserOptions: Options<SafariViewController> {
                 ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:58:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
            if #available(iOS 11.0, *) {
               ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:12:14: note: enclosing scope here
    public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate {
                 ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:62:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
            if #available(iOS 10.0, *) {
               ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:12:14: note: enclosing scope here
    public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate {
                 ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:58:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
            if #available(iOS 11.0, *) {
               ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:12:14: note: enclosing scope here
    public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate {
                 ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:62:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
            if #available(iOS 10.0, *) {
               ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:12:14: note: enclosing scope here
    public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate {
                 ^
    /Users/prashantpandey/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-4.0.0+4/ios/Classes/SafariViewController.swift:162:17: warning: 'scanHexInt32' was deprecated in iOS 13.0
            scanner.scanHexInt32(&hexInt)
                    ^
    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 Pro Max.
Exited (sigterm)

This is pubspec.yaml

    dependencies:
  flutter:
    sdk: flutter
  # The following adds the Cupertino Icons font to your application.
  http: ^0.12.0+4
  carousel_slider: ^1.3.0
  provider: ^4.0.4
  image_picker: 0.6.7+7
  file_picker: ^1.5.0+2
  pdf: ^1.4.1
  fluttertoast: ^3.1.3
  cached_network_image: ^2.0.0
  razorpay_flutter: ^1.1.4
  flutter_pdfview: ^1.0.0+10
  firebase_messaging: ^6.0.12
  flutter_custom_clippers: ^1.0.0
  webview_flutter: ^0.3.22+1
  shared_preferences: ^0.5.6+3
  agora_rtc_engine: ^1.0.13
  permission_handler: ^3.0.0
  url_launcher: ^5.4.2
  share: ^0.6.3+6
  package_info: ^0.4.0+16
  device_id: ^0.2.0
  flutter_widgets: ^0.1.12
  google_fonts: ^0.2.0
  datetime_picker_formfield: ^1.0.0
  flutter_screen_recording: ^1.0.9  
  open_file: ^3.0.1
  flutter_inappwebview: ^4.0.0+4
  flutter_spinkit: "^4.1.2"
  flutter_webrtc: ^0.2.8
  random_string: ^2.1.0
  dynamic_theme: ^1.0.1
  flutter_statusbar_manager: ^2.0.0
  shimmer: ^1.1.1
  avatar_glow: ^1.2.0
  audioplayers: ^0.16.1
  flutter_linkify: ^3.1.3
  firebase_storage: ^4.0.1
  flutter_open_whatsapp: ^0.1.2
  flutter_audio_recorder: ^0.5.5
  bottom_navy_bar: ^5.4.0
  easy_localization: ^2.3.3
  video_player: ^1.0.1
  youtube_explode_dart: ^1.4.4
  youtube_player_flutter: 7.0.0+7
  youtube_player_iframe: ^1.2.0+2
  wakelock: ^0.2.1+1
  image: ^2.1.19

1 Answer 1

0

First of all make sure that your deployment target is same everywhere and for every pods you used like in my case i used 12.0 everywhere as my default development info. Here are few screen snips for your help:

enter image description here

enter image description here

Same deployment target you need to add for all the pod files added. I don't know if there is any one click way to change deployment target for all but for now i am doing it manually one by one.

As we know that m1 mac runs on arm based processor and thus few things like cocoa pods and ffi needs to be build based on that. After a long research i came up with few steps which will definitely help every-time you stuck with xcode flutter application build for m1 mac.

To install completely cocoapods on Mac with M1 chip (Apple Silicon), please follow those steps:

Cocoa Pods Installation in M1

  • sudo gem install cocoapods
  • sudo gem install ffi
  • arch -x86_64 sudo gem install cocoapods -n /usr/local/bin
  • sudo gem install cocoapods -n /usr/local/bin

Install ffi

  • sudo arch -x86_64 gem install ffi

#update repo

  • arch -x86_64 pod install --repo-update

Flutter iOS builds

  • flutter clean
  • flutter build ios

Re-install dependency in iOS folder of flutter project

  • arch -x86_64 pod install
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.