Reputation: 7497
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!]
Upvotes: 8
Views: 5039
Reputation: 4836
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)
Upvotes: 3
Reputation: 29038
You can move your Flutter project anywhere, as long as you don't move the files inside the project relative to each other.
A note about pod install
: If you are immediately running from Xcode, you need to run pod install
inside the ios
folder after adding a plugin to your pubspec.yaml
. If you run flutter run
or use Android Studio to run it, that will run pod install
for you automatically. However, you don't have to run pod install
after moving the project, I've just tested it.
If you move the root folder of your 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).
This only happens if you kept Android Studio open when moving the files. You shouldn't open the old project reference in Android Studio, you should open the project using File
> Open...
.
Also, the moved project will no longer build from within Xcode.
If you provide the errors, that will help us help you.
How can you move a Flutter project that was created with Android Studio without it having weird side-effects?
I have not found any side effects of moving a Flutter project. Quit Android Studio if it is running, and open it using File
> Open...
. Or if you are in terminal, run (if installed using Jetbrains toolbox) open -a ~/Applications/JetBrains\ Toolbox/Android\ Studio.app/
Upvotes: 1