Flutter run xcode build fails but building directly with xcode succeeded - ios

I'm new to iOS development and I ran into this problem at the very beginning:
When I tried to flutter run my hello world app I got xcodebuild failed (I took only the last lines since it's too long):
81 errors generated.
<unknown>:0: error: failed to emit precompiled header '/Users/mehec/Library/Developer/Xcode/DerivedData/Runner-cssmbpuzzkyjvpfghedbpvdhbbmr/Build/Intermediates.noindex/PrecompiledHeaders/Runner-Bridging-Header-swift_2PXLF604USZTM-clang_KLU4EDN5EN1U.pch' for bridging header '/Users/mehec/Desktop/bgp/learn_flutter_0_test/ios/Runner/Runner-Bridging-Header.h'
<unknown>:0: error: generate-pch command failed with exit code 1 (use -v to see invocation)
note: Using new build system
note: Planning build
note: Constructing build description
I then tried to build and run in xcode and everything's fine.
I have tried flutter clean and flutter upgrade even creating a new project but no effect
I'm using macOS 10.14.6, IntelliJ Idea 2020.1, Flutter 1.17.5 and 1.19.0, Xcode 11.3.1
the code in main.dart:
import 'package:flutter/material.dart';
void main() {
runApp(Center(
child: Text(
"hello world",
textDirection: TextDirection.rtl,
),
));
}
flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.19.0-4.3.pre, on Mac OS X 10.14.6 18G5033, locale en-US)
[✗] 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.3.1)
[!] Android Studio (not installed)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.1.3)
[✓] Connected device (1 available)
! Doctor found issues in 2 categories.
Thanks!

I had a similar problem.
The build from Xcode.app was successful, but the build from the command line or Android Studio failed.
Finally, I reinstalled rbenv, and the problem went away.
In other Github comments, some people solved the problem with conda deactivate, so I think the problem is caused by a bug in the development environment that Xcode.app does not refer to, such as ruby or python environment.

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

Flutter iOS project Flutter.h file not found after adding Share Extension

I am stuck with this build issue
ios/Runner/GeneratedPluginRegistrant.h:10:9: error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
^
1 error generated.
:0: error: failed to emit precompiled header
It occurs after carefully adding a Share Extension to the Xcode workspace and configuring it according to this article:
https://medium.com/flutter-community/receive-sharing-files-to-flutter-app-from-another-app-7a84c0c0cd88
The "solutions" appear to be limited to deleting the iOS folder, and then recreating it.
I have done that, however as soon as I then add back in the share extension, I am left with the same problem.
I have so far tried the following, as well as many others since forgotten, and in many different combinations:
flutter clean
delete DerivedData folder
rm Podfile.lock and rm -rf Pods, follow by arch -x86_64 pod install --repo-update
Cocoapods updated
I am running on an M1 Macbook Pro
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.0, on macOS 12.2 21D49 darwin-arm, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
[✓] Chrome - develop for the web
[!] Android Studio
✗ Unable to find bundled Java version.
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.3)
[✓] VS Code (version 1.67.1)
[✓] Connected device (5 available)
[✓] HTTP Host Availability
I have seen the project build and run for the Simulator, but I cannot reliably say what changed or why, and right now it is back to not even building for simulator after I attempted a device build (which failed as above).
Additional notes
My targets (Runner, ShareExtension, Pods) are all set to build for iOS14
ShareExtension has the same bundle id as the Runner project with "Share-Extension" appended.
Bitcode not enabled
Thanks in advance for any help

Flutter iOS Build Issue : l[!] The 'Pods-Runner' target has transitive dependencies that include statically linked binaries:

Recently I am getting a build issue with Flutter iOS. It was working fine before, now for all flutter applications i try to build iOS same build issue arises.
Flutter Version : 1.17.5
Xcode Version : 11.3.1
Mac Os : 10.15
On pod install getting the following error message
[!] The 'Pods-Runner' target has transitive dependencies that include statically linked binaries: (/Users/acube/Desktop/Projects/Uhlala /limitless_singlevendor-app/ios/Flutter/Flutter.framework)
And in Xcode Build
error: /Users/acube/Desktop/Projects/Uhlala /limitless_singlevendor-app/ios/Flutter/Debug.xcconfig:1: could not find included file 'Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig' in search paths (in target 'Runner' from project 'Runner')
I have already tried almost all available fixes found in stack and github
add
s.static_framework = true
Clean build and pod
Uninstall flutter,xcode
Flutter Doctor result
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15 19A583, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.46.1)
[✓] Connected device (1 available)
• No issues found!
Faced this over the weekend. My solution was to rejig the platform architecture; rather than rewriting the code. So uninstalling & reinstalling Flutter, Cocoa-pods (& even Xcode if needed).
I've posted a step-by-step solution below.. if anyone's still stuck.
https://stackoverflow.com/a/64203751/3543789
I have faced this problem in all my project even I Create a new flutter Project. Finally I found the solution .
Solution
I strongly believe that this issue caused because of some configuration or flutter install issues. I have solved this issue by uninstalling all flutter and coco pods from the machine and reinstalling all from scratch.
Then deleting the ios folder from the project and create it again using flutter create . command.

Flutter: iOS build fails

I have an issue with Flutter. I can't run my app on an iOS simulator. I've tried to create a new certificate under the Mac keychain and that didn't help me much. Does anyone know how I can fix this problem?
(base) seroaslan#Seros-MBP Desktop % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.4 19E287, locale da-DK)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
[✓] Android Studio (version 3.5)
[!] IntelliJ IDEA Ultimate Edition (version 2020.1.1)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.44.2)
[✓] Connected device (1 available)
! Doctor found issues in 1 category.
(base) seroaslan#Seros-MBP tutorial % flutter run
Launching lib/main.dart on iPhone 8 in debug mode...
Running Xcode build...
├─Assembling Flutter resources... 2,8s
└─Compiling, linking and signing... 3,0s
Xcode build done. 9,2s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
/Users/seroaslan/Desktop/tutorial/build/ios/Debug-iphonesimulator/Runner.app: resource fork, Finder
information, or similar detritus not allowed
Command CodeSign 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.
The answer is in your flutter doctor:
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
You will need to fix these issues by setting it all up again as shown here: https://flutter.io/setup-macos/

error:Unable to locate a development device; please run 'flutter doctor' for information about installing additional components

while trying to run a simple code using bloc I weren't able to test it because of that error , and before this it takes a lot of time trying to resolving dependencies and then post this error :
Unable to locate a development device; please run 'flutter doctor' for information about installing additional components.
and after running flutter doctor the result is :
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.8.2, on Microsoft Windows [Version 10.0.17134.345], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
X Android SDK file not found: C:\Users\aya sisy\AppData\Local\Android\sdk\build-tools\28.0.3\aapt.
[√] Android Studio (version 3.1)
[√] VS Code (version 1.28.1)
[√] Connected devices (1 available)
! Doctor found issues in 1 category.
Seems like the Android Sdk is not found by Flutter.
Did you set the correct ANDROID_HOME environment variable ?
It could also be coming from the path including a space "...\Users\aya sisy\AppData\...".
Can you try to move it to another location ?
The same problem happened to me, except I'm using Ubuntu 18.04, so check the following:
The solution was to remove adb from apt package manager. so see if you accidentally installed adb for windows other than the one that come with android_sdk.
and from the logs you posted, it's clear that there is something wrong inside the android_sdk path so try to move it to other directory : for ex C:\dev\android_sdk and run the following command
flutter config --android-sdk "C:\dev\android_sdk"
Hoping that helps.
Just check whether your 'Project SDK' is set in File -> Project Structure; under the section Project Settings -> Project.
For me, it was not set by default, and setting it solved the problem.

Resources