Skip to content

Commit 73006eb

Browse files
committed
fix(ios): declare DeveloperSecrets.swift output path & add BUILD_KMP.md
1 parent f2b769f commit 73006eb

3 files changed

Lines changed: 203 additions & 118 deletions

File tree

BUILD_KMP.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Kotlin Multiplatform (KMP) Maps Demo — Build & Run Guide
2+
3+
This guide details how to build and run the multiplatform Maps Compose library (`:maps-compose-multiplatform`), the Android demo app (`:maps-app`), and the iOS demo app (`iosApp`).
4+
5+
---
6+
7+
## 1. Checkout the PR / Branch
8+
9+
Fetch the remote branch and check it out (or add it as a Git worktree):
10+
11+
```bash
12+
git fetch origin feat/experimental-kmp-module
13+
git checkout feat/experimental-kmp-module
14+
```
15+
16+
*(Alternatively, to isolate your work in a worktree branch)*:
17+
```bash
18+
git worktree add -b feat/experimental-kmp-module feat-experimental-kmp-module origin/feat/experimental-kmp-module
19+
```
20+
21+
---
22+
23+
## 2. Configure Local API Keys
24+
25+
Create a file named `secrets.properties` in the **root** directory of the repository (if you don't already have one) and populate it with your Google Maps API keys:
26+
27+
```properties
28+
MAPS_API_KEY=YOUR_GOOGLE_MAPS_API_KEY
29+
PLACES_API_KEY=YOUR_GOOGLE_PLACES_API_KEY
30+
```
31+
32+
> [!IMPORTANT]
33+
> Both `secrets.properties` and the generated iOS equivalent (`DeveloperSecrets.swift`) are ignored by Git to prevent accidentally leaking credentials.
34+
35+
---
36+
37+
## 3. Building & Running for Android
38+
39+
To compile and verify both the KMP library Android target and the Android sample application (`:maps-app`), run:
40+
41+
```bash
42+
./gradlew assembleDebug
43+
```
44+
45+
---
46+
47+
## 4. Building & Running for iOS (Step-by-Step)
48+
49+
If you are running the iOS project (`iosApp`) for the first time, follow these steps on a Mac with **Xcode** and **CocoaPods** installed:
50+
51+
### Step 4.1: Generate the KMP Dummy Framework
52+
Before CocoaPods can link the local `:maps-compose-multiplatform` podspec, the initial Kotlin framework must exist. From the repository root, execute:
53+
54+
```bash
55+
./gradlew :maps-compose-multiplatform:generateDummyFramework
56+
```
57+
58+
### Step 4.2: Generate the Xcode Project
59+
Navigate to the `iosApp` directory and run the project generation Ruby script (requires the `xcodeproj` gem):
60+
61+
```bash
62+
cd iosApp
63+
ruby create_project.rb
64+
```
65+
66+
> [!NOTE]
67+
> **Build System Output Tracking (Xcode 16+)**: The `create_project.rb` script declares `$(SRCROOT)/iosApp/DeveloperSecrets.swift` as an output of the **Populate Secrets** script build phase. This prevents modern Xcode build systems from failing with `Build input file cannot be found: DeveloperSecrets.swift` during dependency graph analysis.
68+
69+
### Step 4.3: Install Pod Dependencies
70+
Install the required CocoaPods (`GoogleMaps` 10.14.0 and the local KMP library). If your local specs repository is out of date, use the `--repo-update` flag:
71+
72+
```bash
73+
pod install --repo-update
74+
```
75+
76+
### Step 4.4: Open and Run in Xcode
77+
1. Open the generated **Workspace** (do **not** open the `.xcodeproj` file directly):
78+
```bash
79+
open iosApp.xcworkspace
80+
```
81+
2. In Xcode's top toolbar, select the active scheme dropdown and set it to **`iosApp`** (instead of `maps_compose_multiplatform`).
82+
3. Choose an iOS Simulator (e.g., **iPhone 16** or **iPhone 17 Pro**) in the destination dropdown.
83+
4. Click the **Play** button (or press **Cmd + R**) to compile, run the secrets population script, and launch the app!

iosApp/create_project.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
# Add a Build Phase Run Script to populate secrets before compilation
3737
populate_secrets_phase = target.new_shell_script_build_phase('Populate Secrets')
38+
populate_secrets_phase.output_paths = ['$(SRCROOT)/iosApp/DeveloperSecrets.swift']
3839
populate_secrets_phase.shell_script = <<-SHELL
3940
SECRETS_PATH="${PROJECT_DIR}/../secrets.properties"
4041
OUTPUT_FILE="${SRCROOT}/iosApp/DeveloperSecrets.swift"

0 commit comments

Comments
 (0)