Flutter: error Xcode: command PhaseScriptExecution failed with a nonzero exit code - ios

I tried to run flutter after updating to the newest stable version
Error output from Xcode build:
↳
** BUILD FAILED **
Xcodes output:
↳
Writing result bundle at path:
/var/folders/56/fc0b38hx7dv7ldxkbs9flh_m0000gn/T/flutter_tools.sDq2W5/flutter_ios_build_temp_dirGNvLvF/temporary_xcresult_bundle
/usr/local/Caskroom/flutter/2.5.2/flutter/.pub-cache/hosted/pub.dartlang.org/platform-3.0.0/lib/src/interface/local_platform.dart:46:19: Error: Member not
found: 'packageRoot'.
io.Platform.packageRoot; // ignore: deprecated_member_use
^^^^^^^^^^^
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in parallel
Result bundle written to path:
/var/folders/56/fc0b38hx7dv7ldxkbs9flh_m0000gn/T/flutter_tools.sDq2W5/flutter_ios_build_temp_dirGNvLvF/temporary_xcresult_bundle
Could not build the application for the simulator.
Error launching application on iPhone 13 Pro.
I've tried flutter clean and flutter pub get but that isn't the fix. Anyone any idea how to fix this?

As i see you are currently using flutter 2.5.2 which is newest,So Update you flutter SDK by running command
flutter upgrade
Then Upgrade the current package's dependencies to latest versions by running command
flutter pub upgrade
Go to iOS folder of the project run
pod init
and
pod install
I hope this solution solve your problem.
Please up the vote if this answer help you.

I spent way too much time on this issue.
For me the problem was related to the Flutter cache and running the following command resolved the issue:
flutter pub cache repair
The solution made sense to me when I noticed a plugin trying to reference [flutter-sdk-path]/flutter/packages/flutter/lib/screens.dart--which did not exist in my Flutter SDK.
Ref: Update flutter dependencies in /.pub-cache
Guys, sometimes it better to just GO TO SLEEP! It helps a great deal to have fresh eyes looking at a problem.

if you have Podfile in iOS folder
Go to iOS folder of the project
run
flutter clean
and
flutter pub get
and
pod update

Related

Codemagic build process for a Flutter app: Could not find a file named "pubspec.yaml"

I am using Codemagic for the iOS build process for a Flutter app.
In the pubspec.yaml I am referring to a package dependency by pointing to a public repository like so:
dependencies:
flutter:
sdk: flutter
flutter_circular_slider:
git: https://github.com/tomoehlrich/flutter-circular-slider.git
It all works with local debugging and when building an apk with "flutter build apk" on Windows.
Codemagic though keeps giving me the following error message in the build step "Installing dependencies":
== Install Flutter dependencies ==
> flutter packages pub get
Resolving dependencies...
Could not find a file named "pubspec.yaml" in https://github.com/tomoehlrich/flutter-circular-slider.git 5d6d0c54e93766b27d30707bf20042b26894561c.pub
finished with exit code 1
Build failed :|Failed to install dependencies
I had Codemagic working before. The difference now to the working version was that I was referencing a different repository on Github.
I am trying to figure out why the build process cannot find the pubspec.yaml in https://github.com/tomoehlrich/flutter-circular-slider.git but in another fork of the same flutter package on Github.
Any hints are highly appreciated.
It seems that "resolved-ref" in pubspec.lock for the slider package was an outdated reference.
A new generation of pubspec.lock, sync to GitHub and start a new build process in Codemagic did the trick.

module 'audio_session' not found

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?
You should
1 . open "Runner.xcworkspace" in xcode , Not "Runner.xcodeproj"
2 . everything going well
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:
Open finder -> Utilities
Right click on the Terminal -> Get Info
Check 'Open with Rosetta'
Open a new terminal and type 'gem uninstall cocoapods'
sudo gem install cocoapods
gem uninstall ffi
arch -x86_64 sudo gem install ffi
I hope this is useful for someone else.
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
Source: thanhbinh84
For me, it build succesfully after I ran flutter clean.
flutter clean
flutter pub get
flutter build ios
It worked for me.
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.

Kotlin Multiplatform Mobile unable to run on iOS: Execution failed for task ':shared:compileKotlinIosX64'

I have created fresh project(Hello World) in KMM followed by their official website. In android it works smooth but when I am trying to run in XCode it's giving errors because of which I am unable to build / run the xcode project. I have attached screenshots and logs for my errors. Somehow xcode scheme is not getting generated in the KMM platform that's what I am guessing.
Can anyone please help me understand what am I missing?
Any help would be appriciated.
Following is my dev env:
Xcode 11.4.1
Android 4.1.2
Kotling Plugin version 1.4.30 (stable)
KMM 0.2.0```
XCode Logs:
> Task :shared:compileKotlinIosX64
Downloading native dependencies (LLVM, sysroot etc). This is a one-time action performed only on the first run of the compiler.
Extracting dependency: /Users/fatin/.konan/cache/clang-llvm-apple-8.0.0-darwin-macos.tar.gz into /Users/fatin/.konan/dependencies
e: java.lang.RuntimeException: Cannot extract archive with dependency: /Users/fatin/.konan/cache/clang-llvm-apple-8.0.0-darwin-macos.tar.gz.
> Task :shared:compileKotlinIosX64 FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':shared:compileKotlinIosX64'.
> Compilation finished with errors
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 7s
1 actionable task: 1 executed
Command PhaseScriptExecution failed with a nonzero exit code ```
[![enter image description here][3]][3]
I reached out to community for this and finally found the solution. Here is the link to that issue which I raised and solved this problem.
If anyone else is going through this same issue it mostly cause of corrupted kotlin file.
Also try checking your cmd line tools in XCode as per comments.
Hope this helps someone. Cheers.
If the project doesn't run right away even on opening it from Xcode and shows the shared framework is missing, Then try generating the shared framework for iOS platform using terminal. Navigate to the project folder and execute
Command: ./gradlew packForXcode Now the shared framework should have a xcode-frameworks product and you should be able to build and run the project through Xcode.
This could happen if there are two libraries, where one library was compiled against the different version of the other library than the one currently used in the project. Please check that the project configuration is correct and has consistent versions of dependencies.

How to fix cocoa pods flutter bug?

I am trying to run several dependencies on my flutter project however end up always getting the same error while running the project on ios and the full terminal message looks like this:
Xcode's output:
↳
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
Debug.xcconfig line 1: Unable to find included file "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
Debug.xcconfig line 1: Unable to find included file "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
/Users/username/Desktop/flutter_test/xylophone/ios/Runner/GeneratedPluginRegistrant.m:6:9: fatal error: 'assets_audio_player/AssetsAudioPlayerPlugin.h' file not found
#import <assets_audio_player/AssetsAudioPlayerPlugin.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Could not build the application for the simulator.
Error launching application on iPhone X.
Launching lib/main.dart on iPhone X in debug mode...
Warning: CocoaPods not installed. Skipping pod install.
CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
For more info, see https://flutter.dev/platform-plugins
To install:
brew install cocoapods
pod setup
Xcode build done. 5.7s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Exited (sigterm)
This occurs with every dependency that I try to use from the flutter packages and I really don't know how to fix this. The process of installing cocoapods also doesn't work.
This has an existing GitHub issue. The error you've encountered was because the time you've installed cocoapods, it was installed with different version of ruby than you currently have active.
The recommended way to fix this is to to uninstall your existing cocoapods brew uninstall cocoapods and install a fresh one, via sudo gem install cocoapods.

Flutter - <Flutter/Flutter.h> not found when using the google_sign_in library

I am facing this issue while compiling the app for ios
this is the whole stacktrace:
Launching lib/main.dart on iPhone Xs Max in debug mode... Running pod
install... Running Xcode build... Xcode build done.
2,4s Failed to build iOS app Error output from Xcode build: ↳
** BUILD FAILED **
Xcode's output: ↳
=== BUILD TARGET FirebaseAuth OF PROJECT Pods WITH CONFIGURATION Debug ===
In file included from /Users/danielec/.pub-cache/hosted/pub.dartlang.org/google_sign_in-4.0.1+3/ios/Classes/GoogleSignInPlugin.m:5:
/Users/danielec/.pub-cache/hosted/pub.dartlang.org/google_sign_in-4.0.1+3/ios/Classes/GoogleSignInPlugin.h:5:9:
fatal error: 'Flutter/Flutter.h' file not found
#import
^~~~~~~~~~~~~~~~~~~
1 error generated.
I tried reinstalling both firebase_auth and google_sign_in, removing and reinstalling cocoapods, I don't know what else to do, as any one experienced this problem before?
Versions:
Cocoapods: 1.6.1
firebase_auth: ^0.8.4+5
google_sign_in: ^4.0.1+3
I had a similar issue, while using Flutter on the stable channel. While running on iOS simulator I started to get this error: /[pathto]/Flutter/testtwo/ios/Runner/GeneratedPluginRegistrant.h:8:9: fatal error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
The only thing that helped was to change the channel to beta (I actually tried to run there and it worked) and then back to stable but also pub upgrade. See below the sequence of commands. Note that after changing to a channel you need to wait to Flutter to do the build (it took several minutes for me):
flutter pub upgrade,
flutter channel beta,
flutter clean,
run app successfully... on iOS.
flutter channel stable,
flutter clean.
I hope it helps.
I had the same , I don't know what happened but my solution was :
Create a backup "iOS/Runner" plist is especially if you have some permissions or other thing stuff that..
After that in console write : flutter create .
.. that create one more time your iOS folder, apparently some files inside iOS are corrupter for some ¿bug?..
ahh too,, very important , open Xcode and not copy the file googleservices.json, you need take the file and put inside runner files (NO COPY!!)
don't forget flutter clean and restart invalid android studio.
good luck!
This is what worked for me.
Delete your .pubcache folder, you can find it where you installed flutter to (you can run "which flutter" if you are not sure where) it is usually a hidden file so you would have to enable your settings to show hidden files (shift + Command + full stop to show hidden files on Mac).
Run "flutter clean" in your terminal (ensure build folder is removed)
Delete symlinks, pods and podfile.lock from the ios folder
Delete your pubspec.lock file
Build again
If you are still having issues you can go further
Downgrade Flutter with "flutter downgrade"
flutter pub cache repair
delete Generated.xcconfig from ios/Flutter directory
pod install (from the ios directory)
build again

Resources