Skip to content

Commit 8c770f5

Browse files
authored
Use CaseIterable from Xcode 10. (#2484)
Now that Apple requires Xcode 10.1+ to submit to the App Store, we can package the Zip file using Xcode 10.1.
1 parent 6f7ba7a commit 8c770f5

File tree

4 files changed

+6
-59
lines changed

4 files changed

+6
-59
lines changed

ZipBuilder/Sources/ZipBuilder/FrameworkBuilder.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import Foundation
1818

1919
/// Different architectures to build frameworks for.
20-
private enum Architecture: String {
20+
private enum Architecture: String, CaseIterable {
2121
/// The target platform that the framework is built for.
2222
enum TargetPlatform: String {
2323
case device = "iphoneos"
@@ -48,11 +48,6 @@ private enum Architecture: String {
4848
case .i386, .x86_64: return .simulator
4949
}
5050
}
51-
52-
// TODO: Once we default to Swift 4.2 (in Xcode 10) we can conform to "CaseIterable" protocol to
53-
// automatically generate this method.
54-
/// All the architectures to parse.
55-
public static func allCases() -> [Architecture] { return [.arm64, .armv7, .i386, .x86_64] }
5651
}
5752

5853
/// A structure to build a .framework in a given project directory.
@@ -356,7 +351,7 @@ struct FrameworkBuilder {
356351
// TODO: Pass in supported architectures here, for those that don't support individual
357352
// architectures (MLKit).
358353
var thinArchives = [URL]()
359-
for arch in Architecture.allCases() {
354+
for arch in Architecture.allCases {
360355
let buildDir = projectDir.appendingPathComponent(arch.rawValue)
361356
let thinArchive = buildThin(framework: framework,
362357
arch: arch,

ZipBuilder/Sources/ZipBuilder/LaunchArgs.swift

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ extension FileManager: FileChecker {}
3838
/// `-myKey myValue`.
3939
struct LaunchArgs {
4040
/// Keys associated with the launch args. See `Usage` for descriptions of each flag.
41-
private enum Key: String {
41+
private enum Key: String, CaseIterable {
4242
case cacheEnabled
4343
case customSpecRepos
4444
case coreDiagnosticsDir
@@ -76,21 +76,6 @@ struct LaunchArgs {
7676
return "A flag to run `pod repo update` before building the zip file."
7777
}
7878
}
79-
80-
// TODO: Once we default to Swift 4.2 (in Xcode 10) we can conform to "CaseIterable" protocol to
81-
// automatically generate this method.
82-
/// All the subspecs to parse.
83-
static func allCases() -> [Key] {
84-
return [.cacheEnabled,
85-
.coreDiagnosticsDir,
86-
.customSpecRepos,
87-
.deleteCache,
88-
.existingVersions,
89-
.outputDir,
90-
.releasingSDKs,
91-
.templateDir,
92-
.updatePodRepo]
93-
}
9479
}
9580

9681
/// A file URL to a textproto with the contents of a `ZipBuilder_FirebaseSDKs` object. Used to
@@ -232,7 +217,7 @@ struct LaunchArgs {
232217

233218
// Loop over all the possible keys and print their description.
234219
print("Usage: `swift run ZipBuilder [ARGS]` where args are:")
235-
for option in Key.allCases() {
220+
for option in Key.allCases {
236221
print("""
237222
-\(option.rawValue) <VALUE>
238223
\(option.usage)

ZipBuilder/Sources/ZipBuilder/Subspec.swift

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Foundation
1818

1919
// TODO: Auto generate this list from the Firebase.podspec, probably with a script.
2020
/// All the subspecs available in the Firebase pod.
21-
public enum Subspec: String {
21+
public enum Subspec: String, CaseIterable {
2222
case abTesting = "ABTesting"
2323
case adMob = "AdMob"
2424
case analytics = "Analytics"
@@ -55,39 +55,6 @@ public enum Subspec: String {
5555
}
5656
}
5757

58-
// TODO: Once we default to Swift 4.2 (in Xcode 10) we can conform to "CaseIterable" protocol to
59-
// automatically generate this method.
60-
/// All the subspecs to parse.
61-
public static func allCases() -> [Subspec] {
62-
return [
63-
.abTesting,
64-
.adMob,
65-
.analytics,
66-
.auth,
67-
.core,
68-
.crash,
69-
.database,
70-
.dynamicLinks,
71-
.firestore,
72-
.functions,
73-
.inAppMessaging,
74-
.inAppMessagingDisplay,
75-
.invites,
76-
.messaging,
77-
.mlModelInterpreter,
78-
.mlNaturalLanguage,
79-
.mlNLLanguageID,
80-
.mlVision,
81-
.mlVisionBarcodeModel,
82-
.mlVisionFaceModel,
83-
.mlVisionLabelModel,
84-
.mlVisionTextModel,
85-
.performance,
86-
.remoteConfig,
87-
.storage,
88-
]
89-
}
90-
9158
/// The minimum supported iOS version.
9259
public func minSupportedIOSVersion() -> OperatingSystemVersion {
9360
// All ML pods have a minimum iOS version of 9.0.

ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ struct ZipBuilder {
180180

181181
// Break the `subspecsToInstall` into a variable since it's helpful when debugging non-cache
182182
// builds to just install a subset: `[.core, .analytics, .storage, .firestore]` for example.
183-
let subspecsToInstall = Subspec.allCases()
183+
let subspecsToInstall = Subspec.allCases
184184

185185
// We need to install all the subpsecs in order to get every single framework that we'll need
186186
// for the zip file. We can't install each one individually since some pods depend on different

0 commit comments

Comments
 (0)