Xcode commands are taking a long time within Flutter projects - ios

Some context
I'm working with Flutter, but after doing a couple of changes to the iOS Podfile, .plist files, and Runner.xcworkspace things "stopped" working. The problem I'm having is that everything Xcode related is taking a very long time to run in all of my Flutter projects.
To give some context the app I was building when Xcode started giving me problems uses Cloud Firestore. For this to compile faster I added the following code to my Podfile, this was suggested by Google in some docs.
platform :ios, '16.1'
target 'Runner' do
# Code to reduce compile time for iOS.
pod 'FirebaseFirestore/WithLeveldb', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '10.2.0'
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
After doing this change and importing the Firestore package a file called GoogleService-Info.plist was created and I added this file to the Runner.xcworkspace as a Runner. This step was mentioned in another Google document for activating sign-in with Google.
A weird thing about all of this is that if I try to run open Runner.xcworkspace the Xcode app also takes forever to open (it's been over an hour since I ran it and it has not been opened). This worked earlier as I was able to open this directory to make the aforementioned change (make GoogleService-Info.plist a Runner file).
Attempts to solve this
After identifying the error I tried doing the following things, but nothing has worked so far:
Uninstall Xcode Command Line Tools and install them back on.
Uninstall Flutter and install it back on.
Uninstall Xcode completely and install it back on.
Restart my computer.
Try to build the project in another computer, but now this other computer is having the same issue.
I've tried to run things on both an Intel-based Mac and an Apple Silicon Mac, but in both computers Xcode "stopped" working for Flutter.
Reproducing this problem
The problem occurs when I try to run flutter clean, flutter run, or open Runner.xcworkspace. After running the first two commands in --verbose mode the problem comes up when the following commands appear:
xcrun xcodebuild -list
xcrun xcodebuild -workspace $PATH/Runner.xcworkspace -scheme Flutter Assamble clean
xcrun xcodebuild -workspace $PATH/Runner.xcworkspace -scheme Runner clean
The first command is currently running on the Apple Silicon Mac and its already been over an hour since it's been stuck there (Intel-based Mac already finished running this command). The second command follows the first one and it took over 20 minutes for it to run in the Intel computer. The third command is currently running on the Intel-based computer and it's been there for over 40 minutes.
Final details
This problem is persistent in all of my Flutter projects, it doesn't matter if the project has the Firebase packages or not. I don't know what I could have changed in my Xcode configuration for things to stop working so abruptly, but I hope someone is able to help me out.
P.S. I already tried compiling a native Swift project and everything seems to work, this issue seems to affect the Flutter projects exclusively. Obviously if I try to run the commands listed earlier outside of the Flutter execution they take a very long time as well.

After running more tests I realized that the problem was iCloud. For some reason working on both computers at the same time made my local computers work very slowly. The problem was hard to find because the iCloud bird process didn't appear to use more resources than it usually would.
To solve this I had to kill iCloud on both computers and restart the service. I recently updated both computers to Ventura 13.0.1 so I think the problem might be somewhere along those lines.

Related

Flutter on OSX M1 Mac gives error on xcode_backend.sh, about xcode project version when building for simulator

I'm on an M1 Mac Mini, Monterey 12.0.1, with XCode 13.1 & it's command-line tools and freshly-installed Flutter MacOS 2.8.0. I create a base Flutter project with
flutter create appname
When I do "flutter run" in the ios folder (in the parent folder it launches ok in Chrome), I get the message:
Could not build the application for the simulator.
Error launching application on iPhone 13.
I tried it with the simulator running, and not. It looks like the Runner XCode project build stages runs a script, xcode_backend.sh. I also tried loading the project in the XCode UI to build and get 'Command PhaseScriptExecution failed with a nonzero exit code' on that script.
If I go and run this script directly, from the project folder of the ios folder:
guy#Guys-Mac-mini ios % /bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh"
I get the message:
error: Your Xcode project is incompatible with this version of Flutter. Run "rm -rf ios/Runner.xcodeproj" and "flutter create ." to regenerate.
I tried the steps indicated, which I also found on Google, and removed the folder and regenerated the project, but the same message is appearing. (I did export the FLUTTER_ROOT environment variable, both in the shell and it's also defined in the XCode project settings.
I can build and run the flutter apps to Chrome, but not for the iOS simulator. I also have no problem building and running Swift apps I've coded on the simulator.
I got my Windows and Android setup running in minutes, but on the M1 Mac it's been hours without success. Any ideas?
I'm a developer with decent of experience, but this is my first stab at Flutter and cross-platform (other than Xamarin). Any help is appreciated.
I can't fully explain it, but the problem I was having was related to my having the project files on an SMB share I was accessing from the Mac.
I setup the project on an SMB share so I could access it from my Windows and Mac workstations. I found that any flutter project on that share would fail compilation.
To test this, I created a new flutter app on my Mac Documents folder, comiled and ran it succesfully in the iOS simulator using 'flutter run'. When I moved that project to the SMB share and tried to run it, I got the compilation error again, and it wouldn't run (I also tried clean and run). I moved the project back to the local drive Documents folder, and was able to run it again.
I also noticed that the Mac access to the SMB share is painfully slow, though I tried a required_signon fixes from
https://kb.synology.com/en-us/DSM/tutorial/What_can_I_do_to_fix_slow_SMB_file_transfers_on_OS_X_10_11_5 but it didn't help.
I had even tried to factory reset my Mac, and I thought that fixed it, but it was only because I hadn't connected to the share yet, and made a test project on the local drive.
PS: I don't expect to use the exact same Flutter project between the Mac and Windows workstations because of paths and SDK locations, but I am using it as a convenient place for transfering the source files.
My team was able to solve this by supplying an absolute path to the xcode_backend script in a run phase and running it. Running it once seemed to be enough and we could remove it thereafter:
/bin/sh "/absolute-path-to-flutter/packages/flutter_tools/bin/xcode_backend.sh" thin
/bin/sh "/absolute-path-to-flutter/packages/flutter_tools/bin/xcode_backend.sh" embed

YogaKit.modulemap not found in React Native on IOS after build in Xcode 12.4 on Macbook M1

Just make a new React Native projects on new Macbook M1. At first it was building on Xcode 12.4 with any troubles. But after a few days build failed with error:
fatal error: module map file '/Users/jocoders/Library/Developer/Xcode/DerivedData/CryptoWalletApp-hfiwvoyqlbgufkgtyvqtxygiaodf/Build/Products/Debug-iphonesimulator/YogaKit/YogaKit.modulemap' not found
What I already tried, but nothing works from it:
Checked cocoapods build target and it is the same version as my projects build target https://github.com/facebook/react-native/issues/28503#issuecomment-643744117
Rebuild a project;
Install pod with command arch -x86_64 pod install;
Put arm64 in Xcode Excluded Architectures https://github.com/facebook/react-native/issues/28503#issuecomment-770378485.
Guys can you tell me please how to solve it? Is it possible now to develop for React Native on new Macbook M1? I have it already a few weeks, but still not work on IOS, because it is so painy, a lot of errors. And I was waiting more surprises from Android more then IOS, but in real Android works with out any troubles.
All day I tried to find the decision and nothing worked to me except it: please try to open Xcode through Rosetta - Right click on Xcode in applications folder -> Get Info -> set Open with Rosetta to true
When you try to create a project using the below command in M1(Apple Silicon Chip):
npx react-native init ProjectName
Try to build using below steps:
Open Terminal and install rosetta
Type "softwareupdate — install-rosetta" command in your terminal.
After installation completes, go to the Application.
Find Terminal App
Right click and make a Duplicate Terminal
Now right click on a duplicate terminal and click on "Get Info"
You will see checkbox with option "Open with Rosetta". Enable it. Rosetta checkbox in terminal
That's it. Rename your rosetta terminal so that you can identify it easily.
Open your Rosetta Terminal and run the command npx react-native init ProjectName
After project initialisation done type npx react-native start to start metro.
Now type command npx react-native run-android for run into Android
Type command npx react-native run-ios for run into iOS.
After project initialisation is done you can run start and run command in VS Code also.
I had this problem with react-native 0.70 and xcode 14.2, and i was able to eventually get the app to run by opening the .workspace (NOT the .project xcode file) xcode file in xcode and running (the "play" button in xcode) from the root directory.
After this worked (the app succesfully ran in the ios simulator), i was able to run metro in the terminal and then run
yarn react-native run-ios
from within the ios folder of the app.
The app succesfully built and ran from terminal.
I had the same issue although not on a M1. I fixed it using all the recommendations from this answer.
Quoting the answer there for reference:
Make sure your cocoapods build target is the same version as your
projects build target.
Try rebooting your machine.
Examine your podfile to make sure your build scheme is included in it.
The last thing that really helped me was rebooting the machine. Strange!
I have got an M1 mac setup. The above methodologies were not working for me. However, this worked: Run XCode Rosetta
Finder -> Xcode in applications folder -> Get Info -> set Open with
Rosetta to true
Xcode is now under Rosetta.

Can't get Flutter project running after cloning from GitHub

I'm new to Flutter and have been learning it recently. Been trying to get this flutter app running for my internship, but can't seem to figure out why it's not running. I have no problem getting the default flutter app running on both iOS and Android simulators and on my personal iPhone. Flutter doctor checks out fine. I’ve tried flutter clean, removing the Podfile (as it recommended because it said it was out of date), downgrading flutter to the same version my team was using because I was thinking maybe it was a problem with that working with Xcode 12, and running things like pub get and pod install. Same error all around when trying on Xcode, terminal, android studio, and VScode. I've been pretty much going in circles with the same errors trying different things.
I'm running the app with the following command: flutter run -t lib/main_dev.dart --flavor dev
The third image is the error I got after I tried the first solution on Stackoverflow.
The fourth image is when I try running the app on my android sim.
I've tried the following answers here in Stack overflow
First solution
When I was getting deployment warnings
I could go on with the bunch of different errors I've encountered trying to run on Vscode, android studio, and so on, but basically, I've been going in circles with the same errors and the images below are just the ones I'm encountering now. All I'm trying to do is run the project I cloned from Github. I'm hoping anyone here will find an error that looks familiar to them or a similar situation where they couldn't get a flutter project to run after cloning.
A word of advice, Always run the latest flutter engine unless it is absolutely necessary.
run flutter clean
run rm ios/Podfile ios/Podfile.lock pubspec.lock
Looks like your flutter svg package has to be updated

Ionic Xcode unable to open file(target app)

I haven't touched my Ionic projects in around 1-2 months.
All my projects were running perfectly then.
I go to try run them today and every single one of them is saying
Showing Recent Messages
/Users/jakelewis/Desktop/fifteen-project-e/ios/App/Pods/Target Support
Files/Pods-App/Pods-App.debug.xcconfig: unable to open file (in target "App" in project "App")
They were all running perfectly. I haven't updated Xcode yet to the latest because it's still in the process of downloading. What would cause this issue?
It's a nightmare.
Somethings I tried, removing the ios folder and npx cap add ios
Even went on GitHub and went to rollback versions I knew that ran perfectly on IOS before.
I am using capacitor on most of my projects.
This did not fix the issue.
close XCode
run ionic capacitor copy ios to build it.
run pod reintegrate and pod install (navigate to where the pod file is located first, ex: cd ios/App and then run "pod install" command)
open XCode again use ionic capacitor open ios command
This work for me
try this:
Close XCode
open a terminal, go to the project and execute
pod install inside your app folder (where Podfile is located)

Flutter, Cannot Build For iOS: Missing .h-Files

Building our Flutter project fails on iOS. The following steps work without problems:
running on the XCode simulator (flutter run)
building in the terminal (flutter build ios)
running on a real device in debug mode (flutter run -d "abcd")
If I open the project in XCode, change the build target to "Generic iOS Device" and hit "Build" or "Archive" I get the following error:
/Users/.../development/testproject/ios/Runner/GeneratedPluginRegistrant.m:6:9: 'flutter_exif_rotation/FlutterExifRotationPlugin.h' file not found
After removing the FlutterExifRotationPlugin, the error reoccurs with the next plugin alphabetically, so I figured that plugins in general don't work at the moment.
I tried:
dev, stable and master channels of flutter
reinstalling XCode
reinstalling Flutter
create a new project and moving the old files there
But nothing worked so far.
Ok the solution was very simple. I had to open the .xcworkspace file instead of the .xcodeproject one.
One WEEK went down the pipe for this error. I hope that you, future reader, will find this comment useful.

Resources