8

I am working on a flutter app. I recently shifted to macOS and since then haven't been able to run the app. Other apps are running fine so I think the error is in within the code of this app. And maybe because of this same reason I am unable to make a build.

Here is the output of flutter doctor:

[✓] Flutter (Channel stable, 1.20.1, on Mac OS X 10.15.6 19G73, locale en-US)
    • Flutter version 1.20.1 at /Users/bhawna/dev/flutter
    • Framework revision 2ae34518b8 (4 days ago), 2020-08-05 19:53:19 -0700
    • Engine revision c8e3b94853
    • Dart version 2.9.0

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, set ANDROID_SDK_ROOT to that location.
      You may also want to add it to your PATH environment variable.


 
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.6, Build version 11E708
    • CocoaPods version 1.9.3

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] VS Code (version 1.47.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.13.2

 
[✓] Connected device (1 available)            
    • iPhone 8 (mobile) • 3D03BDE4-F1A6-45AB-B095-01107CDDC2CD • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-6 (simulator)

Output of flutter run:

Running "flutter pub get" in delivero...                            1.6s
Launching lib/main.dart on iPhone 8 in debug mode...
 
Running pod install...                                             38.2s
Running Xcode build...                                                  
                                                   
Xcode build done.                                           449.0s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **


Xcode's output:
↳
    /Users/bhawna/dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inapp_purchase-2.2.0/ios/Classes/FlutterInappPurchasePlugin.
    m:45:52: warning: assigning to 'id<IAPPromotionObserverDelegate>' from incompatible type 'FlutterInappPurchasePlugin *__strong'
        [IAPPromotionObserver sharedObserver].delegate = self;
                                                       ^ ~~~~
    /Users/bhawna/dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inapp_purchase-2.2.0/ios/Classes/FlutterInappPurchasePlugin.
    m:200:79: warning: implicit conversion loses integer precision: 'SKPaymentTransactionState' (aka 'enum
    SKPaymentTransactionState') to 'int' [-Wshorten-64-to-32]
                                                         [NSNumber numberWithInt: item.transactionState], @"transactionStateIOS",
                                                         ~                        ^~~~~~~~~~~~~~~~~~~~~
    /Users/bhawna/dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inapp_purchase-2.2.0/ios/Classes/FlutterInappPurchasePlugin.
    m:586:71: warning: implicit conversion loses integer precision: 'SKPaymentTransactionState' (aka 'enum
    SKPaymentTransactionState') to 'int' [-Wshorten-64-to-32]
                                                 [NSNumber numberWithInt: transaction.transactionState], @"transactionStateIOS",
                                                 ~                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    3 warnings generated.
    /Users/bhawna/dev/flutter/.pub-cache/hosted/pub.dartlang.org/contacts_service-0.3.10/ios/Classes/ContactsServicePlugin.m:6:4:
    warning: 'SwiftContactsServicePlugin' is only available on iOS 9.0 or newer [-Wunguarded-availability]
      [SwiftContactsServicePlugin registerWithRegistrar:registrar];
       ^~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from
    /Users/bhawna/dev/flutter/.pub-cache/hosted/pub.dartlang.org/contacts_service-0.3.10/ios/Classes/ContactsServicePlugin.m:2:
    /Users/bhawna/delivero/delivero/build/ios/Debug-iphonesimulator/contacts_service/contacts_service.framework/Headers/contacts_serv
    ice-Swift.h:213:12: note: 'SwiftContactsServicePlugin' has been marked as being introduced in iOS 9.0 here, but the deployment
    target is iOS 8.0.0
    @interface SwiftContactsServicePlugin : NSObject <FlutterPlugin>
               ^
    /Users/bhawna/dev/flutter/.pub-cache/hosted/pub.dartlang.org/contacts_service-0.3.10/ios/Classes/ContactsServicePlugin.m:6:4:
    note: enclose 'SwiftContactsServicePlugin' in an @available check to silence this warning
      [SwiftContactsServicePlugin registerWithRegistrar:registrar];
       ^~~~~~~~~~~~~~~~~~~~~~~~~~
    1 warning generated.
    /Users/bhawna/dev/flutter/packages/flutter_tools/bin/xcode_backend.sh: line 13: pushd: /Users/hrvoje/Documents/Delivero
    Files/contactsFeature: No such file or directory
    Command PhaseScriptExecution failed with a nonzero exit code
    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 8.

Any help would be great. Thanks for your time.

Bhawna Saroha
  • 603
  • 1
  • 11
  • 28

13 Answers13

13

Simple Commands that made my archive successful after 2 days of struggle:

flutter clean
flutter pub get
flutter pub upgrade
cd iOS
pod install
pod update 

And the issue is resolved.

julemand101
  • 28,470
  • 5
  • 52
  • 48
Maqsood
  • 807
  • 3
  • 14
9

You won't believe it, but in my case the problem was caused by a corrupted image that was used to generate the launcher icons. Something with the alpha channel was messed up. After I fixed it, the product could be archived successfully.

Jeff S.
  • 888
  • 12
  • 17
  • can you elaborate more on how you fixed this pleas?? – JayVDiyk May 28 '21 at 13:19
  • I opened the original image in Gimp, removed the alpha channel and exported the image as png. This new image could be successfully used to generate launcher icons and the product archiving went through successfully. – Jeff S. Jul 01 '21 at 07:53
  • 3
    This is unbelievable. I replaced in my flutter assets a jpg with a png, and started getting this build error. Tried every possible thing for an hour, until I found this response, put that jpg back, and now everything works. I cannot understand how such a small change can break the build so badly, without any extra information. – Babao Aug 29 '21 at 16:40
  • I'm totally feeling you buddy... One could create an Xcode issue, but they probably need a minimal test project to reproduce this error. – Jeff S. Aug 31 '21 at 13:11
  • 2
    My god!! This!!! I saw this comment and thought "surely that can't be it. Everything was working fine before migrating to null safety," but after WEEKS of being stuck it turned out to be this. Here's how I found the culprit(s): Flutter Clean - Comment out all image assets in pubspec - flutter pub get. Run App. At this point, my app started working again. Then, one by one, uncomment an image asset - flutter pub get - run the app. I had two PNG's that caused an issue. I simply opened them in Photoshop and resaved them as PNGs and it worked. – Eric Duffett Oct 07 '21 at 02:09
  • This is mind-blowing. I had a rogue SVG that broke my build. I was unable to find the right settings in Illustrator to save it in a way that it would work, but saving with Sketch fixed it... – jeppeb Jan 28 '22 at 11:42
  • 1
    OMG! I can't believe this was it. Wasted entire 2 days and read this comment earlier, but I thought "no, this can't be it". I revisited again, removed newly added images and voila - it worked. This should be the accepted answer – mike Feb 13 '22 at 18:19
1

In the migration try replacing the podfile with this:

https://github.com/jmagman/flutter/blob/40b21e52153e1246120e90d1c757c0ec4c34ebb0/dev/integration_tests/flutter_driver_screenshot_test/ios/Podfile

Steps:

  1. Remove PodFile.lock
  2. Replace Podfile
  3. flutter clean
  4. flutter pub get
  5. cd ios /
  6. pod install
  7. pod update
  8. relaunch

Now apparently it is an error generated by the automatic processes of the 1.20 of the flutter SDK. In my case, I removed all the plugins from my project and started placing them one by one.

In my project the error appeared because I had the plugin flutter_dotenv 2.1.0 and the .env files corrupt the automatic flutter process.

1

For me this error occurred because of low disc space. as I cleaned some of files and it worked

CHP
  • 192
  • 6
  • This was the issue for me, thanks! Btw, a convenient way to clean up some space is to go Apple Symbol -> About This Mac -> Storage -> Manage... Under Developer there are usually multiple gigabytes to free up. – lastant Aug 26 '22 at 00:44
0
  1. Delete podfile.lock
  2. Ios>pod install
  3. flutter clean
  4. flutter run
Johny Saini
  • 879
  • 1
  • 5
  • 6
0

Check your image assets!

I spent days on this, upgraded flutter, upgraded Xcode, re-installed Xcode command line tools, and did every conceivable combination of flutter clean, flutter pub upgrade, pod install etc. I even used flutter create to regenerate the ios folder.

I searched for responses related to Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore because that was part of the Xcode error output, but in the end it was none of that.

I had recently added a new .png asset to my project and that was the problem. I converted it to .jpeg and the problem disappeared.

nsc211
  • 51
  • 1
  • 2
0

I was getting the Command PhaseScriptExecution failed error without any other details after upgrading Flutter from version 1.22.4 to 3.0.5 (and all dependencies to null-safety versions). MacOS 12.5, XCode 13.4.1.

My solution:

  1. Delete the ios folder.
  2. Run flutter create . from root project folder.
  3. Remove unnecessary platform support that you don't need, I mean deleting e.g. the windows and linux folders.
  4. Run the app just to confirm that the build is working now.
  5. With your version control discard changes that you didn't expect (those outside ios folder): reset assets icons, set back your original bundle id, bundle display name, etc.
  6. In the Xcode set back any "capabilities" that your app had (e.g. Push Notifications) and files added to Runner (e.g. GoogleService-Info.plist required by Firebase).
  7. Test your app, check logs, and you're done!

Because of some dependency I also had to update iOS version in the Podfile: platform :ios, '11.0'

Changes observerd after recreating the project:

  1. In the ios/Podfile:
  • The use_modular_headers! from the top of file was removed

  • These 2 lines were added inside target 'Runner' do section:

    use_frameworks!
    use_modular_headers!
    
  1. The ios/Flutter/AppFrameworkInfo.plist file was added, which was completely missing before.

  2. Changes inside Info.plist:

  • MARKETING_VERSION value was replaced with FLUTTER_BUILD_NAME and CURRENT_PROJECT_VERSION with FLUTTER_BUILD_NUMBER

  • The following entry was added: <key>CADisableMinimumFrameDurationOnPhone</key><true/>

  1. These files were modified: ios/Runner.xcodeproj/project.pbxproj and ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

I don't know which of these changes made it working again, but you can try selectively some of them before you recreate the ios project from scratch.

Derek K
  • 2,756
  • 1
  • 21
  • 37
0

TL;DR Try updating Flutter flutter upgrade

I had this error a few times and always try the flutter clean, flutter pub get...etc but it doesn't work, also try restarting laptop, deleting recently added assets (as some other comments suggest) but none of it works.

Then I remember how I fixed it the last time by updating Flutter, and it has just worked for me again so definitely worth a try!

MrHarvey
  • 192
  • 2
  • 2
  • 16
0

Step:

  • Remove PodFile.lock
  • Remove GeneratedPluginRegistrant.h
  • Remove GeneratedPluginRegistrant.m
  • Replace podfile
  • flutter clean
  • flutter pub get
  • cd ios /
  • pod install
  • pod update (Use this command when you get an error in pod install)
  • relaunch
0

In my case,I got the same error when I am trying to setup flutter and run app in macbook with Apple Chip.

Flutter app ran in chrome browser but didnt work in Android emulator. I found that I had to install to rosetta.

sudo softwareupdate --install-rosetta --agree-to-license

It was also mentioned in documentation here,but somehow I got to missed that thing while setup.

Gowtham K K
  • 3,123
  • 1
  • 11
  • 29
0

In my case, syntax error for the run script created issue. Script has to be like this: "${PODS_ROOT}/FirebaseCrashlytics/run". Double quotes needed. Without quotes, so many issues in debug and release mode.

Vipin Krishna
  • 355
  • 1
  • 4
  • 25
-1

Sometimes happen when you have this import 'dart:html'; and run the app in IOS.

Javier Garcia
  • 188
  • 1
  • 2
  • 10
-1
  1. Delete Run Binary from Build Phases.
  2. Delete Thin Binary from Build Phases.
shubh14896
  • 156
  • 1
  • 12