Skip to content

Commit 442efb8

Browse files
authored
[Sessions] Add Swift Package Manager tests for Sessions (#10572)
1 parent 1fa2b4f commit 442efb8

22 files changed

+238
-37
lines changed

.github/workflows/sessions.yml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,22 @@ jobs:
3535
run: |
3636
scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseSessions.podspec --platforms=${{ matrix.target }}
3737
38-
#
39-
# Uncomment below when Swift Package Manager is implemented
40-
#
41-
# spm:
42-
# # Don't run on private repo unless it is a PR.
43-
# if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
44-
# runs-on: macos-12
45-
# strategy:
46-
# matrix:
47-
# target: [iOS, tvOS, macOS, catalyst, watchOS]
48-
# steps:
49-
# - uses: actions/checkout@v3
50-
# - uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
51-
# with:
52-
# cache_key: ${{ matrix.os }}
53-
# - name: Initialize xcodebuild
54-
# run: scripts/setup_spm_tests.sh
55-
# - name: Unit Tests
56-
# run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseSessions ${{ matrix.target }} spmbuildonly
57-
38+
spm:
39+
# Don't run on private repo unless it is a PR.
40+
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
41+
runs-on: macos-12
42+
strategy:
43+
matrix:
44+
target: [iOS, tvOS, macOS, catalyst, watchOS]
45+
steps:
46+
- uses: actions/checkout@v3
47+
- uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
48+
with:
49+
cache_key: ${{ matrix.os }}
50+
- name: Initialize xcodebuild
51+
run: scripts/setup_spm_tests.sh
52+
- name: Unit Tests
53+
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseSessionsUnit ${{ matrix.target }} spm
5854

5955
catalyst:
6056
# Don't run on private repo unless it is a PR.

FirebaseSessions.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ Pod::Spec.new do |s|
3535

3636
base_dir = "FirebaseSessions/"
3737
s.source_files = [
38-
base_dir + 'Sources/**/*.{swift,h,m}',
39-
base_dir + 'Protogen/**/*.{c,h,m,mm}',
38+
base_dir + 'Sources/**/*.{swift}',
39+
base_dir + 'SourcesObjC/**/*.{c,h,m,mm}',
4040
]
4141

4242
s.dependency 'FirebaseCore', '~> 10.0'

FirebaseSessions/Sources/ApplicationInfo.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@
1616
import Foundation
1717

1818
@_implementationOnly import FirebaseCore
19-
@_implementationOnly import GoogleUtilities
19+
20+
#if SWIFT_PACKAGE
21+
import FirebaseSessionsObjC
22+
#endif // SWIFT_PACKAGE
23+
24+
#if SWIFT_PACKAGE
25+
@_implementationOnly import GoogleUtilities_Environment
26+
#else
27+
@_implementationOnly import GoogleUtilities
28+
#endif // SWIFT_PACKAGE
2029

2130
/// Development environment for the application.
2231
enum DevEnvironment: String {

FirebaseSessions/Sources/Development/DevEventConsoleLogger.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
import Foundation
1717

18+
#if SWIFT_PACKAGE
19+
import FirebaseSessionsObjC
20+
#endif // SWIFT_PACKAGE
21+
1822
class DevEventConsoleLogger: EventGDTLoggerProtocol {
1923
private let commandLineArgument = "-FIRSessionsDebugEvents"
2024

FirebaseSessions/Sources/Development/NanoPB+CustomStringConvertible.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
import Foundation
1717

18+
#if SWIFT_PACKAGE
19+
import FirebaseSessionsObjC
20+
#endif // SWIFT_PACKAGE
21+
1822
///
1923
/// These extensions allows us to console log properties of our Session Events
2024
/// proto for development and debugging purposes without having to call decode

FirebaseSessions/Sources/NetworkInfo.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@
1515

1616
import Foundation
1717

18-
@_implementationOnly import GoogleUtilities
18+
#if SWIFT_PACKAGE
19+
import FirebaseSessionsObjC
20+
#endif // SWIFT_PACKAGE
21+
22+
#if SWIFT_PACKAGE
23+
@_implementationOnly import GoogleUtilities_Environment
24+
#else
25+
@_implementationOnly import GoogleUtilities
26+
#endif // SWIFT_PACKAGE
1927

2028
protocol NetworkInfoProtocol {
2129
var mobileCountryCode: String? { get }

FirebaseSessions/Sources/SessionInitiator.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
// limitations under the License.
1414

1515
import Foundation
16-
#if os(macOS)
16+
#if os(iOS) || os(tvOS)
17+
import UIKit
18+
#elseif os(macOS)
1719
import Cocoa
1820
import AppKit
1921
#elseif os(watchOS)

FirebaseSessions/Sources/SessionStartEvent.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@
1616
import Foundation
1717

1818
@_implementationOnly import GoogleDataTransport
19-
@_implementationOnly import GoogleUtilities
19+
20+
#if SWIFT_PACKAGE
21+
import FirebaseSessionsObjC
22+
#endif // SWIFT_PACKAGE
23+
24+
#if SWIFT_PACKAGE
25+
@_implementationOnly import GoogleUtilities_Environment
26+
#else
27+
@_implementationOnly import GoogleUtilities
28+
#endif // SWIFT_PACKAGE
2029

2130
///
2231
/// SessionStartEvent is responsible for:

FirebaseSessions/Sources/SettingsDownloadClient.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515

1616
import Foundation
1717

18-
@_implementationOnly import GoogleUtilities
18+
#if SWIFT_PACKAGE
19+
@_implementationOnly import GoogleUtilities_Environment
20+
#else
21+
@_implementationOnly import GoogleUtilities
22+
#endif // SWIFT_PACKAGE
1923

2024
protocol SettingsDownloadClient {
2125
func fetch(completion: @escaping (Result<[String: Any], Error>) -> Void)

FirebaseSessions/Sources/NanoPB/FIRSESNanoPBHelpers.h renamed to FirebaseSessions/SourcesObjC/NanoPB/FIRSESNanoPBHelpers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#ifndef FIRSESNanoPBHelpers_h
1717
#define FIRSESNanoPBHelpers_h
1818

19+
#import <Foundation/Foundation.h>
20+
1921
#import <TargetConditionals.h>
2022
#if __has_include("CoreTelephony/CTTelephonyNetworkInfo.h") && !TARGET_OS_MACCATALYST && \
2123
!TARGET_OS_OSX && !TARGET_OS_TV

0 commit comments

Comments
 (0)