Sub topic 2
The android and ios folders you will edit
Most Flutter work happens in lib/, but a release touches the platform folders. This chapter maps the files you will edit later in the tutorial, so you can find them quickly and avoid editing generated files by mistake.
It assumes you can create a Flutter project, run flutter run, and read a simple config file. You do not need prior Gradle or Xcode experience.
Why the platform folders exist
Flutter compiles your Dart code, then packages it inside a normal native app. The android/ folder holds a Gradle project, and the ios/ folder holds an Xcode project. The Android and iOS toolchains build, sign, and package your app from those folders. Store-facing settings such as the app's identifier, display name, icon, permissions, and signing live there, not in Dart.
Other platform folders such as web/, macos/, linux/, and windows/ exist only if you enabled those platforms. They are not covered here.
The top-level layout
A new project looks like this:
my_app/
lib/
test/
pubspec.yaml
android/
ios/The table below shows who owns what.
| Location | You edit it? | Purpose |
|---|---|---|
| `lib/` | Yes | Dart source code |
| `pubspec.yaml` | Yes | Dependencies, assets, and the app version |
| `android/` | Yes, selected files | Gradle project for Android |
| `ios/` | Yes, selected files | Xcode project for iOS |
| `build/` | No | Build output, regenerated on every build |
pubspec.yaml is the only file shared by both platforms for versioning. Its version: value flows into both native projects at build time, which a later chapter covers.
The android folder
Inside android/ you will mostly touch a handful of files.
android/
build.gradle.kts (project-level Gradle)
settings.gradle.kts (plugins and included modules)
gradle.properties (Gradle JVM and AndroidX flags)
local.properties (generated, machine specific)
key.properties (you create this for signing)
app/
build.gradle.kts (app module: ID, SDK versions, signing)
src/
main/
AndroidManifest.xml
kotlin/... (MainActivity)
res/ (icons, launch screen, strings)
debug/
AndroidManifest.xml
profile/
AndroidManifest.xmlOlder projects use Groovy files named build.gradle and settings.gradle instead of the .kts versions. The settings are the same, but the syntax differs. Check which one your project has before you copy a snippet.
android/app/build.gradle.kts
This is the file you will edit most. It is the build script for the app module, and it controls these release settings:
applicationId, the unique identifier of your app on Google Play.minSdk,targetSdk, andcompileSdk, the Android API levels.signingConfigsandbuildTypes, which decide how a release build is signed.- Shrinking options such as
isMinifyEnabled.
A trimmed excerpt shows where these settings sit:
// android/app/build.gradle.kts (excerpt)
android {
namespace = "com.example.my_app"
compileSdk = flutter.compileSdkVersion
defaultConfig {
applicationId = "com.example.my_app"
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
}Two details matter here. First, versionCode and versionName come from flutter.versionCode and flutter.versionName. Flutter reads them from pubspec.yaml, so you normally do not hard-code them in Gradle. Second, namespace and applicationId are different things. The namespace is used for generated code and the R class. The application ID is what the store sees. They often match in a new project, but you can change them independently.
AndroidManifest.xml
android/app/src/main/AndroidManifest.xml declares the app to the operating system. For release work you will edit two things:
android:labelon the<application>element, which is the name shown under the launcher icon.<uses-permission>entries, such asandroid.permission.INTERNET.
Here is a small valid manifest fragment:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:label="My App"
android:icon="@mipmap/ic_launcher">
<!-- activities omitted -->
</application>
</manifest>The debug/ and profile/ folders contain their own small manifests. These typically add the INTERNET permission so hot reload and the debugger can reach the device. Flutter merges them with the main manifest for those build types only. This leads to a classic bug: your app works in debug because the debug manifest grants INTERNET, then fails in release because the main manifest does not. If your app makes network calls, add the permission to src/main/AndroidManifest.xml.
Files you should not commit
local.propertiesis generated on each machine. It stores the paths to your Flutter and Android SDKs. A default.gitignorealready excludes it.key.propertiesholds your signing passwords. You create it, and you must keep it out of version control.- Keystore files (
*.jks) are secrets too. Store them outside the repository.
The ios folder
The ios/ folder is an Xcode project plus CocoaPods files.
ios/
Runner.xcodeproj/ (project settings, targets, signing)
Runner.xcworkspace/ (open this one in Xcode)
Runner/
Info.plist (app metadata and permission strings)
Assets.xcassets/ (AppIcon, LaunchImage)
AppDelegate.swift
Base.lproj/ (storyboards)
Flutter/
Debug.xcconfig
Release.xcconfig
Generated.xcconfig (generated)
Podfile (CocoaPods dependencies)
Podfile.lock
Pods/ (generated, installed by CocoaPods)Open the workspace, not the project
Always open ios/Runner.xcworkspace in Xcode. The workspace includes the Pods project that holds your plugins. If you open Runner.xcodeproj directly, the plugin code is missing and the build fails with errors about missing modules.
Xcode settings versus files
Many iOS settings are not plain text files you edit by hand. You change them in Xcode, and Xcode writes them into Runner.xcodeproj/project.pbxproj. These include:
- The bundle identifier and signing team, set under Runner target > Signing & Capabilities.
- The deployment target, which is the minimum iOS version.
- Capabilities such as push notifications.
Avoid hand-editing project.pbxproj. It is dense, and a small mistake can make the project unreadable. Use Xcode's interface and commit the resulting diff.
Info.plist
ios/Runner/Info.plist is an XML property list with the app's metadata. For release you will touch:
CFBundleDisplayName, the name shown on the home screen.- Usage description strings for each protected resource you use, such as
NSCameraUsageDescription.
Apple rejects or crashes apps that access the camera, location, photos, or microphone without a usage string. An example entry:
<key>CFBundleDisplayName</key>
<string>My App</string>
<key>NSCameraUsageDescription</key>
<string>Used to scan receipts you add to expenses.</string>Version values in Info.plist use variables such as $(FLUTTER_BUILD_NAME) and $(FLUTTER_BUILD_NUMBER). These come from Generated.xcconfig, which Flutter rewrites from pubspec.yaml on each build. Leave those placeholders alone.
Generated and installed files
| File or folder | Source | Rule |
|---|---|---|
| `Flutter/Generated.xcconfig` | Flutter tool | Never edit; it is overwritten |
| `Pods/` | `pod install` | Do not edit; many teams ignore it in Git |
| `Podfile.lock` | CocoaPods | Commit it so builds are repeatable |
| `local.properties` (Android) | Flutter tool | Never commit |
If the pods get out of sync, run these commands from the project root:
flutter clean
flutter pub get
cd ios && pod installWhere each release setting lives
Use this table as a map for the next chapters.
| Release setting | Android | iOS |
|---|---|---|
| Unique ID | `applicationId` in `app/build.gradle.kts` | Bundle Identifier in Xcode |
| Display name | `android:label` in `AndroidManifest.xml` | `CFBundleDisplayName` in `Info.plist` |
| Version | `version:` in `pubspec.yaml` | `version:` in `pubspec.yaml` |
| Icons | `res/mipmap-*` | `Assets.xcassets/AppIcon` |
| Signing | `key.properties` and Gradle | Team and profiles in Xcode |
| Permissions | `<uses-permission>` | `Info.plist` usage strings |
Common errors
- Editing the wrong manifest. A change in
src/debug/AndroidManifest.xmldoes not reach release builds. Put release-relevant settings insrc/main. - Copying Groovy into a Kotlin file. Syntax such as
signingConfig signingConfigs.releasefails in.ktsfiles. UsesigningConfig = signingConfigs.getByName("release"). - Opening
Runner.xcodeproj. Open the.xcworkspaceinstead. - Changing only one platform. The application ID and bundle identifier are separate settings. Changing one does not change the other.
- Editing generated files. Your change to
Generated.xcconfigorlocal.propertiesis lost on the next build. - Regenerating folders. If a platform folder is damaged,
flutter create .recreates missing platform files without touching your Dart code. Review the diff, since it can overwrite files you customized.
Exercise
Your app fetches data from the network. It works with flutter run on an Android phone, but a release APK shows no data and logs a socket permission error. Which file do you check first, and what do you add?
Show answer
Check android/app/src/main/AndroidManifest.xml. The debug and profile manifests declare android.permission.INTERNET, so debug builds work. The release build uses only the main manifest, so add <uses-permission android:name="android.permission.INTERNET" /> there as a child of <manifest>.
Exercise
A teammate opens ios/Runner.xcodeproj in Xcode and gets "No such module" errors for a plugin. What is the cause and the fix?
Show answer
The plugins are part of the CocoaPods workspace, which the bare project does not include. Close it and open ios/Runner.xcworkspace instead. If the error persists, run pod install in the ios folder.