Skip to content

Commit 47c185b

Browse files
committed
Merge branch 'zip-v3'
2 parents a6a89e0 + 6dfae11 commit 47c185b

14 files changed

+688
-570
lines changed

ReleaseTooling/DEVELOP.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Firebase Release Tools
2+
3+
This project includes Firebase release tooling including a zip builder and a
4+
Firebase release candidate creation tool.
5+
6+
The tools are designed to fail fast with an explanation of what went wrong, so
7+
you can fix issues or dig in without having to dig too deep into the code.
8+
9+
## Zip Builder
10+
11+
For general usage, see [README.md](README.md).
12+
13+
### Firebase Release zip building
14+
15+
If the `--zip-pods` option is not specified, the tool will build a Firebase zip distribution.
16+
17+
For release engineers (Googlers packaging an upcoming Firebase release) these commands should also
18+
be used:
19+
- `--custom-spec-repos sso://cpdc-internal/firebase`
20+
- This pulls the latest podspecs from the CocoaPods staging area.
21+
- `--enable-carthage-build` Turns on generation of Carthage zips and json file updates.
22+
- `--keep-build-artifacts` Useful for debugging and verifying the zip build contents.
23+
24+
Putting them all together, here's a common command to build a releaseable Zip file:
25+
26+
```
27+
swift run zip-builder --update-pod-repo \
28+
--custom-spec-repos sso://cpdc-internal/firebase \
29+
--enable-carthage-build \
30+
--keep-build-artifacts
31+
```
32+
33+
#### Carthage
34+
35+
Carthage binaries can also be built at the same time as the zip file by passing in `--enable-carthage-build`
36+
as a command line argument. This directory should contain JSON files describing versions and download
37+
locations for each product. This will result in a folder called "carthage" at the root where the zip directory exists
38+
containing all the zip files and JSON files necessary for distribution.
39+
40+
## Firebase Releaser
41+
42+
Provides several functions for staging a Firebase release candidate. See the internal go/firi link
43+
for the process documentation.
44+
45+
### Launch Arguments
46+
47+
See `main.swift` for information on specific launch arguments.
48+
49+
You can pass in launch arguments with Xcode by selecting the "firebase-releaser" scheme
50+
beside the Run/Stop buttons, clicking "Edit Scheme" and adding them in the "Arguments Passed On Launch"
51+
section.
52+
53+
## Development Philosophy
54+
55+
The following section describes the priorities taken while building this tool and should be followed
56+
for any modifications.
57+
58+
### Readable and Maintainable
59+
This code will rarely be modified outside of bug fixes, but read very frequently. There should be no
60+
"magic lines" that do multiple things. Verbosity is preferred over making the code shorter and
61+
performing multiple actions at once. All functions should be well documented.
62+
63+
### Avoid Calling bash Commands Where Possible
64+
Instead of using `cat`, `find`, `grep`, or `perl` use `String` APIs to read the contents of a file,
65+
`FileManager` to properly list contents of a directory, `RegularExpression` for pattern matching,
66+
etc. If there's a `Foundation` API available, it should be used.
67+
68+
### Understandable Output
69+
The output of the script should make it immediately obvious if there were any issues and exactly
70+
what those issues were, without looking at the code. It should also be very clear if the Zip file
71+
was properly built and output the file location.
72+
73+
### Show Xcode and API Output on Failures
74+
In the event that there's an Xcode build failure, the logs should be surfaced immediately to aid
75+
debugging. Release engineers should not have to find the Xcode project manually. That being said, a
76+
link to the Xcode project file should be logged as well in case it's necessary. Same goes for errors
77+
logged by exceptions (ex: `FileManager`).
78+
79+
### Testable and Debuggable
80+
Components and functions should be split up in a way that make them easy to test and easy to debug.
81+
Prefer small functions that have proper failure conditions and input validated with `guard`
82+
statements, throwing `fatalError` with a well written error message if it's a critical issue that
83+
prevents the Zip file from being built properly.
84+
85+
### Works from the Command Line or Xcode (Environment Agnostic)
86+
The script should be able to run from the command line to allow for easier automation and Xcode for
87+
simpler debugging and maintenance.
88+
89+
### Any Failure Exits Immediately
90+
The script should not continue if anything necessary for a successful Zip file fails. This includes
91+
things like compiling storyboards, moving resources, missing files, etc. This is to ensure the
92+
integrity of the zip file and that any issues during testing are SDK bugs and not related to the
93+
files and folders.
94+
95+
### Prefer File `URL`s over Strings
96+
Instead of relying on `String`s to represent file paths, use `URL`s as soon as possible to avoid any
97+
missed or double slashes along with other issues.

ReleaseTooling/README.md

Lines changed: 20 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
This project includes Firebase release tooling including a zip builder and a
44
Firebase release candidate creation tool.
55

6-
The tools are designed to fail fast with an explanation of what went wrong, so
7-
you can fix issues or dig in without having to dig too deep into the code.
6+
The rest of this file documents using the `zip-builder` tool. Information about the rest of the
7+
tools for managing Firebase releases and information about developing these tools is at
8+
[DEVELOP.md](DEVELOP.md)
89

910
## Zip Builder
1011

11-
This is a Swift Package Manager project that allows users to package an iOS Zip file of binary
12-
packages.
12+
The `zip-builder` tool generates a zip distribution of binary `.xcframeworks` from an input set of
13+
CocoaPods.
1314

1415
### Requirements
1516

@@ -21,10 +22,10 @@ In order to build the Zip file, you will need:
2122

2223
### Running the Tool
2324

24-
You can run the tool with `swift run zip-builder [ARGS]` or generate an Xcode project with
25-
`swift package generate-xcodeproj` and run within Xcode.
25+
You can run the tool with `swift run zip-builder [ARGS]` or `open Package.swift` to debug or run
26+
within Xcode.
2627

27-
Since Apple does not support linking libraries built by future Xcode versions, make sure to builid with the
28+
Since Apple does not support linking libraries built by future Xcode versions, make sure to build with the
2829
earliest Xcode needed by any of the library clients. The Xcode command line tools must also be configured
2930
for that version. Check with `xcodebuild -version`.
3031

@@ -37,14 +38,12 @@ You can pass in launch arguments with Xcode by clicking "zip-builder" beside the
3738

3839
#### Common Arguments
3940

40-
These arguments assume you're running the command from the `ReleaseTooling` directory.
41+
Use `pods <pods>` to specify the CocoaPods to build.
4142

42-
**Required** arguments:
43+
The `pods` option will choose whatever pods get installed from an unversioned CocoaPods install,
44+
typically the latest versions.
4345

44-
- `--repo-dir <PATH_TO_firebase_ios_sdk_REPO>`
45-
- The root of the `firebase-ios-sdk` repo.
46-
47-
Typical argument (all use cases except Firebase release build):
46+
To explicitly specify the CocoaPods versions, use a JSON specification :
4847
- `--zip-pods <PATH_TO.json>`
4948
- This is a JSON list of the pods to consolidate into a zip of binary frameworks. For example,
5049

@@ -64,90 +63,13 @@ Indicates to install the version 3.2.0 of "GoogleDataTransport" and the latest
6463
version of "FirebaseMessaging". The version string is optional and can be any
6564
valid [CocoaPods Podfile version specifier](https://guides.cocoapods.org/syntax/podfile.html#pod).
6665

67-
68-
Optional common arguments:
66+
Other optional arguments:
6967
- `--no-update-pod-repo`
7068
- This is for speedups when `pod repo update` has already been run recently.
71-
72-
For release engineers (Googlers packaging an upcoming Firebase release) these commands should also be used:
73-
- `--custom-spec-repos sso://cpdc-internal/firebase`
74-
- This pulls the latest podspecs from the CocoaPods staging area.
75-
- `--repo-dir path` GitHub repo containing Template and Carthage json file inputs.
76-
- `--enable-carthage-build` Turns on generation of Carthage zips and json file updates.
77-
- `--keep-build-artifacts` Useful for debugging and verifying the zip build contents.
78-
79-
Putting them all together, here's a common command to build a releaseable Zip file:
80-
81-
```
82-
swift run zip-builder --update-pod-repo \
83-
--repo-dir <PATH_TO_current.firebase_ios_sdk.repo> \
84-
--custom-spec-repos sso://cpdc-internal/firebase \
85-
--enable-carthage-build \
86-
--keep-build-artifacts
87-
```
88-
89-
### Carthage
90-
91-
Carthage binaries can also be built at the same time as the zip file by passing in `--enable-carthage-build`
92-
as a command line argument. This directory should contain JSON files describing versions and download
93-
locations for each product. This will result in a folder called "carthage" at the root where the zip directory exists
94-
containing all the zip files and JSON files necessary for distribution.
95-
96-
## Firebase Releaser
97-
98-
Provides several functions for staging a Firebase release candidate. See the internal go/firi link
99-
for the process documentation.
100-
101-
### Launch Arguments
102-
103-
See `main.swift` for information on specific launch arguments.
104-
105-
You can pass in launch arguments with Xcode by selecting the "firebase-releaser" scheme
106-
beside the Run/Stop buttons, clicking "Edit Scheme" and adding them in the "Arguments Passed On Launch"
107-
section.
108-
109-
## Development Philosophy
110-
111-
The following section describes the priorities taken while building this tool and should be followed
112-
for any modifications.
113-
114-
### Readable and Maintainable
115-
This code will rarely be modified outside of bug fixes, but read very frequently. There should be no
116-
"magic lines" that do multiple things. Verbosity is preferred over making the code shorter and
117-
performing multiple actions at once. All functions should be well documented.
118-
119-
### Avoid Calling bash Commands Where Possible
120-
Instead of using `cat`, `find`, `grep`, or `perl` use `String` APIs to read the contents of a file,
121-
`FileManager` to properly list contents of a directory, `RegularExpression` for pattern matching,
122-
etc. If there's a `Foundation` API available, it should be used.
123-
124-
### Understandable Output
125-
The output of the script should make it immediately obvious if there were any issues and exactly
126-
what those issues were, without looking at the code. It should also be very clear if the Zip file
127-
was properly built and output the file location.
128-
129-
### Show Xcode and API Output on Failures
130-
In the event that there's an Xcode build failure, the logs should be surfaced immediately to aid
131-
debugging. Release engineers should not have to find the Xcode project manually. That being said, a
132-
link to the Xcode project file should be logged as well in case it's necessary. Same goes for errors
133-
logged by exceptions (ex: `FileManager`).
134-
135-
### Testable and Debuggable
136-
Components and functions should be split up in a way that make them easy to test and easy to debug.
137-
Prefer small functions that have proper failure conditions and input validated with `guard`
138-
statements, throwing `fatalError` with a well written error message if it's a critical issue that
139-
prevents the Zip file from being built properly.
140-
141-
### Works from the Command Line or Xcode (Environment Agnostic)
142-
The script should be able to run from the command line to allow for easier automation and Xcode for
143-
simpler debugging and maintenance.
144-
145-
### Any Failure Exits Immediately
146-
The script should not continue if anything necessary for a successful Zip file fails. This includes
147-
things like compiling storyboards, moving resources, missing files, etc. This is to ensure the
148-
integrity of the zip file and that any issues during testing are SDK bugs and not related to the
149-
files and folders.
150-
151-
### Prefer File `URL`s over Strings
152-
Instead of relying on `String`s to represent file paths, use `URL`s as soon as possible to avoid any
153-
missed or double slashes along with other issues.
69+
- `--minimum-ios-version <minimum-ios-version>`
70+
- Change the minimimum iOS version from the default of 10.
71+
- `--output-dir <output-dir>`
72+
- The directory to copy the built Zip file. If this is not set, the path to the Zip file will
73+
be logged to the console.
74+
- `--keep-build-artifacts`
75+
- Keep the build artifacts.

ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,27 @@ public let shared = Manifest(
3030
Pod("FirebaseCore"),
3131
Pod("FirebaseInstallations"),
3232
Pod("FirebaseInstanceID"),
33-
Pod("GoogleAppMeasurement", isClosedSource: true),
34-
Pod("FirebaseAnalytics", isClosedSource: true, zip: true),
33+
Pod("GoogleAppMeasurement", isClosedSource: true, platforms: ["ios"]),
34+
Pod("FirebaseAnalytics", isClosedSource: true, platforms: ["ios"], zip: true),
3535
Pod("FirebaseABTesting", zip: true),
3636
Pod("FirebaseRemoteConfig", zip: true),
37-
Pod("FirebaseAppDistribution", isBeta: true, zip: true),
37+
Pod("FirebaseAppDistribution", isBeta: true, platforms: ["ios"], zip: true),
3838
Pod("FirebaseAuth", zip: true),
3939
Pod("FirebaseCrashlytics", zip: true),
4040
Pod("FirebaseDatabase", zip: true),
41-
Pod("FirebaseDynamicLinks", zip: true),
41+
Pod("FirebaseDynamicLinks", platforms: ["ios"], zip: true),
4242
Pod("FirebaseFirestore", allowWarnings: true, zip: true),
4343
Pod("FirebaseFirestoreSwift", isBeta: true),
4444
Pod("FirebaseFunctions", zip: true),
45-
Pod("FirebaseInAppMessaging", isBeta: true, zip: true),
45+
Pod("FirebaseInAppMessaging", isBeta: true, platforms: ["ios"], zip: true),
4646
Pod("FirebaseMessaging", zip: true),
47-
Pod("FirebasePerformance", zip: true),
47+
Pod("FirebasePerformance", platforms: ["ios"], zip: true),
4848
Pod("FirebaseStorage", zip: true),
4949
Pod("FirebaseStorageSwift", isBeta: true),
50-
Pod("FirebaseMLCommon", isClosedSource: true, isBeta: true),
51-
Pod("FirebaseMLModelInterpreter", isClosedSource: true, isBeta: true, zip: true),
52-
Pod("FirebaseMLVision", isClosedSource: true, isBeta: true, zip: true),
50+
Pod("FirebaseMLCommon", isClosedSource: true, isBeta: true, platforms: ["ios"]),
51+
Pod("FirebaseMLModelInterpreter", isClosedSource: true, isBeta: true, platforms: ["ios"],
52+
zip: true),
53+
Pod("FirebaseMLVision", isClosedSource: true, isBeta: true, platforms: ["ios"], zip: true),
5354
Pod("Firebase", allowWarnings: true, zip: true),
5455
]
5556
)

ReleaseTooling/Sources/FirebaseManifest/Pod.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public struct Pod {
2323
public let isBeta: Bool
2424
public let isFirebase: Bool
2525
public let allowWarnings: Bool // Allow validation warnings. Ideally these should all be false
26+
public let platforms: Set<String> // Set of platforms to build this pod for
2627
public let podVersion: String? // Non-Firebase pods have their own version
2728
public let releasing: Bool // Non-Firebase pods may not release
2829
public let zip: Bool // Top level pod in Zip Distribution
@@ -32,6 +33,7 @@ public struct Pod {
3233
isBeta: Bool = false,
3334
isFirebase: Bool = true,
3435
allowWarnings: Bool = false,
36+
platforms: Set<String> = ["ios", "macos", "tvos"],
3537
podVersion: String? = nil,
3638
releasing: Bool = true,
3739
zip: Bool = false) {
@@ -40,6 +42,7 @@ public struct Pod {
4042
self.isBeta = isBeta
4143
self.isFirebase = isFirebase
4244
self.allowWarnings = allowWarnings
45+
self.platforms = platforms
4346
self.podVersion = podVersion
4447
self.releasing = releasing
4548
self.zip = zip

0 commit comments

Comments
 (0)