Skip to content

Commit 0100afb

Browse files
Add flavors to macOS (#1078)
## Summary With this PR, we support `prod` and `dev` flavors for our macOS app. Make you sure, you have the [FlutterFire CLI](https://pub.dev/packages/flutterfire_cli) installed (version 0.3.0-dev.18 or higher), if you want to build for macOS. The FlutterFire CLI is used during the build process in the XCode build phases (configuring bundle service files and uploading Crashlytics symbols). ## Details Because the process of adding Firebase flavors to our macOS isn't documented well (there is a open PR with more documentation: invertase/flutterfire_cli#224), I'm describing here, what I did to support flavors. First, I needed to execute the following commands: ```sh flutterfire configure \ --project=sharezone-debug \ --platforms=macos \ --out=lib/firebase_options_dev.g.dart \ --macos-build-config=Debug-dev \ --macos-out=macos/config/dev \ --macos-bundle-id=de.codingbrain.sharezone.app.dev flutterfire configure \ --project=sharezone-debug \ --platforms=macos \ --out=lib/firebase_options_dev.g.dart \ --macos-build-config=Profile-dev \ --macos-out=macos/config/dev \ --macos-bundle-id=de.codingbrain.sharezone.app.dev flutterfire configure \ --project=sharezone-debug \ --platforms=macos \ --out=lib/firebase_options_dev.g.dart \ --macos-build-config=Release-dev \ --macos-out=macos/config/dev \ --macos-bundle-id=de.codingbrain.sharezone.app.dev flutterfire configure \ --project=sharezone-c2bd8 \ --platforms=macos \ --out=lib/firebase_options_prod.g.dart \ --macos-build-config=Debug-prod \ --macos-out=macos/config/prod \ --macos-bundle-id=de.codingbrain.sharezone.app flutterfire configure \ --project=sharezone-c2bd8 \ --platforms=macos \ --out=lib/firebase_options_prod.g.dart \ --macos-build-config=Profile-prod \ --macos-out=macos/config/prod \ --macos-bundle-id=de.codingbrain.sharezone.app flutterfire configure \ --project=sharezone-c2bd8 \ --platforms=macos \ --out=lib/firebase_options_prod.g.dart \ --macos-build-config=Release-prod \ --macos-out=macos/config/prod \ --macos-bundle-id=de.codingbrain.sharezone.app ``` The commands configure Firebase for each build config (`Debug-dev`, `Profile-dev`, `Release-dev`, `Debug-prod`, `Profile-prod`, `Release-prod`). Additionally, I needed to set `debug information format` to `DWARF with dSYM File`, see https://firebase.google.com/docs/crashlytics/get-started?platform=ios#set-up-dsym-uploading. ## Related Tickets Closes #352 Related to invertase/flutterfire_cli#14
1 parent 6723fdd commit 0100afb

File tree

13 files changed

+680
-141
lines changed

13 files changed

+680
-141
lines changed

.github/workflows/alpha.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,12 @@ jobs:
304304
fvm flutter pub global activate --source path "$CI_CD_DART_SCRIPTS_PACKAGE_PATH"
305305
echo $(realpath ./bin) >> $GITHUB_PATH
306306
307+
# We need to install the FlutterFire CLI because we have Build Phases in
308+
# XCode configured which are using the FlutterFire CLI. Without the CLI,
309+
# the build would fail.
310+
- name: Install FlutterFire CLI
311+
run: fvm flutter pub global activate flutterfire_cli 0.3.0-dev.18
312+
307313
- name: Deploy macOS to TestFlight
308314
env:
309315
# The following secrets are used by the Codemagic CLI tool. It's important

.github/workflows/beta.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ jobs:
254254
fvm flutter pub global activate --source path "$CI_CD_DART_SCRIPTS_PACKAGE_PATH"
255255
echo $(pwd)/bin >> $GITHUB_PATH
256256
257+
# We need to install the FlutterFire CLI because we have Build Phases in
258+
# XCode configured which are using the FlutterFire CLI. Without the CLI,
259+
# the build would fail.
260+
- name: Install FlutterFire CLI
261+
run: fvm flutter pub global activate flutterfire_cli 0.3.0-dev.18
262+
257263
- name: Deploy to TestFlight
258264
env:
259265
# The following secrets are used by the Codemagic CLI tool. It's important

.github/workflows/integration_tests_app_ci.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ jobs:
304304
APP_STORE_CONNECT_KEY_IDENTIFIER: ${{ secrets.SHAREZONE_APP_STORE_CONNECT_KEY_IDENTIFIER }}
305305
APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.SHAREZONE_APP_STORE_CONNECT_ISSUER_ID }}
306306
APP_STORE_CONNECT_PRIVATE_KEY: ${{ secrets.SHAREZONE_APP_STORE_CONNECT_PRIVATE_KEY }}
307-
BUNDLE_ID: de.codingbrain.sharezone.app
307+
BUNDLE_ID: de.codingbrain.sharezone.app.dev
308308
run: |
309309
# Even when are trying to build app, we need to use "--platform IOS".
310310
# The reason for this that our production bundle ID was created for
@@ -331,7 +331,14 @@ jobs:
331331
flutter-version: ${{ env.FLUTTER_VERSION }}
332332
channel: ${{ env.FLUTTER_CHANNEL }}
333333

334+
# We need to install the FlutterFire CLI because we have Build Phases in
335+
# XCode configured which are using the FlutterFire CLI. Without the CLI,
336+
# the build would fail.
337+
- name: Install FlutterFire CLI
338+
run: flutter pub global activate flutterfire_cli 0.3.0-dev.18
339+
334340
- name: Build macOS app
335341
run: |
336342
flutter build macos \
337-
-t lib/main_prod.dart
343+
--flavor dev \
344+
-t lib/main_dev.dart

.github/workflows/stable.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ jobs:
256256
fvm flutter pub global activate --source path "$CI_CD_DART_SCRIPTS_PACKAGE_PATH"
257257
echo $(pwd)/bin >> $GITHUB_PATH
258258
259+
# We need to install the FlutterFire CLI because we have Build Phases in
260+
# XCode configured which are using the FlutterFire CLI. Without the CLI,
261+
# the build would fail.
262+
- name: Install FlutterFire CLI
263+
run: fvm flutter pub global activate flutterfire_cli 0.3.0-dev.18
264+
259265
- name: Deploy to TestFlight
260266
env:
261267
# The following secrets are used by the Codemagic CLI tool. It's important

CONTRIBUTING.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ To install & use FVM, follow the following steps:
9292

9393
When you are using VS Code, no further steps should be necessary, because we included the `.vscode/setting.json` to git. However, when you are using Android Studio, you need to configure your IDE to use the Flutter version of FVM. Follow the [official documentation](https://fvm.app/docs/getting_started/configuration#android-studio) to configure Android Studio.
9494

95+
### FlutterFire CLI
96+
97+
If you want to use build the macOS app, you need to install the [FlutterFire CLI](https://pub.dev/packages/flutterfire_cli). This CLI is used during the build process.
98+
99+
To install the FlutterFire CLI, execute the following command:
100+
101+
```sh
102+
fvm flutter pub global activate flutterfire_cli 0.3.0-dev.18
103+
```
104+
105+
Make sure, you have the 0.3.0-dev.18 version or higher installed. You can check the version by running `flutterfire --version`.
106+
95107
## Running the app
96108

97109
After you have set up your development environment, you can run the app.
@@ -104,13 +116,15 @@ cd app
104116

105117
To run the app, you can then execute the following command:
106118

107-
### Android & iOS
119+
### Android, iOS & macOS
120+
121+
```sh
108122

109123
```sh
110124
fvm flutter run --flavor dev --target lib/main_dev.dart
111125
```
112126

113-
### Web & macOS
127+
### Web
114128

115129
```sh
116130
fvm flutter run --target lib/main_dev.dart

app/firebase.json

Lines changed: 114 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,122 @@
11
{
2-
"hosting": [
3-
{
4-
"target": "alpha-web-app",
5-
"public": "build/web",
6-
"ignore": [
7-
"firebase.json",
8-
"**/.*",
9-
"**/node_modules/**"
10-
],
11-
"rewrites": [
2+
"hosting": [
123
{
13-
"source": "**",
14-
"destination": "/index.html"
15-
}
16-
]
17-
},
18-
{
19-
"target": "beta-web-app",
20-
"public": "build/web",
21-
"ignore": [
22-
"firebase.json",
23-
"**/.*",
24-
"**/node_modules/**"
25-
],
26-
"rewrites": [
4+
"target": "alpha-web-app",
5+
"public": "build/web",
6+
"ignore": [
7+
"firebase.json",
8+
"**/.*",
9+
"**/node_modules/**"
10+
],
11+
"rewrites": [
12+
{
13+
"source": "**",
14+
"destination": "/index.html"
15+
}
16+
]
17+
},
2718
{
28-
"source": "**",
29-
"destination": "/index.html"
30-
}
31-
]
32-
},
33-
{
34-
"target": "release-web-app",
35-
"public": "build/web",
36-
"ignore": [
37-
"firebase.json",
38-
"**/.*",
39-
"**/node_modules/**"
40-
],
41-
"rewrites": [
19+
"target": "beta-web-app",
20+
"public": "build/web",
21+
"ignore": [
22+
"firebase.json",
23+
"**/.*",
24+
"**/node_modules/**"
25+
],
26+
"rewrites": [
27+
{
28+
"source": "**",
29+
"destination": "/index.html"
30+
}
31+
]
32+
},
4233
{
43-
"source": "**",
44-
"destination": "/index.html"
45-
}
46-
]
47-
},
48-
{
49-
"target": "test-web-app",
50-
"public": "build/web",
51-
"ignore": [
52-
"firebase.json",
53-
"**/.*",
54-
"**/node_modules/**"
55-
],
56-
"rewrites": [
34+
"target": "release-web-app",
35+
"public": "build/web",
36+
"ignore": [
37+
"firebase.json",
38+
"**/.*",
39+
"**/node_modules/**"
40+
],
41+
"rewrites": [
42+
{
43+
"source": "**",
44+
"destination": "/index.html"
45+
}
46+
]
47+
},
5748
{
58-
"source": "**",
59-
"destination": "/index.html"
49+
"target": "test-web-app",
50+
"public": "build/web",
51+
"ignore": [
52+
"firebase.json",
53+
"**/.*",
54+
"**/node_modules/**"
55+
],
56+
"rewrites": [
57+
{
58+
"source": "**",
59+
"destination": "/index.html"
60+
}
61+
]
62+
}
63+
],
64+
"flutter": {
65+
"platforms": {
66+
"macos": {
67+
"buildConfigurations": {
68+
"Debug-dev": {
69+
"projectId": "sharezone-debug",
70+
"appId": "1:366164701221:ios:785f107df46335d5bfcfcc",
71+
"uploadDebugSymbols": true,
72+
"fileOutput": "macos/config/dev/GoogleService-Info.plist"
73+
},
74+
"Profile-dev": {
75+
"projectId": "sharezone-debug",
76+
"appId": "1:366164701221:ios:785f107df46335d5bfcfcc",
77+
"uploadDebugSymbols": true,
78+
"fileOutput": "macos/config/dev/GoogleService-Info.plist"
79+
},
80+
"Release-dev": {
81+
"projectId": "sharezone-debug",
82+
"appId": "1:366164701221:ios:785f107df46335d5bfcfcc",
83+
"uploadDebugSymbols": true,
84+
"fileOutput": "macos/config/dev/GoogleService-Info.plist"
85+
},
86+
"Debug-prod": {
87+
"projectId": "sharezone-c2bd8",
88+
"appId": "1:730263787697:ios:3ff9b2cb1c2a5a31",
89+
"uploadDebugSymbols": true,
90+
"fileOutput": "macos/config/prod/GoogleService-Info.plist"
91+
},
92+
"Profile-prod": {
93+
"projectId": "sharezone-c2bd8",
94+
"appId": "1:730263787697:ios:3ff9b2cb1c2a5a31",
95+
"uploadDebugSymbols": true,
96+
"fileOutput": "macos/config/prod/GoogleService-Info.plist"
97+
},
98+
"Release-prod": {
99+
"projectId": "sharezone-c2bd8",
100+
"appId": "1:730263787697:ios:3ff9b2cb1c2a5a31",
101+
"uploadDebugSymbols": true,
102+
"fileOutput": "macos/config/prod/GoogleService-Info.plist"
103+
}
104+
}
105+
},
106+
"dart": {
107+
"lib/firebase_options_dev.g.dart": {
108+
"projectId": "sharezone-debug",
109+
"configurations": {
110+
"macos": "1:366164701221:ios:785f107df46335d5bfcfcc"
111+
}
112+
},
113+
"lib/firebase_options_prod.g.dart": {
114+
"projectId": "sharezone-c2bd8",
115+
"configurations": {
116+
"macos": "1:730263787697:ios:3ff9b2cb1c2a5a31"
117+
}
118+
}
119+
}
60120
}
61-
]
62121
}
63-
]
64122
}

0 commit comments

Comments
 (0)