When working on a Mac with Flutter in Android Studio (Arctic Fox 2021.3.1 Patch 4 and XCode 13.1 and/or 13.2):
If you move the root folder of your Flutter project using Finder, then open it in Android Studio and run it, the original folder location is still re-written (multiple sub folders with empty contents, usually, but not always).
Also, the moved project will no longer build from within XCode.
This means that if you don't know the final desired location for your project at the time you create it, you will not be able to move it without weird stuff happening.
How can you move a Flutter project that was created with Android Studio without it having weird side-effects?
More info on how to reproduce:
Close all IDEs
Open Android Studio
Using Android Studio, create a new default FLUTTER project using Java as the Android code choice
Using Android Studio, run this project on an Android Emulator
Using Android Studio, run this project on an IOS simulator
Using Android Studio, open the project in XCode (right-click ios folder and select Flutter\Open project in Xcode)
Using XCode, run the project on an IOS simulator
[everything should have worked so far]
Close all IDEs
Using Finder, move the project folder to a new location that is at the same depth as its current folder, but with a different parent folder. Meaning if current location is: [root]/x/y/a/my_project_original, the destination would be: [root]/x/y/b/my_project_copy
delete the original folder and remember where it was
Using Android Studio, open the project from its new location
Using Android Studio, open the project in XCode (right-click ios folder and select Flutter\Open project in Xcode)
Attempt to run on IOS simulator
[observe error - "Command PhaseScriptExecution failed with a nonzero exit code" // "file not found exception"]
Using Finder, check to verify original folder location has NOT been re-written
Using Android Studio, run the project on Android emulator
[observe that original folder has been re-written!]
Here are the steps I follow to move a project's location on my mac :
The steps should be the same within XCode (in the main window, remove the old location from your recent projects, and Open the new location)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With