DEV Community

Cover image for How to Rebuild Android and iOS Separately in a Flutter Project
Geoffrey Kim
Geoffrey Kim

Posted on

How to Rebuild Android and iOS Separately in a Flutter Project

In Flutter development, there might be times when you want to rebuild only the Android or iOS part of your project. Here's how you can do it for each platform:

Rebuilding Android:

  • Delete the build folder inside the Android directory:

    • Navigate to the root directory of your Flutter project.
    • From there, delete the build folder inside the android directory using the command:
     rm -rf android/app/build
    
  • Use Flutter build command:

    • Still in the root directory of your Flutter project, to build only the Android part, you can use the following commands:
    • For APK:
     flutter build apk
    
    • For App Bundle:
     flutter build appbundle
    
  • Using Android Studio:

    • Open your Flutter project in Android Studio.
    • Go to the 'Build' menu and select 'Rebuild Project'.

Rebuilding iOS:

  • Delete the build and DerivedData folders inside the iOS directory:

    • Navigate to the root directory of your Flutter project.
    • From there, delete the DerivedData and build folders inside the ios directory using the commands:
     rm -rf ios/DerivedData
     rm -rf ios/build
    
  • Use Flutter build command:

    • Still in the root directory of your Flutter project, to build only the iOS part, use the following command:
   flutter build ios
Enter fullscreen mode Exit fullscreen mode
  • Using Xcode:
    • Open the ios folder of your Flutter project in Xcode.
    • From the top menu, select 'Product', then 'Clean Build Folder'. This action removes all the previously compiled files, ensuring a fresh build the next time you compile.
    • After that, click the 'Run' button or select 'Product' > 'Build' to rebuild the project. This compiles the project using the latest code and resources.

By following these steps, you can rebuild the Android or iOS parts of your Flutter project separately, without affecting the other platform.

Top comments (0)