Flutter Xcode iOS 'Flutter/Flutter.h' file not found - android

I have Mac and use Android studio and Xcode, I got the following error messages when I tried to run my Flutter app or when I tried to do Build -> Build iOS
I tried most solution I found in web like: pod install or remove pods files,,, and another solutions but did not helped me, How to fix? thanks
Could not build the precompiled application for the device.
Error (Xcode): 'Flutter/Flutter.h' file not found
/Users/test/StudioProjects/app/ios/Runner/GeneratedPluginRegistrant.h:9:8
Error (Xcode): failed to emit precompiled header '/Users/test/Library/Developer/Xcode/DerivedData/Runner-dmjvwbvrfekhkvanzgfshfxgayly/Build/Intermediates.noindex/PrecompiledHeaders/Runner-Bridging-Header-swift_3KZJBW1LQ4BLG-clang_3S6LL1PRJK0WS.pch' for bridging header '/Users/test/StudioProjects/app/ios/Runner/Runner-Bridging-Header.h'
Error launching application
And Flutter doctor here:
/Users/test/Downloads/flutter/bin/flutter doctor --verbose
[✓] Flutter (Channel stable, 2.10.1, on macOS 12.2.1 21D62 darwin-x64, locale sv-SE)
• Flutter version 2.10.1 at /Users/test/Downloads/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision db747aa133 (5 days ago), 2022-02-09 13:57:35 -0600
• Engine revision ab46186b24
• Dart version 2.16.1
• DevTools version 2.9.2
[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /Users/test/Library/Android/sdk
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✗] 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 (version 2021.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
[!] Connected device
! No devices available
[✓] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 3 categories.
Process finished with exit code 0
Flutter -v
Manage your Flutter app development.
Common commands:
flutter create <output directory>
Create a new Flutter project in the specified directory.
flutter run [options]
Run your Flutter application on an attached device or in an emulator.
Usage: flutter <command> [arguments]
Global options:
-h, --help Print this usage information.
-v, --verbose Noisy logging, including all shell commands executed.
If used with "--help", shows hidden options. If used with "flutter doctor", shows additional diagnostic information. (Use "-vv" to force
verbose logging in those cases.)
--prefixed-errors Causes lines sent to stderr to be prefixed with "ERROR:".
--quiet Reduce the amount of output from some commands.
--[no-]wrap Toggles output word wrapping, regardless of whether or not the output is a terminal.
(defaults to on)
--wrap-column Sets the output wrap column. If not set, uses the width of the terminal. No wrapping occurs if not writing to a terminal. Use "--no-wrap" to
turn off wrapping when connected to a terminal.
-d, --device-id Target device id or name (prefixes allowed).
--version Reports the version of this tool.
--machine When used with the "--version" flag, outputs the information using JSON.
--[no-]color Whether to use terminal colors (requires support for ANSI escape sequences).
(defaults to on)
--[no-]version-check Allow Flutter to check for updates when this command runs.
(defaults to on)
--suppress-analytics Suppress analytics reporting when this command runs.
--packages Path to your "package_config.json" file.
Local build selection options (not normally required):
--local-engine-src-path Path to your engine src directory, if you are building Flutter locally.
Defaults to $FLUTTER_ENGINE if set, otherwise defaults to the path given in your pubspec.yaml dependency_overrides for sky_engine, if any.
--local-engine Name of a build output within the engine out directory, if you are building Flutter locally.
Use this to select a specific version of the engine if you have built multiple engine targets.
This path is relative to "--local-engine-src-path" or "--local-engine-src-out" (q.v.).
Options for testing the "flutter" tool itself:
--show-test-device List the special "flutter-tester" device in device listings. This headless device is used to test Flutter tooling.
--show-web-server-device List the special "web-server" device in device listings.
Available commands:
Flutter SDK
bash-completion Output command line shell completion setup scripts.
channel List or switch Flutter channels.
config Configure Flutter settings.
doctor Show information about the installed tooling.
downgrade Downgrade Flutter to the last active version for the current channel.
precache Populate the Flutter tool's cache of binary artifacts.
upgrade Upgrade your copy of Flutter.
Project
analyze Analyze the project's Dart code.
assemble Assemble and build Flutter resources.
build Build an executable app or install bundle.
clean Delete the build/ and .dart_tool/ directories.
create Create a new Flutter project.
drive Run integration tests for the project on an attached device or emulator.
format Format one or more Dart files.
gen-l10n Generate localizations for the current project.
pub Commands for managing Flutter packages.
run Run your Flutter app on an attached device.
test Run Flutter unit tests for the current project.
Tools & Devices
attach Attach to a running app.
custom-devices List, reset, add and delete custom devices.
daemon Run a persistent, JSON-RPC based server to communicate with devices.
debug-adapter Run a Debug Adapter Protocol (DAP) server to communicate with the Flutter tool.
devices List all connected devices.
emulators List, launch and create emulators.
install Install a Flutter app on an attached device.
logs Show log output for running Flutter apps.
screenshot Take a screenshot from a connected device.
symbolize Symbolize a stack trace from an AOT-compiled Flutter app.
Run "flutter help <command>" for more information about a command.
Run "flutter help -v" for verbose help output, including less commonly used options.

Here is some steps you can follow :-
cd.. your flutter project
run flutter clean
run your project iOS directory in Xcode
go to preferences-> Location and clear derive data
then run cd.. your_project_path/iOS in your terminal
then run pod install
then run your code in simulator using Xcode
Maybe it can solve your problem

Upgrade the Project 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.

Related

Exception: Unable to generate build files in flutter

I am trying to install flutter in kali linux machine. I installed flutter from official website and followed accordingly. I don't want to use android studio so I am using visual studio code.
when I run Flutter doctor in terminal i get
[✓] Flutter (Channel master, 2.2.0-11.0.pre.161, on Linux, locale en_IN)
[✗] 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/linux#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.
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[☠] Linux toolchain - develop for Linux desktop (the doctor check crashed)
✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at
https://github.com/flutter/flutter/issues.
✗ ProcessException: Failed to find "ninja" in the search path.
Command: ninja
[!] Android Studio (not installed)
[✓] VS Code (version 1.55.2)
[✓] Connected device (1 available)
! Doctor found issues in 4 categories.
And when i Run in visual studio i get this
Launching lib/main.dart on Linux in debug mode...
lib/main.dart:1
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
Exception: Unable to generate build files
Exited (sigterm)
Can anyone help me with this issue please.
I found the solution by using this following command:
sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev
and
flutter config --enable-linux-desktop
you must install ninja.
sudo pacman -S ninja or sudo apt-get install ninja.

Flutter error: Could not load wrapper properties from /android/gradle/wrapper/gradle-wrapper.properties'

i am new to flutter, i just followed an online video on setting up flutter on my MacBook pro and i just created my first project and tried to run it while my system is connected to the internet but got this error bellow
Launching lib/main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
Exception in thread "main" java.lang.RuntimeException: Could not load wrapper properties from '/Users/bright/AndroidStudioProjects/second_flutterapp/android/gradle/wrapper/gradle-wrapper.properties'.
at org.gradle.wrapper.WrapperExecutor.<init>(WrapperExecutor.java:64)
at org.gradle.wrapper.WrapperExecutor.forWrapperPropertiesFile(WrapperExecutor.java:47)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:60)
Caused by: java.net.URISyntaxException: Illegal character in path at index 62: https://services.gradle.org/distributions/gradle-x.x.x-all.zip to gradle-6.7-all.zip
at java.net.URI$Parser.fail(URI.java:2848)
at java.net.URI$Parser.checkChars(URI.java:3021)
at java.net.URI$Parser.parseHierarchical(URI.java:3105)
at java.net.URI$Parser.parse(URI.java:3053)
at java.net.URI.<init>(URI.java:588)
at org.gradle.wrapper.WrapperExecutor.readDistroUrl(WrapperExecutor.java:81)
at org.gradle.wrapper.WrapperExecutor.prepareDistributionUri(WrapperExecutor.java:70)
at org.gradle.wrapper.WrapperExecutor.<init>(WrapperExecutor.java:57)
... 2 more
Exception: Gradle task assembleDebug failed with exit code 1
i have see many issues like this with answers here but non fixed my issue... i have tried deleting "gradle-wrapper.jar" and Replacing "distributionUrl=https://services.gradle.org/distributions/gradle-x.x.x-all.zip to gradle-6.4.1-all.zip" on the gradle-wrapper-properties file and running the comman "flutter run" on my terminal but still get same error
i have tried "flutter doctor" which gave me the result down bellow
Brights-MBP:~ bright$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.15.6 19G2021 darwin-x64,
locale en-NG)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✗] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS
development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
✗ CocoaPods not installed.
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
[✓] Android Studio (version 4.1)
[✓] Connected device (1 available)
! Doctor found issues in 1 category.
i know i have not installed Xcode which i will do later but am not sure if thats the issue
#what am i doing wrong?
Looking at the path, the error clearly stated that:
Caused by: java.net.URISyntaxException: Illegal character in path at index 62: https://services.gradle.org/distributions/gradle-x.x.x-all.zip to gradle-6.7-all.zip
When checking the file gradle-x.x.x-all.zip in services.gradle.org/ distributions/, it is not existing while the gradle-6.7-all.zip was found. So it could be a big factor that there was an error copying the distributions path. The proper file should be gradle-6.7-all.zip.
Also, you've mentioned that this was the first time Flutter was setup in your MacOS. With this, you can always check the guide from the Flutter documentation about macOS install for any missed steps/processes.
The error shows your characters in "distributionUrl=https://services.gradle.org/distributions/gradle-xxx-all.zip to gradle-6.4.1-all.zip"
Just change it to something like this:
enter image description here

Error: Unknown argument --licenses flutter doctor --android-licenses

I tried to install the android SDK with vscode to write flutter. But whenever a start android emulator it asked for licenses. But whenever I use command flutter doctor android licenses. It gives me this error. I am using,
ANDROID SDK PLATFORM TOOLS - 29.0.6
ANDROID SDK BUILD TOOLS - 29.0.3
ANDROID 7 (API:24)
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.1, on Linux, locale en_US.utf8)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.
[!] Android Studio (not installed)
[✓] VS Code (version 1.50.0)
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
I tried many StackOverflow solutions but it didn't work out. maybe outdated.
flutter doctor --android-licenses
Error: Unknown argument --licenses
Usage:
sdkmanager [--uninstall] [<common args>] \
[--package_file <package-file>] [<packages>...]
sdkmanager --update [<common args>]
sdkmanager --list [<common args>]
In its first form, installs, or uninstalls, or updates packages.
<package> is a sdk-style path (e.g. "build-tools;23.0.0" or
"platforms;android-23").
<package-file> is a text file where each line is a sdk-style path
of a package to install or uninstall.
Multiple --package_file arguments may be specified in combination
with explicit paths.
In its second form (with --update), currently installed packages are
updated to the latest version.
In its third form, all installed and available packages are printed out.
Common Arguments:
--sdk_root=<sdkRootPath>: Use the specified SDK root instead of the SDK containing this tool
--channel=<channelId>: Include packages in channels up to <channelId>.
Common channels are:
0 (Stable), 1 (Beta), 2 (Dev), and 3 (Canary).
--include_obsolete: With --list, show obsolete packages in the
package listing. With --update, update obsolete
packages as well as non-obsolete.
--no_https: Force all connections to use http rather than https.
--proxy=<http | socks>: Connect via a proxy of the given type.
--proxy_host=<IP or DNS address>: IP or DNS address of the proxy to use.
--proxy_port=<port #>: Proxy port to connect to.
* If the env var REPO_OS_OVERRIDE is set to "windows",
"macosx", or "linux", packages will be downloaded for that OS.
So how can I activate the license for android SDK?
I had the same issue when I ran flutter doctor --android-licenses. And I had android SDK installed without using Android Studio.
Here are the steps I took to make it work
I went to android studio download page and scrolled down and downloaded the command line tools for my OS (windows)
Then I extracted it to the android-sdk directory
I created a new folder called latest inside cmdline-tools and moved the content of cmdline-tools to it.
After this I tried to run flutter doctor --android-licenses and then it worked without errors and ran it on my device no problem.
Install Android SDK 6.0(Marshmallow)
I solved it by installing android studio and uninstall all android files and reinstall from android studio. Then automatically the license created in the folder. now whenever I run the emulator from vscode.. it is working smoothly.
I faced the problem because I installed all android files from android sdk directly. I installed android sdk by sudo snap android-sdk. so it created the problem for me.
To know more in detailed you can read this article - Flutter, Android SDK and VScode setup on Linux Complete Guideline
This issue would occur if you do not have the command-line tools in your <sdk>/cmdline-tools\latest directory. Instead of installing Android Studio, you can download command line tools from here and put it in the directory <sdk>/cmdline-tools\latest

ProcessException: Process timed out: when xode build Done Flutter app

After Xcode code build flutter run
ProcessException: Process timed out:
Command: /usr/bin/env xcrun xcodebuild -configuration Debug -quiet -workspace
Runner.xcworkspace -scheme Runner
BUILD_DIR=/Users/Huzeifah/Documents/flutter_development/test_app/build/ios
-sdk iphonesimulator -arch x86_64
SCRIPT_OUTPUT_STREAM_FILE=/var/folders/w8/nf0h0vbj01v4qz3wbk07fvnr0000gn/T/flu
tter_build_log_pipe.O5hXp2/pipe_to_stdout FLUTTER_SUPPRESS_ANALYTICS=true
COMPILER_INDEX_STORE_ENABLE=NO -showBuildSettings
All version information when run flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.17.1, on Mac OS X 10.15.3 19D76, locale en-PK)
[✗] 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.4.1)
[!] Android Studio (not installed)
[✓] VS Code (version 1.45.1)
[✓] Connected device (1 available)
! Doctor found issues in 2 categories.
When I run flutter. Xocde build done then give the Error ProceesTimw out. Then I try every thing that i can try. I install new vwesion of Xcode 11.4.1 and flutter new version 1.17 stable enter image description here
For me, I had the same issue and resolved it by moving my project out of a folder that iCloud was backing up. I had moved to a place with slower wifi, so my project kept hanging. Now, it loads faster than it did before.
Credit here (iOS simulator not working or taking so much time in Flutter)
This usually happens when you update xcode to fix this use Flutter upgrade in your general terminal and go to your project code editor and run Flutter clean and run flutter run if you face any other issues let me know......

Android SDK file not found: adb on MacOSX

On MacOSX, when I run flutter doctor, the following result is shown in the terminal:
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.14.5 18F132, locale pt-BR)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
✗ Android SDK file not found: adb.
[✗] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
✗ CocoaPods not installed.
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
[✓] Android Studio (version 3.6)
[!] VS Code (version 1.40.2)
✗ Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
! No devices available
! Doctor found issues in 4 categories.
The line following error is strange.
[!] Android toolchain - develop for Android devices (Android SDK
version 29.0.3)
✗ Android SDK file not found: adb.
Android SDK is installed
Platform tools are installed
If I run adb devices on my terminal, everything works fine and my device appears.
Any idea on how to fix this?
So I fixed in a very strange way:
Seems like some new version of Android SDK moved adb from /sdk/platform-tools to /sdk/platform-tools/platform-tools
To fix, I've only moved adb from /sdk/platform-tools/platform-tools to /sdk/platform-tools and now it's working.
Starting with the less complex fix;
Open vscode, click on the extension tab then search and install flutter extension.
Open the App Store search and install Xcode. It takes a very long time to complete. Clearly your installation is not complete.
If you are sure you have android SDK downloaded, then use the following command to provide the path the android studio. flutter config --android-sdk <path-to-your-android-sdk-path>
. Else you can use android studio to download the required Android SDK. See location in picture
Installing Xcode in the App store will install cocaopods. Then try flutter doctor -v and everything will be good.
NOTE: you don't need adb in mac for flutter to compile on android. downloading an Android SDK will install qemu. You will also notice some significate process load while running an Android emulator because of the running qemu process since it is not very optimized fro mac. But that is not an issue you will get use to or just use a real android device. Install Xcode will install all Iphones simulators.

Categories

Resources