mirror of
https://github.com/firebase/firebase-ios-sdk
synced 2026-11-09 22:36:01 +05:45
[Sessions] Add Swift Package Manager tests for Sessions (#10572)
This commit is contained in:
1 parent
1fa2b4f31e
commit
442efb874e
22 files changed
+238
-37
No files matched your search
@@ -35,26 +35,22 @@ jobs:
|
||||
run: |
|
||||
scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseSessions.podspec --platforms=${{ matrix.target }}
|
||||
|
||||
#
|
||||
# Uncomment below when Swift Package Manager is implemented
|
||||
#
|
||||
# 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-12
|
||||
# strategy:
|
||||
# matrix:
|
||||
# target: [iOS, tvOS, macOS, catalyst, watchOS]
|
||||
# steps:
|
||||
# - uses: actions/checkout@v3
|
||||
# - uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
|
||||
# with:
|
||||
# cache_key: ${{ matrix.os }}
|
||||
# - name: Initialize xcodebuild
|
||||
# run: scripts/setup_spm_tests.sh
|
||||
# - name: Unit Tests
|
||||
# run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseSessions ${{ matrix.target }} spmbuildonly
|
||||
|
||||
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-12
|
||||
strategy:
|
||||
matrix:
|
||||
target: [iOS, tvOS, macOS, catalyst, watchOS]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: mikehardy/buildcache-action@c87cea0ccd718971d6cc39e672c4f26815b6c126
|
||||
with:
|
||||
cache_key: ${{ matrix.os }}
|
||||
- name: Initialize xcodebuild
|
||||
run: scripts/setup_spm_tests.sh
|
||||
- name: Unit Tests
|
||||
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseSessionsUnit ${{ matrix.target }} spm
|
||||
|
||||
catalyst:
|
||||
# Don't run on private repo unless it is a PR.
|
||||
|
||||
@@ -35,8 +35,8 @@ Pod::Spec.new do |s|
|
||||
|
||||
base_dir = "FirebaseSessions/"
|
||||
s.source_files = [
|
||||
base_dir + 'Sources/**/*.{swift,h,m}',
|
||||
base_dir + 'Protogen/**/*.{c,h,m,mm}',
|
||||
base_dir + 'Sources/**/*.{swift}',
|
||||
base_dir + 'SourcesObjC/**/*.{c,h,m,mm}',
|
||||
]
|
||||
|
||||
s.dependency 'FirebaseCore', '~> 10.0'
|
||||
|
||||
@@ -16,7 +16,16 @@
|
||||
import Foundation
|
||||
|
||||
@_implementationOnly import FirebaseCore
|
||||
@_implementationOnly import GoogleUtilities
|
||||
|
||||
#if SWIFT_PACKAGE
|
||||
import FirebaseSessionsObjC
|
||||
#endif // SWIFT_PACKAGE
|
||||
|
||||
#if SWIFT_PACKAGE
|
||||
@_implementationOnly import GoogleUtilities_Environment
|
||||
#else
|
||||
@_implementationOnly import GoogleUtilities
|
||||
#endif // SWIFT_PACKAGE
|
||||
|
||||
/// Development environment for the application.
|
||||
enum DevEnvironment: String {
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
#if SWIFT_PACKAGE
|
||||
import FirebaseSessionsObjC
|
||||
#endif // SWIFT_PACKAGE
|
||||
|
||||
class DevEventConsoleLogger: EventGDTLoggerProtocol {
|
||||
private let commandLineArgument = "-FIRSessionsDebugEvents"
|
||||
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
#if SWIFT_PACKAGE
|
||||
import FirebaseSessionsObjC
|
||||
#endif // SWIFT_PACKAGE
|
||||
|
||||
///
|
||||
/// These extensions allows us to console log properties of our Session Events
|
||||
/// proto for development and debugging purposes without having to call decode
|
||||
|
||||
@@ -15,7 +15,15 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@_implementationOnly import GoogleUtilities
|
||||
#if SWIFT_PACKAGE
|
||||
import FirebaseSessionsObjC
|
||||
#endif // SWIFT_PACKAGE
|
||||
|
||||
#if SWIFT_PACKAGE
|
||||
@_implementationOnly import GoogleUtilities_Environment
|
||||
#else
|
||||
@_implementationOnly import GoogleUtilities
|
||||
#endif // SWIFT_PACKAGE
|
||||
|
||||
protocol NetworkInfoProtocol {
|
||||
var mobileCountryCode: String? { get }
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
// limitations under the License.
|
||||
|
||||
import Foundation
|
||||
#if os(macOS)
|
||||
#if os(iOS) || os(tvOS)
|
||||
import UIKit
|
||||
#elseif os(macOS)
|
||||
import Cocoa
|
||||
import AppKit
|
||||
#elseif os(watchOS)
|
||||
|
||||
@@ -16,7 +16,16 @@
|
||||
import Foundation
|
||||
|
||||
@_implementationOnly import GoogleDataTransport
|
||||
@_implementationOnly import GoogleUtilities
|
||||
|
||||
#if SWIFT_PACKAGE
|
||||
import FirebaseSessionsObjC
|
||||
#endif // SWIFT_PACKAGE
|
||||
|
||||
#if SWIFT_PACKAGE
|
||||
@_implementationOnly import GoogleUtilities_Environment
|
||||
#else
|
||||
@_implementationOnly import GoogleUtilities
|
||||
#endif // SWIFT_PACKAGE
|
||||
|
||||
///
|
||||
/// SessionStartEvent is responsible for:
|
||||
|
||||
@@ -15,7 +15,11 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@_implementationOnly import GoogleUtilities
|
||||
#if SWIFT_PACKAGE
|
||||
@_implementationOnly import GoogleUtilities_Environment
|
||||
#else
|
||||
@_implementationOnly import GoogleUtilities
|
||||
#endif // SWIFT_PACKAGE
|
||||
|
||||
protocol SettingsDownloadClient {
|
||||
func fetch(completion: @escaping (Result<[String: Any], Error>) -> Void)
|
||||
|
||||
+2
@@ -16,6 +16,8 @@
|
||||
#ifndef FIRSESNanoPBHelpers_h
|
||||
#define FIRSESNanoPBHelpers_h
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <TargetConditionals.h>
|
||||
#if __has_include("CoreTelephony/CTTelephonyNetworkInfo.h") && !TARGET_OS_MACCATALYST && \
|
||||
!TARGET_OS_OSX && !TARGET_OS_TV
|
||||
+2
-2
@@ -17,9 +17,9 @@
|
||||
|
||||
#import <GoogleUtilities/GULNetworkInfo.h>
|
||||
|
||||
#import "FirebaseSessions/Sources/NanoPB/FIRSESNanoPBHelpers.h"
|
||||
#import "FirebaseSessions/SourcesObjC/NanoPB/FIRSESNanoPBHelpers.h"
|
||||
|
||||
#import "FirebaseSessions/Protogen/nanopb/sessions.nanopb.h"
|
||||
#import "FirebaseSessions/SourcesObjC/Protogen/nanopb/sessions.nanopb.h"
|
||||
|
||||
#import <nanopb/pb.h>
|
||||
#import <nanopb/pb_decode.h>
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
/* Automatically generated nanopb constant definitions */
|
||||
/* Generated by nanopb-0.3.9.9 */
|
||||
|
||||
#include "sessions.nanopb.h"
|
||||
#include "FirebaseSessions/SourcesObjC/Protogen/nanopb/sessions.nanopb.h"
|
||||
|
||||
/* @@protoc_insertion_point(includes) */
|
||||
#if PB_PROTO_HEADER_VERSION != 30
|
||||
File renamed without changes.
@@ -15,7 +15,11 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@_implementationOnly import GoogleUtilities
|
||||
#if SWIFT_PACKAGE
|
||||
@_implementationOnly import GoogleUtilities_Environment
|
||||
#else
|
||||
@_implementationOnly import GoogleUtilities
|
||||
#endif // SWIFT_PACKAGE
|
||||
|
||||
@testable import FirebaseSessions
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import FirebaseInstallations
|
||||
@_implementationOnly import FirebaseInstallations
|
||||
|
||||
@testable import FirebaseSessions
|
||||
|
||||
|
||||
@@ -15,7 +15,11 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@_implementationOnly import GoogleUtilities
|
||||
#if SWIFT_PACKAGE
|
||||
@_implementationOnly import GoogleUtilities_Environment
|
||||
#else
|
||||
@_implementationOnly import GoogleUtilities
|
||||
#endif // SWIFT_PACKAGE
|
||||
|
||||
@testable import FirebaseSessions
|
||||
|
||||
|
||||
@@ -15,7 +15,15 @@
|
||||
|
||||
import XCTest
|
||||
|
||||
@_implementationOnly import GoogleUtilities
|
||||
#if SWIFT_PACKAGE
|
||||
import FirebaseSessionsObjC
|
||||
#endif // SWIFT_PACKAGE
|
||||
|
||||
#if SWIFT_PACKAGE
|
||||
@_implementationOnly import GoogleUtilities_Environment
|
||||
#else
|
||||
@_implementationOnly import GoogleUtilities
|
||||
#endif // SWIFT_PACKAGE
|
||||
|
||||
@testable import FirebaseSessions
|
||||
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
|
||||
import XCTest
|
||||
|
||||
#if SWIFT_PACKAGE
|
||||
import FirebaseSessionsObjC
|
||||
#endif // SWIFT_PACKAGE
|
||||
|
||||
@testable import FirebaseSessions
|
||||
|
||||
// The file and line fields in this function capture the file and line of the
|
||||
|
||||
@@ -19,7 +19,7 @@ readonly DIR="$( git rev-parse --show-toplevel )"
|
||||
|
||||
readonly LIBRARY_DIR="${DIR}/FirebaseSessions/Sources/"
|
||||
readonly PROTO_DIR="${DIR}/FirebaseSessions/ProtoSupport/Protos/"
|
||||
readonly PROTOGEN_DIR="${DIR}/FirebaseSessions/Protogen/"
|
||||
readonly INCLUDE_PREFIX="FirebaseSessions/Protogen/nanopb/"
|
||||
readonly PROTOGEN_DIR="${DIR}/FirebaseSessions/SourcesObjC/Protogen/"
|
||||
readonly INCLUDE_PREFIX="FirebaseSessions/SourcesObjC/Protogen/nanopb/"
|
||||
|
||||
./scripts/nanopb/generate_protos.sh "$PROTO_DIR" "$PROTOGEN_DIR" "$INCLUDE_PREFIX"
|
||||
+66
-1
@@ -160,7 +160,7 @@ let package = Package(
|
||||
.package(
|
||||
name: "GoogleUtilities",
|
||||
url: "https://github.com/google/GoogleUtilities.git",
|
||||
"7.9.0" ..< "8.0.0"
|
||||
"7.10.0" ..< "8.0.0"
|
||||
),
|
||||
.package(
|
||||
name: "GTMSessionFetcher",
|
||||
@@ -1080,6 +1080,70 @@ let package = Package(
|
||||
]
|
||||
),
|
||||
|
||||
// MARK: - Firebase Sessions
|
||||
|
||||
.target(
|
||||
name: "FirebaseSessions",
|
||||
dependencies: [
|
||||
"FirebaseCore",
|
||||
"FirebaseInstallations",
|
||||
"FirebaseCoreExtension",
|
||||
"FirebaseSessionsObjC",
|
||||
.product(name: "GoogleDataTransport", package: "GoogleDataTransport"),
|
||||
.product(name: "GULEnvironment", package: "GoogleUtilities"),
|
||||
],
|
||||
path: "FirebaseSessions/Sources",
|
||||
cSettings: [
|
||||
.headerSearchPath(".."),
|
||||
.define("DISPLAY_VERSION", to: firebaseVersion),
|
||||
.define("PB_FIELD_32BIT", to: "1"),
|
||||
.define("PB_NO_PACKED_STRUCTS", to: "1"),
|
||||
.define("PB_ENABLE_MALLOC", to: "1"),
|
||||
],
|
||||
linkerSettings: [
|
||||
.linkedFramework("Security"),
|
||||
.linkedFramework("SystemConfiguration", .when(platforms: [.iOS, .macOS, .tvOS])),
|
||||
]
|
||||
),
|
||||
// The Sessions SDK is Swift-first with Objective-C code to support
|
||||
// nanopb. Because Swift Package Manager doesn't support mixed
|
||||
// language targets, the ObjC code has been extracted out into
|
||||
// a separate target.
|
||||
.target(
|
||||
name: "FirebaseSessionsObjC",
|
||||
dependencies: [
|
||||
.product(name: "GULEnvironment", package: "GoogleUtilities"),
|
||||
.product(name: "nanopb", package: "nanopb"),
|
||||
],
|
||||
path: "FirebaseSessions",
|
||||
exclude: [
|
||||
"README.md",
|
||||
"Sources/",
|
||||
"Tests/",
|
||||
"ProtoSupport/",
|
||||
"generate_project.sh",
|
||||
"generate_protos.sh",
|
||||
"generate_testapp.sh",
|
||||
],
|
||||
publicHeadersPath: "SourcesObjC",
|
||||
cSettings: [
|
||||
.headerSearchPath(".."),
|
||||
.define("DISPLAY_VERSION", to: firebaseVersion),
|
||||
.define("PB_FIELD_32BIT", to: "1"),
|
||||
.define("PB_NO_PACKED_STRUCTS", to: "1"),
|
||||
.define("PB_ENABLE_MALLOC", to: "1"),
|
||||
],
|
||||
linkerSettings: [
|
||||
.linkedFramework("Security"),
|
||||
.linkedFramework("SystemConfiguration", .when(platforms: [.iOS, .macOS, .tvOS])),
|
||||
]
|
||||
),
|
||||
.testTarget(
|
||||
name: "FirebaseSessionsUnit",
|
||||
dependencies: ["FirebaseSessions"],
|
||||
path: "FirebaseSessions/Tests/Unit"
|
||||
),
|
||||
|
||||
// MARK: - Firebase Storage
|
||||
|
||||
.target(
|
||||
@@ -1146,6 +1210,7 @@ let package = Package(
|
||||
.target(name: "FirebasePerformance",
|
||||
condition: .when(platforms: [.iOS, .tvOS])),
|
||||
"FirebaseRemoteConfig",
|
||||
"FirebaseSessions",
|
||||
"FirebaseStorage",
|
||||
.product(name: "nanopb", package: "nanopb"),
|
||||
],
|
||||
|
||||
@@ -38,6 +38,7 @@ import FirebaseMessaging
|
||||
import FirebasePerformance
|
||||
#endif
|
||||
import FirebaseRemoteConfig
|
||||
import FirebaseSessions
|
||||
import FirebaseStorage
|
||||
import GoogleDataTransport
|
||||
import GoogleUtilities_AppDelegateSwizzler
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1410"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "FirebaseSessionsUnit"
|
||||
BuildableName = "FirebaseSessionsUnit"
|
||||
BlueprintName = "FirebaseSessionsUnit"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "FirebaseSessionsUnit"
|
||||
BuildableName = "FirebaseSessionsUnit"
|
||||
BlueprintName = "FirebaseSessionsUnit"
|
||||
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">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "FirebaseSessionsUnit"
|
||||
BuildableName = "FirebaseSessionsUnit"
|
||||
BlueprintName = "FirebaseSessionsUnit"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
Reference in new issue
Block a user