Flutter gets stuck on "Running Xcode build... " when building for iOS - ios

I have an existing Flutter project which has been working fine for two years. But now all of a sudden, when I try to build or run it on iOS, it always gets stuck on Running Xcode build... .
flutter build ios --debug
Running "flutter pub get" in MyApp... 0.6s
Building org.example.myapp for device (ios)...
Automatically signing iOS for device deployment using specified development team in Xcode project: 36U5A9XK2Z
Running pod install... 1.6s
Running Xcode build...
(This is taking an unexpectedly long time.) ⣻
Before this would only take 1-2 minutes, and now I've tried waiting up to 2 hours, so obviously something is very wrong. Other existing apps build just fine.
I have tried "the usual suspects":
flutter clean.
Delete ~/Library/Developer/XCode/DerivedData.
Restart the computer.
Delete podfile.lockand run pod install again.
Removed some "difficult" plugins (i.e. everything Firebase-related and all Swift-based plugins).
Nothing seems to help. Same thing happens if I try to run the app from within XCode or IntelliJ. Version info below.
Flutter 1.22.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7891006299 (7 weeks ago) • 2020-12-10 11:54:40 -0800
Engine • revision ae90085a84
Tools • Dart 2.10.4```
XCode 11.1
OSx 10.15.1

You could try deleting the ios folder on the project and generate an iOS build again by running flutter create --platforms=ios [PROJECT_PATH]. That should generate an iOS project from your Flutter code. After that, you could try running flutter build ios again.

Related

flutter app runs on Android simulator but not iOS simulator

I am running a flutter app on the Android simulator successfully but when I run it on the iOS simulator the app opens to a white screen then crashes.
I have done all of the following about 10 times each.
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
sudo xcodebuild -license
flutter update
flutter clean
xcode clean build folder
flutter build ios
flutter run
Remove the Pods folder and Podfile.lock files.
cd ios
pod deintegrate
cd ..
flutter clean
flutter build ios
Xcode 12.5.1
I also made sure Xcode Signing & Capabilities were set. I also stopped and removed all antivirus software.
It doesn't work by running debug and running via terminal ( flutter run --enable-software-rendering ) doesn't show any errors.
UPDATE:
Deleted the iOS folder and tried to run flutter create and now getting.
"No option specified for the output directory"
flutter create doesn't work.
Got the above flutter create working and now the app won't install on the Android device at all, where as it was working before flutter create was run (suggested below). Added memory and wiped Android simulator and still won't install on Android saying not enough memory. Deleting the ios folder and running "flutter create" was a disaster.
Rolling back to original code. Still stuck on not installing on iOS. It has to be something with Xcode.

Error says cocoapods is not installed after installation

I get this error when I try to run my flutter app on Macbook Pro:
Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
Warning: CocoaPods not installed. Skipping pod install.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install:
sudo gem install cocoapods
CocoaPods not installed or not in valid state.
Error launching application on iPhone 12 Pro Max.
This is my first attempt to run this app on a mac. I have installed cocoapods and the simulator I have is iPhone 12 Pro Max - 14.3. I am doing this in Android Studio.
I am new to macs and this has been a lengthy task trying to get this to run on mac. Any suggestions?
Run pod update in your pod file and clean the flutter project and try to run
command for pod update
pod update
command for flutter clean
flutter clean

Not able to build for IOS after flutter upgrade to 1.20.2

I am facing the issue after upgrading to stable flutter version 1.20.2. I am not able to run on IOS. when I start debugging I get this error.
Xcode build done. 48.6s
Failed to build iOS app
Exited (sigterm)
Could not build the application for the simulator.
flutter run -v
Before that, I was on flutter 1.17.5 and everything was working. It is happening on all of my projects. How to resolve?
It happens to me also after Upgrading flutter, My project does not work.Then i create new project and copy paste previous code in new projects.This works for me because previous projects have old dependencies.Try it

How to fix Command PhaseScriptExecution failed with a nonzero exit code on flutter run in macOS?

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.
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.
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.
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:
Remove PodFile.lock
Replace Podfile
flutter clean
flutter pub get
cd ios /
pod install
pod update
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.
For me this error occurred because of low disc space. as I cleaned some of files and it worked
Delete podfile.lock
Ios>pod install
flutter clean
flutter run
Sometimes happen when you have this import 'dart:html'; and run the app in IOS.
Delete Run Binary from Build Phases.
Delete Thin Binary from Build Phases.
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.
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:
Delete the ios folder.
Run flutter create . from root project folder.
Remove unnecessary platform support that you don't need, I mean deleting e.g. the windows and linux folders.
Run the app just to confirm that the build is working now.
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.
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).
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:
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!
The ios/Flutter/AppFrameworkInfo.plist file was added, which was completely missing before.
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/>
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.
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!
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
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.
The only thing that worked for me was to backup my project and clone a fresh copy from the repository. I suspect it was an issue with one of the hidden files or folders like .symlinks or Pods.

Flutter iOS build is stuck on "Running Xcode Build"

I recently got a mac to be able to test the iOS applications I made with Flutter/Dart. But when trying to transfer all my files to a Mac and try to test it, it gets on "Running Xcode Build."
I am importing 2 things in my pubspec.yaml file:
dependicies:
flutter:
sdk:
cupertino_icons: ^0.1.2
firebase_admob: ^0.9.0+10
In my podfile, which I was told to download on the google admobs documentation I have
pod 'Google-Mobile_Ads_SDK"
My Flutter Doctors reads:
[flutter] flutter doctor -v
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-US)
• Flutter version 1.12.13+hotfix.5 at /Users/priscilla/Desktop/Temp/flutter
• Framework revision 27321ebbad (5 weeks ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/priscilla/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /usr/bin/java
✗ Could not determine java version
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C504
• CocoaPods version 1.8.4
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/setup/#android-setup for detailed instructions).
[✓] Connected device (1 available)
• iPhone 11 Pro Max • 754DF0BD-203E-4A0A-B785-E92D4B1D9C38 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)
! Doctor found issues in 2 categories.
And the change to my info.plist is: (The actual app ID is in my code, just didn't want to post it here)
<key>GADApplicationIdentifier</key>
<string>[APP_ID]</string>
If I were to create a new Flutter project from scratch, the given code runs perfectly fine. It is just when I try to import the files the project on my windows PC to my Mac.
I think a solution would be to create a new Flutter project and while creating import my files, but I am not sure how to do that. So at the moment, I created a new Flutter project, deleted all the files that comes loaded initially, then replaced them with my project files.
in my case, I use Firebase Firestore.
it doesn't stuck actually, but it takes waaaay too long to build in Xcode. don't forget to improve iOS build times as per the official documentation in here (don't forget to pick Dart Flutter as the language), and then scroll to find the optional section about how to Improve iOS & macOS build times by including the pre-compiled framework.
Currently, the Firestore SDK for iOS depends on code that can take
upwards of 5 minutes to build in Xcode. To reduce build times
significantly, you can use a pre-compiled version by adding this line
to the target 'Runner' do block in your Podfile:
please open that documentation to improve the build time, because the code maybe updated.
the code will be like this
target 'Runner' do
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => 'x.xx.x'
# ...
end
after adding that 1 line on your iOS podfile, don't forget to do flutter clean before rebuild the project. the second time you build the project it should be faster
NOTE:
if there is an error, then please ensure the tag in pod :tag => 'X.X.X' from the code in documentation is suitable with your cloud_firestore package version. sometimes the official documentation is not updated like the issue in here
I had removed the external devices specifically external monitors attached to Mac.
Then made the build.
My build time came from 10min on average to 0.5 to 2 min max.
iOS(Build) IPA building was taking around 14456.14 Sec i.e (more than 4 hrs) after updating to the below version it was reduced to 2143.3 Sec i.e. (less than 40 mins)
Changed From:
environment:
sdk: ">=2.7.0 <3.0.0"
Changes To:
environment:
sdk: '>=2.12.0 <3.0.0'
Change the whole project to Null-safety
Please follow https://dart.dev/null-safety/migration-guide
In My Experience, this first build indeed takes a long time - but after you run it once - the build time is reasonable.
If your build is stuck on Running Xcode build..., try the solution below:
cd Project Folder >
rm -R build
rm .dart_tool
rm .packages
rm -Rf ios/Pods
rm -Rf ios/.symlinks
rm -Rf ios/Flutter/Flutter.framework
rm -Rf ios/Flutter/Flutter.podspec
pod cache clean --all
cd ios > pod deintegrate
pod setup
arch -x86_64 pod install
cd ..
flutter clean -v
flutter pub get
flutter clean && flutter run
If the above fails, clone the project again and flutter run.

Resources