Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move Root Folder of Flutter Project

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:

  1. Close all IDEs

  2. Open Android Studio

  3. Using Android Studio, create a new default FLUTTER project using Java as the Android code choice

  4. Using Android Studio, run this project on an Android Emulator

  5. Using Android Studio, run this project on an IOS simulator

  6. Using Android Studio, open the project in XCode (right-click ios folder and select Flutter\Open project in Xcode)

  7. Using XCode, run the project on an IOS simulator

[everything should have worked so far]

  1. Close all IDEs

  2. 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

  3. delete the original folder and remember where it was

  4. Using Android Studio, open the project from its new location

  5. Using Android Studio, open the project in XCode (right-click ios folder and select Flutter\Open project in Xcode)

  6. Attempt to run on IOS simulator

[observe error - "Command PhaseScriptExecution failed with a nonzero exit code" // "file not found exception"]

  1. Using Finder, check to verify original folder location has NOT been re-written

  2. Using Android Studio, run the project on Android emulator

[observe that original folder has been re-written!]

like image 765
Nerdy Bunz Avatar asked Dec 03 '21 00:12

Nerdy Bunz


1 Answers

Here are the steps I follow to move a project's location on my mac :

  • Close your project on Android Studio (File > Close Project)
  • Close Android Studio
  • Move your project to your new location
  • Open Android Studio
  • Delete your project from the Recent Projects (on the list of Recent Projects, click on the Settings icon on the right, and "Remove from recent projects")
  • Click on "Open" and select your project in the new location.
  • Delete the .idea file and build/ folder

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)

like image 134
FDuhen Avatar answered Oct 04 '22 17:10

FDuhen