From 0099a221496ea1b6ccb212c522c8f276a7393f97 Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Thu, 26 Nov 2020 15:21:16 -0500 Subject: [PATCH 01/10] Add AppDistribution to SwiftPM. Tests aren't ported yet due to an import OCMock issue. --- Package.swift | 27 +++++++++++++++++++ .../FirebaseAppDistributionWrap/dummy.m | 18 +++++++++++++ .../include/dummy.h | 15 +++++++++++ SwiftPMTests/objc-import-test/objc-header.m | 2 ++ SwiftPMTests/objc-import-test/objc-module.m | 1 + SwiftPMTests/swift-test/main.swift | 1 + 6 files changed, 64 insertions(+) create mode 100644 SwiftPM-PlatformExclude/FirebaseAppDistributionWrap/dummy.m create mode 100644 SwiftPM-PlatformExclude/FirebaseAppDistributionWrap/include/dummy.h diff --git a/Package.swift b/Package.swift index 3e52a8b5629..00931e752e4 100644 --- a/Package.swift +++ b/Package.swift @@ -36,6 +36,10 @@ let package = Package( name: "FirebaseAuth", targets: ["FirebaseAuth"] ), + .library( + name: "FirebaseAppDistribution", + targets: ["FirebaseAppDistributionTarget"] + ), .library( name: "FirebaseCrashlytics", targets: ["FirebaseCrashlytics"] @@ -241,6 +245,27 @@ let package = Package( checksum: "b0062d581e1bde54a1f6935bde1a49c6718a2a471825e02ab364e2dd8aef69c2" ), + .target( + name: "FirebaseAppDistributionTarget", + dependencies: [.target(name: "FirebaseAppDistribution", + condition: .when(platforms: [.iOS]))], + path: "SwiftPM-PlatformExclude/FirebaseAppDistributionWrap" + ), + + .target( + name: "FirebaseAppDistribution", + dependencies: ["FirebaseCore", + "FirebaseInstallations", + "GoogleDataTransport", + "GoogleUtilities_AppDelegateSwizzler", + "GoogleUtilities_UserDefaults"], + path: "FirebaseAppDistribution/Sources", + publicHeadersPath: "Public", + cSettings: [ + .headerSearchPath("../../"), + ] + ), + .target( name: "FirebaseAuth", dependencies: ["FirebaseCore", @@ -729,6 +754,7 @@ let package = Package( dependencies: [ "FirebaseAuth", "FirebaseABTesting", + "FirebaseAppDistribution", "Firebase", "FirebaseCrashlytics", "FirebaseCore", @@ -770,6 +796,7 @@ let package = Package( dependencies: [ "FirebaseAuth", "FirebaseABTesting", + "FirebaseAppDistribution", "Firebase", "FirebaseCrashlytics", "FirebaseCore", diff --git a/SwiftPM-PlatformExclude/FirebaseAppDistributionWrap/dummy.m b/SwiftPM-PlatformExclude/FirebaseAppDistributionWrap/dummy.m new file mode 100644 index 00000000000..5c9a92ddd1c --- /dev/null +++ b/SwiftPM-PlatformExclude/FirebaseAppDistributionWrap/dummy.m @@ -0,0 +1,18 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import +#if !TARGET_OS_IOS +#warning "Firebase App Distribution only supports the iOS platform" +#endif diff --git a/SwiftPM-PlatformExclude/FirebaseAppDistributionWrap/include/dummy.h b/SwiftPM-PlatformExclude/FirebaseAppDistributionWrap/include/dummy.h new file mode 100644 index 00000000000..5224d0b2249 --- /dev/null +++ b/SwiftPM-PlatformExclude/FirebaseAppDistributionWrap/include/dummy.h @@ -0,0 +1,15 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Prevent a missing umbrella header warning. diff --git a/SwiftPMTests/objc-import-test/objc-header.m b/SwiftPMTests/objc-import-test/objc-header.m index b90a1b6c803..ce6fbedd48d 100644 --- a/SwiftPMTests/objc-import-test/objc-header.m +++ b/SwiftPMTests/objc-import-test/objc-header.m @@ -14,6 +14,7 @@ #import "Firebase.h" #import "FirebaseABTesting/FirebaseABTesting.h" +#import "FirebaseAppDistribution/FirebaseAppDistribution.h" #import "FirebaseAuth/FirebaseAuth.h" #import "FirebaseCore/FirebaseCore.h" #import "FirebaseCrashlytics/FirebaseCrashlytics.h" @@ -29,6 +30,7 @@ #import #import +#import #import #import #import diff --git a/SwiftPMTests/objc-import-test/objc-module.m b/SwiftPMTests/objc-import-test/objc-module.m index b3c5106265e..47d823eb5d6 100644 --- a/SwiftPMTests/objc-import-test/objc-module.m +++ b/SwiftPMTests/objc-import-test/objc-module.m @@ -14,6 +14,7 @@ @import FirebaseAuth; @import FirebaseABTesting; +@import FirebaseAppDistribution; @import Firebase; @import FirebaseCrashlytics; @import FirebaseCore; diff --git a/SwiftPMTests/swift-test/main.swift b/SwiftPMTests/swift-test/main.swift index 8168a7868fa..2853e88965e 100644 --- a/SwiftPMTests/swift-test/main.swift +++ b/SwiftPMTests/swift-test/main.swift @@ -17,6 +17,7 @@ import Firebase import FirebaseCore import FirebaseAuth import FirebaseABTesting +import FirebaseAppDistribution import FirebaseCrashlytics import FirebaseDynamicLinks import FirebaseFirestore From 070d0c9dd4499032d6dee574ed0e65128df0f27b Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Thu, 26 Nov 2020 15:42:23 -0500 Subject: [PATCH 02/10] Embed public headers in correct directory --- .../Public/{ => FirebaseAppDistribution}/FIRAppDistribution.h | 0 .../{ => FirebaseAppDistribution}/FIRAppDistributionRelease.h | 0 .../{ => FirebaseAppDistribution}/FirebaseAppDistribution.h | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename FirebaseAppDistribution/Sources/Public/{ => FirebaseAppDistribution}/FIRAppDistribution.h (100%) rename FirebaseAppDistribution/Sources/Public/{ => FirebaseAppDistribution}/FIRAppDistributionRelease.h (100%) rename FirebaseAppDistribution/Sources/Public/{ => FirebaseAppDistribution}/FirebaseAppDistribution.h (100%) diff --git a/FirebaseAppDistribution/Sources/Public/FIRAppDistribution.h b/FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FIRAppDistribution.h similarity index 100% rename from FirebaseAppDistribution/Sources/Public/FIRAppDistribution.h rename to FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FIRAppDistribution.h diff --git a/FirebaseAppDistribution/Sources/Public/FIRAppDistributionRelease.h b/FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FIRAppDistributionRelease.h similarity index 100% rename from FirebaseAppDistribution/Sources/Public/FIRAppDistributionRelease.h rename to FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FIRAppDistributionRelease.h diff --git a/FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution.h b/FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FirebaseAppDistribution.h similarity index 100% rename from FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution.h rename to FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FirebaseAppDistribution.h From 1c8f35d0b4ded4227ba85b2b7a84cc12ec00f341 Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Thu, 26 Nov 2020 15:51:01 -0500 Subject: [PATCH 03/10] Fix podspec --- FirebaseAppDistribution.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FirebaseAppDistribution.podspec b/FirebaseAppDistribution.podspec index 36a88639ab3..80b6a803b09 100644 --- a/FirebaseAppDistribution.podspec +++ b/FirebaseAppDistribution.podspec @@ -27,7 +27,7 @@ iOS SDK for App Distribution for Firebase. 'FirebaseInstallations/Source/Library/Private/*.h', 'GoogleDataTransport/GDTCORLibrary/Internal/*.h', ] - s.public_header_files = base_dir + 'Public/*.h' + s.public_header_files = base_dir + 'Public/FirebaseAppDistribution/*.h' s.dependency 'FirebaseCore', '~> 7.0' s.dependency 'GoogleUtilities/AppDelegateSwizzler', '~> 7.0' From ef042ad53c6d4c22a7a06a3ead3f7c918964bba5 Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Thu, 26 Nov 2020 16:00:10 -0500 Subject: [PATCH 04/10] Fixed new header imports. --- FirebaseAppDistribution/Sources/FIRAppDistributionUIService.m | 2 +- FirebaseAppDistribution/Sources/Private/FIRAppDistribution.h | 2 +- .../Sources/Private/FIRAppDistributionRelease.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/FirebaseAppDistribution/Sources/FIRAppDistributionUIService.m b/FirebaseAppDistribution/Sources/FIRAppDistributionUIService.m index 95a92c73f2b..4fabe3d15df 100644 --- a/FirebaseAppDistribution/Sources/FIRAppDistributionUIService.m +++ b/FirebaseAppDistribution/Sources/FIRAppDistributionUIService.m @@ -14,7 +14,7 @@ #import "FirebaseAppDistribution/Sources/FIRAppDistributionUIService.h" #import "FirebaseAppDistribution/Sources/FIRFADLogger.h" -#import "FirebaseAppDistribution/Sources/Public/FIRAppDistribution.h" +#import "FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FIRAppDistribution.h" #import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h" #import diff --git a/FirebaseAppDistribution/Sources/Private/FIRAppDistribution.h b/FirebaseAppDistribution/Sources/Private/FIRAppDistribution.h index 2d7ab0e9e1c..ced542f13aa 100644 --- a/FirebaseAppDistribution/Sources/Private/FIRAppDistribution.h +++ b/FirebaseAppDistribution/Sources/Private/FIRAppDistribution.h @@ -13,7 +13,7 @@ // limitations under the License. #import "FirebaseAppDistribution/Sources/FIRAppDistributionUIService.h" -#import "FirebaseAppDistribution/Sources/Public/FIRAppDistribution.h" +#import "FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FIRAppDistribution.h" NS_ASSUME_NONNULL_BEGIN diff --git a/FirebaseAppDistribution/Sources/Private/FIRAppDistributionRelease.h b/FirebaseAppDistribution/Sources/Private/FIRAppDistributionRelease.h index 1f334d0bc25..799173dfa1f 100644 --- a/FirebaseAppDistribution/Sources/Private/FIRAppDistributionRelease.h +++ b/FirebaseAppDistribution/Sources/Private/FIRAppDistributionRelease.h @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#import "FirebaseAppDistribution/Sources/Public/FIRAppDistributionRelease.h" +#import "FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FIRAppDistributionRelease.h" NS_ASSUME_NONNULL_BEGIN From cbe99d8fac806b3384d4ef12524a3ca2c5f9c9d6 Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Thu, 26 Nov 2020 16:05:12 -0500 Subject: [PATCH 05/10] Add beta designation to SwiftPM name. --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 00931e752e4..6fd6aca9871 100644 --- a/Package.swift +++ b/Package.swift @@ -37,7 +37,7 @@ let package = Package( targets: ["FirebaseAuth"] ), .library( - name: "FirebaseAppDistribution", + name: "FirebaseAppDistribution-Beta", targets: ["FirebaseAppDistributionTarget"] ), .library( From d0c0e192af746703d4853538fce3ebb83e4d50aa Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Wed, 2 Dec 2020 08:15:09 -0500 Subject: [PATCH 06/10] Enable testing for AppDistro in SwiftPM --- .github/workflows/appdistribution.yml | 14 ++++++++++++++ .../Tests/Unit/FIRAppDistributionMachOTests.m | 10 ++++++++++ .../Tests/Unit/FIRAppDistributionTests.m | 2 +- .../Tests/Unit/FIRFADApiServiceTests.m | 2 +- Package.swift | 10 +++++++++- 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/.github/workflows/appdistribution.yml b/.github/workflows/appdistribution.yml index ec2278d778b..6785017670c 100644 --- a/.github/workflows/appdistribution.yml +++ b/.github/workflows/appdistribution.yml @@ -29,6 +29,20 @@ jobs: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseAppDistribution.podspec \ --platforms=${{ matrix.target }} + spm: + # Don't run on private repo unless it is a PR. + if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request' + + runs-on: macOS-latest + steps: + - uses: actions/checkout@v2 + - name: Xcode 12 + run: sudo xcode-select -s /Applications/Xcode_12.app/Contents/Developer + - name: Initialize xcodebuild + run: xcodebuild -list + - name: iOS Unit Tests + run: scripts/third_party/travis/retry.sh ./scripts/build.sh AppDistributionUnit iOS spm + appdistribution-cron-only: if: github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk' diff --git a/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionMachOTests.m b/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionMachOTests.m index 512c465c4c1..e558e9ea1bd 100644 --- a/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionMachOTests.m +++ b/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionMachOTests.m @@ -25,6 +25,16 @@ @implementation FIRAppDistributionMachOTests - (NSString*)resourcePath:(NSString*)path { NSBundle* bundle = [NSBundle bundleForClass:[self class]]; + + // Swift Package Manager uses a different bundle structure for resources, so explicitly get the + // nested bundle. In Swift we could have used `Bundle.module` to access it, but that isn't + // surfaced in ObjC. +#if SWIFT_PACKAGE + NSString *nestedBundlePath = [bundle pathForResource:@"Firebase_AppDistributionUnit" + ofType:@"bundle"];; + bundle = [NSBundle bundleWithPath:nestedBundlePath]; +#endif // SWIFT_PACKAGE + NSString* resourcePath = [bundle resourcePath]; return [resourcePath stringByAppendingPathComponent:path]; diff --git a/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionTests.m b/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionTests.m index 986d0b0a2f2..90114c4944f 100644 --- a/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionTests.m +++ b/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionTests.m @@ -13,8 +13,8 @@ // limitations under the License. #import -#import #import +#import "OCMock.h" #import #import diff --git a/FirebaseAppDistribution/Tests/Unit/FIRFADApiServiceTests.m b/FirebaseAppDistribution/Tests/Unit/FIRFADApiServiceTests.m index 041a0b0f6d0..955c194d51b 100644 --- a/FirebaseAppDistribution/Tests/Unit/FIRFADApiServiceTests.m +++ b/FirebaseAppDistribution/Tests/Unit/FIRFADApiServiceTests.m @@ -13,8 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. #import -#import #import +#import "OCMock.h" #import "FirebaseAppDistribution/Sources/FIRFADApiService.h" #import "FirebaseAppDistribution/Sources/FIRFADLogger.h" diff --git a/Package.swift b/Package.swift index 6fd6aca9871..cd99884182a 100644 --- a/Package.swift +++ b/Package.swift @@ -251,7 +251,6 @@ let package = Package( condition: .when(platforms: [.iOS]))], path: "SwiftPM-PlatformExclude/FirebaseAppDistributionWrap" ), - .target( name: "FirebaseAppDistribution", dependencies: ["FirebaseCore", @@ -265,6 +264,15 @@ let package = Package( .headerSearchPath("../../"), ] ), + .testTarget( + name: "AppDistributionUnit", + dependencies: ["FirebaseAppDistribution", "OCMock"], + path: "FirebaseAppDistribution/Tests/Unit", + resources: [.process("Resources")], + cSettings: [ + .headerSearchPath("../../.."), + ] + ), .target( name: "FirebaseAuth", From ea8ec16eb3a6991c0a24b854483f5b7ae024a062 Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Wed, 2 Dec 2020 08:21:10 -0500 Subject: [PATCH 07/10] Style --- .../Tests/Unit/FIRAppDistributionMachOTests.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionMachOTests.m b/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionMachOTests.m index e558e9ea1bd..3b38b3565b6 100644 --- a/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionMachOTests.m +++ b/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionMachOTests.m @@ -30,8 +30,9 @@ - (NSString*)resourcePath:(NSString*)path { // nested bundle. In Swift we could have used `Bundle.module` to access it, but that isn't // surfaced in ObjC. #if SWIFT_PACKAGE - NSString *nestedBundlePath = [bundle pathForResource:@"Firebase_AppDistributionUnit" - ofType:@"bundle"];; + NSString* nestedBundlePath = [bundle pathForResource:@"Firebase_AppDistributionUnit" + ofType:@"bundle"]; + ; bundle = [NSBundle bundleWithPath:nestedBundlePath]; #endif // SWIFT_PACKAGE From 1fccd1661fd4f9fdda503ce6b37b7f0e0e18bba9 Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Wed, 2 Dec 2020 08:21:31 -0500 Subject: [PATCH 08/10] Style --- .../Tests/Unit/FIRAppDistributionMachOTests.m | 1 - 1 file changed, 1 deletion(-) diff --git a/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionMachOTests.m b/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionMachOTests.m index 3b38b3565b6..db67279933e 100644 --- a/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionMachOTests.m +++ b/FirebaseAppDistribution/Tests/Unit/FIRAppDistributionMachOTests.m @@ -32,7 +32,6 @@ - (NSString*)resourcePath:(NSString*)path { #if SWIFT_PACKAGE NSString* nestedBundlePath = [bundle pathForResource:@"Firebase_AppDistributionUnit" ofType:@"bundle"]; - ; bundle = [NSBundle bundleWithPath:nestedBundlePath]; #endif // SWIFT_PACKAGE From 76e722022d92edd67d40b16b7faf542a8e61924c Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Wed, 2 Dec 2020 08:36:28 -0500 Subject: [PATCH 09/10] Added changelog --- FirebaseCore/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FirebaseCore/CHANGELOG.md b/FirebaseCore/CHANGELOG.md index ac78ec6b540..133e8454b62 100644 --- a/FirebaseCore/CHANGELOG.md +++ b/FirebaseCore/CHANGELOG.md @@ -1,3 +1,6 @@ +# Firebase 7.3.0 +- [added] Added FirebaseAppDistribution-Beta product to Swift Package Manager. (#7045) + # Firebase 7.2.0 - [fixed] Reduced `FirebaseApp.configure()` and `+[FIRApp registerInternalLibrary:withName:]` impact on app launch time. (#6902) - [added] Added arm64 simulator support to support new Apple silicon based Macs. From 36f3ac5f45a2b4a6355c5d977ec7e6b6fc5e28fd Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Wed, 2 Dec 2020 09:17:09 -0500 Subject: [PATCH 10/10] Add unit test scheme. --- .../xcschemes/AppDistributionUnit.xcscheme | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .swiftpm/xcode/xcshareddata/xcschemes/AppDistributionUnit.xcscheme diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/AppDistributionUnit.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/AppDistributionUnit.xcscheme new file mode 100644 index 00000000000..9fb15f6103d --- /dev/null +++ b/.swiftpm/xcode/xcshareddata/xcschemes/AppDistributionUnit.xcscheme @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + +