From 74554790d00f6072982f48b2aaaf27b7e3a657c1 Mon Sep 17 00:00:00 2001 From: Daniel Kalintsev Date: Mon, 1 Apr 2024 16:53:28 +0200 Subject: [PATCH] feat: add basic support to build frameworks and zip them for the Apple Watch (#12624) --- .../Sources/FirebaseManifest/FirebaseManifest.swift | 12 ++++++------ ReleaseTooling/Sources/FirebaseManifest/Pod.swift | 4 ++-- .../Sources/ZipBuilder/CocoaPodUtils.swift | 4 ++-- ReleaseTooling/Sources/ZipBuilder/Platform.swift | 9 ++++++++- .../Sources/ZipBuilder/TargetPlatform.swift | 11 +++++++++++ ReleaseTooling/Sources/ZipBuilder/main.swift | 7 ++++++- ReleaseTooling/Template/README.md | 2 +- 7 files changed, 36 insertions(+), 13 deletions(-) diff --git a/ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift b/ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift index f145ff7129d..c2c00b45323 100755 --- a/ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift +++ b/ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift @@ -33,9 +33,9 @@ public let shared = Manifest( Pod("FirebaseInstallations"), Pod("FirebaseSessions"), Pod("FirebaseRemoteConfigInterop"), - Pod("GoogleAppMeasurement", isClosedSource: true), + Pod("GoogleAppMeasurement", isClosedSource: true, platforms: ["ios", "macos", "tvos"]), Pod("GoogleAppMeasurementOnDeviceConversion", isClosedSource: true, platforms: ["ios"]), - Pod("FirebaseAnalytics", isClosedSource: true, zip: true), + Pod("FirebaseAnalytics", isClosedSource: true, platforms: ["ios", "macos", "tvos"], zip: true), Pod("FirebaseAnalyticsOnDeviceConversion", platforms: ["ios"], zip: true), Pod("FirebaseABTesting", zip: true), Pod("FirebaseAppCheck", zip: true), @@ -43,17 +43,17 @@ public let shared = Manifest( Pod("FirebaseAppDistribution", isBeta: true, platforms: ["ios"], zip: true), Pod("FirebaseAuth", zip: true), Pod("FirebaseCrashlytics", zip: true), - Pod("FirebaseDatabase", zip: true), + Pod("FirebaseDatabase", platforms: ["ios", "macos", "tvos"], zip: true), Pod("FirebaseDynamicLinks", platforms: ["ios"], zip: true), - Pod("FirebaseFirestoreInternal", allowWarnings: true), - Pod("FirebaseFirestore", allowWarnings: true, zip: true), + Pod("FirebaseFirestoreInternal", allowWarnings: true, platforms: ["ios", "macos", "tvos"]), + Pod("FirebaseFirestore", allowWarnings: true, platforms: ["ios", "macos", "tvos"], zip: true), Pod("FirebaseFunctions", zip: true), Pod("FirebaseInAppMessaging", isBeta: true, platforms: ["ios"], zip: true), Pod("FirebaseMessaging", zip: true), Pod("FirebasePerformance", platforms: ["ios", "tvos"], zip: true), Pod("FirebaseStorage", zip: true), Pod("FirebaseMLModelDownloader", isBeta: true, zip: true), - Pod("Firebase", allowWarnings: true, zip: true), + Pod("Firebase", allowWarnings: true, platforms: ["ios", "tvos", "macos"], zip: true), ] ) diff --git a/ReleaseTooling/Sources/FirebaseManifest/Pod.swift b/ReleaseTooling/Sources/FirebaseManifest/Pod.swift index 47d2d26ee6c..ca11ba35b23 100755 --- a/ReleaseTooling/Sources/FirebaseManifest/Pod.swift +++ b/ReleaseTooling/Sources/FirebaseManifest/Pod.swift @@ -26,7 +26,7 @@ public struct Pod { public let isBeta: Bool /// Allow validation warnings. Ideally these should all be `false`. public let allowWarnings: Bool - /// Set of platforms (e.g. "ios", "macos", or "tvos") to build this pod for. + /// Set of platforms (e.g. "ios", "macos", "tvos", or "watchos") to build this pod for. public let platforms: Set /// Whether or not the pod is planned for publicly releasing (as some pods are for /// internal/testing use). @@ -38,7 +38,7 @@ public struct Pod { isClosedSource: Bool = false, isBeta: Bool = false, allowWarnings: Bool = false, - platforms: Set = ["ios", "macos", "tvos"], + platforms: Set = ["ios", "macos", "tvos", "watchos"], podVersion: String? = nil, releasing: Bool = true, zip: Bool = false) { diff --git a/ReleaseTooling/Sources/ZipBuilder/CocoaPodUtils.swift b/ReleaseTooling/Sources/ZipBuilder/CocoaPodUtils.swift index f554fe2869a..ed74e4c20c7 100644 --- a/ReleaseTooling/Sources/ZipBuilder/CocoaPodUtils.swift +++ b/ReleaseTooling/Sources/ZipBuilder/CocoaPodUtils.swift @@ -50,7 +50,7 @@ enum CocoaPodUtils { init(name: String, version: String?, - platforms: Set = ["ios", "macos", "tvos"]) { + platforms: Set = ["ios", "macos", "tvos", "watchos"]) { self.name = name self.version = version self.platforms = platforms @@ -62,7 +62,7 @@ enum CocoaPodUtils { if let platforms = try container.decodeIfPresent(Set.self, forKey: .platforms) { self.platforms = platforms } else { - platforms = ["ios", "macos", "tvos"] + platforms = ["ios", "macos", "tvos", "watchos"] } if let version = try container.decodeIfPresent(String.self, forKey: .version) { self.version = version diff --git a/ReleaseTooling/Sources/ZipBuilder/Platform.swift b/ReleaseTooling/Sources/ZipBuilder/Platform.swift index f0befce9074..3746d1b9334 100644 --- a/ReleaseTooling/Sources/ZipBuilder/Platform.swift +++ b/ReleaseTooling/Sources/ZipBuilder/Platform.swift @@ -21,12 +21,14 @@ enum Platform: CaseIterable { case iOS case macOS case tvOS + case watchOS var platformTargets: [TargetPlatform] { switch self { case .iOS: return [.iOSDevice, .iOSSimulator] + (SkipCatalyst.skip ? [] : [.catalyst]) case .macOS: return [.macOS] case .tvOS: return [.tvOSDevice, .tvOSSimulator] + case .watchOS: return [.watchOSDevice, .watchOSSimulator] } } @@ -36,6 +38,7 @@ enum Platform: CaseIterable { case .iOS: return "ios" case .macOS: return "macos" case .tvOS: return "tvos" + case .watchOS: return "watchos" } } @@ -45,6 +48,7 @@ enum Platform: CaseIterable { case .iOS: return PlatformMinimum.minimumIOSVersion case .macOS: return PlatformMinimum.minimumMacOSVersion case .tvOS: return PlatformMinimum.minimumTVOSVersion + case .watchOS: return PlatformMinimum.minimumWatchOSVersion } } } @@ -53,10 +57,12 @@ enum PlatformMinimum { fileprivate static var minimumIOSVersion = "" fileprivate static var minimumMacOSVersion = "" fileprivate static var minimumTVOSVersion = "" - static func initialize(ios: String, macos: String, tvos: String) { + fileprivate static var minimumWatchOSVersion = "" + static func initialize(ios: String, macos: String, tvos: String, watchos: String) { minimumIOSVersion = ios minimumMacOSVersion = macos minimumTVOSVersion = tvos + minimumWatchOSVersion = watchos } /// Useful to disable minimum version checking on pod installation. Pods still get built with @@ -65,6 +71,7 @@ enum PlatformMinimum { minimumIOSVersion = "14.0" minimumMacOSVersion = "11.0" minimumTVOSVersion = "14.0" + minimumWatchOSVersion = "8.0" } } diff --git a/ReleaseTooling/Sources/ZipBuilder/TargetPlatform.swift b/ReleaseTooling/Sources/ZipBuilder/TargetPlatform.swift index 6e9773119a8..cb915639359 100644 --- a/ReleaseTooling/Sources/ZipBuilder/TargetPlatform.swift +++ b/ReleaseTooling/Sources/ZipBuilder/TargetPlatform.swift @@ -30,6 +30,10 @@ enum TargetPlatform: CaseIterable { case tvOSDevice /// Binaries to target tvOS simulators. case tvOSSimulator + /// Binaries to target tvOS. + case watchOSDevice + /// Binaries to target tvOS simulators. + case watchOSSimulator /// Valid architectures to be built for the platform. var archs: [Architecture] { @@ -43,6 +47,8 @@ enum TargetPlatform: CaseIterable { case .macOS: return [.x86_64, .arm64] case .tvOSDevice: return [.arm64] case .tvOSSimulator: return [.x86_64, .arm64] + case .watchOSDevice: return [.arm64_32, .arm64] + case .watchOSSimulator: return [.x86_64, .arm64] } } @@ -55,6 +61,8 @@ enum TargetPlatform: CaseIterable { case .macOS: return "macosx" case .tvOSDevice: return "appletvos" case .tvOSSimulator: return "appletvsimulator" + case .watchOSDevice: return "watchos" + case .watchOSSimulator: return "watchsimulator" } } @@ -75,6 +83,8 @@ enum TargetPlatform: CaseIterable { case .macOS: return "Release" case .tvOSDevice: return "Release-appletvos" case .tvOSSimulator: return "Release-appletvsimulator" + case .watchOSDevice: return "Release-watchos" + case .watchOSSimulator: return "Release-watchsimulator" } } } @@ -82,6 +92,7 @@ enum TargetPlatform: CaseIterable { /// Different architectures to build frameworks for. enum Architecture: String, CaseIterable { case arm64 + case arm64_32 case armv7 case i386 case x86_64 diff --git a/ReleaseTooling/Sources/ZipBuilder/main.swift b/ReleaseTooling/Sources/ZipBuilder/main.swift index 25080c6b9e9..757e314581c 100644 --- a/ReleaseTooling/Sources/ZipBuilder/main.swift +++ b/ReleaseTooling/Sources/ZipBuilder/main.swift @@ -111,6 +111,10 @@ struct ZipBuilderTool: ParsableCommand { @Option(default: "12.0", help: ArgumentHelp("The minimum supported tvOS version.")) var minimumTVOSVersion: String + /// The minimum watchOS Version to build for. + @Option(default: "6.0", help: ArgumentHelp("The minimum supported watchOS version.")) + var minimumWatchOSVersion: String + /// The list of platforms to build for. @Option(parsing: .upToNextOption, help: ArgumentHelp(""" @@ -272,7 +276,8 @@ struct ZipBuilderTool: ParsableCommand { // Set the platform minimum versions. PlatformMinimum.initialize(ios: minimumIOSVersion, macos: minimumMacOSVersion, - tvos: minimumTVOSVersion) + tvos: minimumTVOSVersion, + watchos: minimumWatchOSVersion) let (installedPods, frameworks, _) = builder.buildAndAssembleZip(podsToInstall: podsToBuild, diff --git a/ReleaseTooling/Template/README.md b/ReleaseTooling/Template/README.md index 162363e5be7..2767e780572 100644 --- a/ReleaseTooling/Template/README.md +++ b/ReleaseTooling/Template/README.md @@ -1,7 +1,7 @@ # Firebase Apple SDKs This directory contains the full Firebase Apple distribution, packaged as static -xcframeworks that include support for the iOS, tvOS, macOS, and Catalyst +xcframeworks that include support for the iOS, tvOS, macOS, watchOS and Catalyst platforms. # Integration Instructions