Flutter IOS xcodebuild: WARNING: Using the first of multiple matching destinations: - ios

When I run the project directly in xcode 13 everything works fine, but when compiling with flutter run I get this error, I already tried deleting the DerivedData files.
Lock the password keychain.
Deleting the Pods and all their files.
Deleting the WorkSpace.
But nothing turns out to be useful, I am from a mac m1 with Monterrey operating system, I would like to know if someone has a possible solution for this error that I have seen so recurrent

Try following by running on specific device:
step1:- Run flutter devices, You will get list of devices connected. like this.
2 connected devices:
Redmi 4 • 81cea4a7d740 • android-arm64 • Android 7.1.2 (API
25)
Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28)
(emulator),
step2:- f you want to run in a specific device Run flutter run -d Device name or Device id
eg:- flutter run -d Redmi or flutter run -d 81cea4a7d740,
step3:- If you want to run in all devices than flutter run -d all.

Related

Error (Xcode): 'Flutter/Flutter.h' file not found /Users/macbook/Developer/RobyHub/mobile/admin-app/ios/Runner/GeneratedPluginRegistrant.h:9:8

Error (Xcode): 'Flutter/Flutter.h' file not found
/Users/macbook/Developer/RobyHub/mobile/admin-app/ios/Runner/GeneratedPluginRegistrant.h:9:8
Error (Xcode): failed to emit precompiled header
'/Users/macbook/Library/Developer/Xcode/DerivedData/Runner-cnmmmgwjwyedhrfbmwidyiqajgcy/Build/Intermediates.noindex/PrecompiledH
eaders/Runner-Bridging-Header-swift_21KKX35XMXJF3-clang_2DSDA8C9CPQUA.pch' for bridging header
'/Users/macbook/Developer/RobyHub/mobile/admin-app/ios/Runner/Runner-Bridging-Header.h'
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.8, on macOS 13.0 22A380 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.73.1)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
Could not build the application for the simulator.
Error launching application on iPhone 14 Pro.
I started encoutering these errors, ever since i archived my application and uploaded it on my apple store connect, the reaseon i decided to build again was just to screenshot screen of my applications for review on my app store connect.
I validated and distributed my app without any furtheer issues.
Any solution would be appreeciated, please
I've tried everything from
flutter clean
pod install
i've deleted the pod file and lock file
Done pod update
flutter run
Tried these several times, my issue still persists.
After attempting several fixes, what solved this for me was by restarting my pc
First make sure to close your xcode or visual studio
Upon restart completion, open VScode again, then open terminal in vscode and cd to ios folder on your flutter application code, and run the following:
pod cache clean --all
after which run:
pod install
Once completed go back to your main flutter directory using
cd ../
Then run:
flutter build ios
flutter run

Why my Flutter app not running on iPhone?

I successfully run my app on simulator(iPhone 12, iOS 14.5), but when it running on real iPhone 11 Pro Max(iOS 14.7.1) I facing just a black screen. Here is the output from Xcode:
2021-09-16 18:48:00.155232+0300 Runner[2396:1009680] Metal API Validation Enabled
2021-09-16 18:48:00.244991+0300 Runner[2396:1009680] Could not load the "LaunchImage" image referenced from a nib in the bundle with identifier "xxx.yyy.zzz"
2021-09-16 18:48:00.353909+0300 Runner[2396:1009946] [VERBOSE-2:shell.cc(93)] Dart Error: Can't load Kernel binary: Invalid kernel binary format version.
2021-09-16 18:48:00.354015+0300 Runner[2396:1009946] [VERBOSE-2:dart_isolate.cc(170)] Could not prepare isolate.
2021-09-16 18:48:00.354185+0300 Runner[2396:1009946] [VERBOSE-2:runtime_controller.cc(382)] Could not create root isolate.
2021-09-16 18:48:00.354213+0300 Runner[2396:1009946] [VERBOSE-2:shell.cc(576)] Could not launch engine with configuration.
2021-09-16 18:48:00.367242+0300 Runner[2396:1009960] flutter: Observatory listening on http://127.0.0.1:54273/PrvtvZOQ8Wc=/
Flutter doctor:
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.2 20G95 darwin-x64, locale
ru-BY)
[✗] 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, please use
flutter config --android-sdk to update to that location.
[✓] Xcode - develop for iOS and macOS
[✗] Chrome - develop for the web (Cannot find Chrome executable at
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[!] Android Studio (not installed)
[✓] Connected device (2 available)
Xcode 12.5.1
UPDATED
To fix this, remove run rm -rf ~/flutter/bin/cache. Then run flutter run (you should run your app from terminal instead of IDE in order to Flutter download missing files). It's somehow works now.
Deleting the cache using rm -rf ~/flutter/bin/cache worked for me. This issue seems to have been caused by a bad Flutter installation. Running flutter pub get after deleting the cache should download the packages again and rebuild the project.

Flutter gets stuck on "Running Xcode build... " when building for 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.

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.

Flutter - Command line - Emulator- Device not found

Disclaimer - Newbie
Just DL everything needed to get started with Flutter on my Windows 10 pc.
Flutter sdk -saved to a folder on my desktop
Git Google USB Driver
Visual Studio Code and its Flutter/Dart plug-ins
Android Studio and its Flutter/Dart plug-ins
Now I can start up Android Studio and pick an emulator (by default "no device connected" shows), hit run and the emulator works but if I go to my command line here is what I get and I followed it up with 'flutter emulators' 'flutter doctor'
When I tell it to check for emulators it tells me "To run an emulator, run 'flutter emulators --launch '"
Where do i find the ID?
C:\Users\admin\Desktop\Computer Science\Flutter Projects\first_app>flutter
run
No connected devices.
C:\Users\admin\Desktop\Computer Science\Flutter Projects\first_app>flutter
emulators
2 available emulators:
Nexus_5X_API_28_x86 • Nexus 5X • Google • Nexus 5X API 28 x86
Nexus_6P • Nexus 6P • Google • Nexus 6P
To run an emulator, run 'flutter emulators --launch <emulator id>'.
To create a new emulator, run 'flutter emulators --create [--name xyz]'.
You can find more information on managing emulators at the links below:
https://developer.android.com/studio/run/managing-avds
https://developer.android.com/studio/command-line/avdmanager
C:\Users\admin\Desktop\Computer Science\Flutter Projects\first_app>flutter
doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.8.2, on Microsoft Windows [Version
10.0.17134.285], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[√] Android Studio (version 3.2)
[√] VS Code (version 1.27.2)
[!] Connected devices
! No devices available
! Doctor found issues in 1 category.
Try this to start your emulator then you will se connected devices.
Once you have running emulator try running flutter app.
Right now you dont have any emulator running thays why its telling you No connected devices...
flutter emulators --launch Nexus_6P
Step 1: Go to the project folder in which you have created the flutter project in cmd (using cd Root/of/your/project)
Step 2: Run the following commands:
flutter emulators --create <whateverIdYouLike>
(Eg:- For my project I used `flutter emulators --create Nexus_6`)
This should give you the message:
"Emulator [Name] created successfully.'
Step 3: Type in the following command:
flutter emulators
You will see an emulator has been added successfully.
Step 4: Launch the emulator using the following command:
flutter emulators --launch <emulator id> //in my case, the id of the newly created emulator was "flutter_emulator"
For further info check
https://developer.android.com/studio/run/managing-avds
https://developer.android.com/studio/command-line/avdmanager
If you want to run app in your connect device through flutter, then first get the device name or id by typing
flutter devices
It will give you info
And run the app by running this command
Try to install Vysor on your system then connect it with mobile through USB cable now the mobile screen will be mirrored on the system, and will act as emulator.

Resources