Browse Source

Add AppDistribution to SwiftPM. (#7045)

* Add AppDistribution to SwiftPM.

Tests aren't ported yet due to an import OCMock issue.

* Embed public headers in correct directory

* Fix podspec

* Fixed new header imports.

* Add beta designation to SwiftPM name.

* Enable testing for AppDistro in SwiftPM

* Style

* Style

* Added changelog

* Add unit test scheme.
Ryan Wilson 5 years ago
parent
commit
a60866383f

+ 14 - 0
.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'
 

+ 52 - 0
.swiftpm/xcode/xcshareddata/xcschemes/AppDistributionUnit.xcscheme

@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+   LastUpgradeVersion = "1220"
+   version = "1.3">
+   <BuildAction
+      parallelizeBuildables = "YES"
+      buildImplicitDependencies = "YES">
+   </BuildAction>
+   <TestAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      shouldUseLaunchSchemeArgsEnv = "YES">
+      <Testables>
+         <TestableReference
+            skipped = "NO">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "AppDistributionUnit"
+               BuildableName = "AppDistributionUnit"
+               BlueprintName = "AppDistributionUnit"
+               ReferencedContainer = "container:">
+            </BuildableReference>
+         </TestableReference>
+      </Testables>
+   </TestAction>
+   <LaunchAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      launchStyle = "0"
+      useCustomWorkingDirectory = "NO"
+      ignoresPersistentStateOnLaunch = "NO"
+      debugDocumentVersioning = "YES"
+      debugServiceExtension = "internal"
+      allowLocationSimulation = "YES">
+   </LaunchAction>
+   <ProfileAction
+      buildConfiguration = "Release"
+      shouldUseLaunchSchemeArgsEnv = "YES"
+      savedToolIdentifier = ""
+      useCustomWorkingDirectory = "NO"
+      debugDocumentVersioning = "YES">
+   </ProfileAction>
+   <AnalyzeAction
+      buildConfiguration = "Debug">
+   </AnalyzeAction>
+   <ArchiveAction
+      buildConfiguration = "Release"
+      revealArchiveInOrganizer = "YES">
+   </ArchiveAction>
+</Scheme>

+ 1 - 1
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'

+ 1 - 1
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 <AuthenticationServices/AuthenticationServices.h>

+ 1 - 1
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
 

+ 1 - 1
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
 

+ 0 - 0
FirebaseAppDistribution/Sources/Public/FIRAppDistribution.h → FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FIRAppDistribution.h


+ 0 - 0
FirebaseAppDistribution/Sources/Public/FIRAppDistributionRelease.h → FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FIRAppDistributionRelease.h


+ 0 - 0
FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution.h → FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FirebaseAppDistribution.h


+ 10 - 0
FirebaseAppDistribution/Tests/Unit/FIRAppDistributionMachOTests.m

@@ -25,6 +25,16 @@
 
 - (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];

+ 1 - 1
FirebaseAppDistribution/Tests/Unit/FIRAppDistributionTests.m

@@ -13,8 +13,8 @@
 // limitations under the License.
 
 #import <Foundation/Foundation.h>
-#import <OCMock/OCMock.h>
 #import <XCTest/XCTest.h>
+#import "OCMock.h"
 
 #import <GoogleUtilities/GULAppDelegateSwizzler.h>
 #import <GoogleUtilities/GULUserDefaults.h>

+ 1 - 1
FirebaseAppDistribution/Tests/Unit/FIRFADApiServiceTests.m

@@ -13,8 +13,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 #import <Foundation/Foundation.h>
-#import <OCMock/OCMock.h>
 #import <XCTest/XCTest.h>
+#import "OCMock.h"
 
 #import "FirebaseAppDistribution/Sources/FIRFADApiService.h"
 #import "FirebaseAppDistribution/Sources/FIRFADLogger.h"

+ 3 - 0
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.

+ 35 - 0
Package.swift

@@ -36,6 +36,10 @@ let package = Package(
       name: "FirebaseAuth",
       targets: ["FirebaseAuth"]
     ),
+    .library(
+      name: "FirebaseAppDistribution-Beta",
+      targets: ["FirebaseAppDistributionTarget"]
+    ),
     .library(
       name: "FirebaseCrashlytics",
       targets: ["FirebaseCrashlytics"]
@@ -241,6 +245,35 @@ 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("../../"),
+      ]
+    ),
+    .testTarget(
+      name: "AppDistributionUnit",
+      dependencies: ["FirebaseAppDistribution", "OCMock"],
+      path: "FirebaseAppDistribution/Tests/Unit",
+      resources: [.process("Resources")],
+      cSettings: [
+        .headerSearchPath("../../.."),
+      ]
+    ),
+
     .target(
       name: "FirebaseAuth",
       dependencies: ["FirebaseCore",
@@ -729,6 +762,7 @@ let package = Package(
       dependencies: [
         "FirebaseAuth",
         "FirebaseABTesting",
+        "FirebaseAppDistribution",
         "Firebase",
         "FirebaseCrashlytics",
         "FirebaseCore",
@@ -770,6 +804,7 @@ let package = Package(
       dependencies: [
         "FirebaseAuth",
         "FirebaseABTesting",
+        "FirebaseAppDistribution",
         "Firebase",
         "FirebaseCrashlytics",
         "FirebaseCore",

+ 18 - 0
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 <TargetConditionals.h>
+#if !TARGET_OS_IOS
+#warning "Firebase App Distribution only supports the iOS platform"
+#endif

+ 15 - 0
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.

+ 2 - 0
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 <Firebase.h>
 #import <FirebaseABTesting/FirebaseABTesting.h>
+#import <FirebaseAppDistribution/FirebaseAppDistribution.h>
 #import <FirebaseAuth/FirebaseAuth.h>
 #import <FirebaseCore/FirebaseCore.h>
 #import <FirebaseCrashlytics/FirebaseCrashlytics.h>

+ 1 - 0
SwiftPMTests/objc-import-test/objc-module.m

@@ -14,6 +14,7 @@
 
 @import FirebaseAuth;
 @import FirebaseABTesting;
+@import FirebaseAppDistribution;
 @import Firebase;
 @import FirebaseCrashlytics;
 @import FirebaseCore;

+ 1 - 0
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