Skip to content

Commit 08b8567

Browse files
authored
Fix SwiftPM versioning (#6399) (#6400)
1 parent efbe595 commit 08b8567

File tree

4 files changed

+128
-14
lines changed

4 files changed

+128
-14
lines changed

.swiftpm/xcode/xcshareddata/xcschemes/Firebase-Package.xcscheme

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,16 @@
620620
ReferencedContainer = "container:">
621621
</BuildableReference>
622622
</TestableReference>
623+
<TestableReference
624+
skipped = "NO">
625+
<BuildableReference
626+
BuildableIdentifier = "primary"
627+
BlueprintIdentifier = "version-test"
628+
BuildableName = "version-test"
629+
BlueprintName = "version-test"
630+
ReferencedContainer = "container:">
631+
</BuildableReference>
632+
</TestableReference>
623633
</Testables>
624634
</TestAction>
625635
<LaunchAction
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1200"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
</BuildAction>
9+
<TestAction
10+
buildConfiguration = "Debug"
11+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
12+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
13+
shouldUseLaunchSchemeArgsEnv = "YES">
14+
<Testables>
15+
<TestableReference
16+
skipped = "NO">
17+
<BuildableReference
18+
BuildableIdentifier = "primary"
19+
BlueprintIdentifier = "version-test"
20+
BuildableName = "version-test"
21+
BlueprintName = "version-test"
22+
ReferencedContainer = "container:">
23+
</BuildableReference>
24+
</TestableReference>
25+
</Testables>
26+
</TestAction>
27+
<LaunchAction
28+
buildConfiguration = "Debug"
29+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
30+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
31+
launchStyle = "0"
32+
useCustomWorkingDirectory = "NO"
33+
ignoresPersistentStateOnLaunch = "NO"
34+
debugDocumentVersioning = "YES"
35+
debugServiceExtension = "internal"
36+
allowLocationSimulation = "YES">
37+
</LaunchAction>
38+
<ProfileAction
39+
buildConfiguration = "Release"
40+
shouldUseLaunchSchemeArgsEnv = "YES"
41+
savedToolIdentifier = ""
42+
useCustomWorkingDirectory = "NO"
43+
debugDocumentVersioning = "YES">
44+
</ProfileAction>
45+
<AnalyzeAction
46+
buildConfiguration = "Debug">
47+
</AnalyzeAction>
48+
<ArchiveAction
49+
buildConfiguration = "Release"
50+
revealArchiveInOrganizer = "YES">
51+
</ArchiveAction>
52+
</Scheme>

Package.swift

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
import PackageDescription
2424

25+
let firebaseVersion = "6.32.0"
26+
2527
let package = Package(
2628
name: "Firebase",
2729
platforms: [.iOS(.v9), .macOS(.v10_11), .tvOS(.v10)],
@@ -143,8 +145,8 @@ let package = Package(
143145
publicHeadersPath: "Public",
144146
cSettings: [
145147
.headerSearchPath("../.."),
146-
.define("FIRCore_VERSION", to: "0.0.1"), // TODO: Fix version
147-
.define("Firebase_VERSION", to: "0.0.1"), // TODO: Fix version
148+
.define("FIRCore_VERSION", to: firebaseVersion),
149+
.define("Firebase_VERSION", to: firebaseVersion),
148150
// TODO: - Add support for cflags cSetting so that we can set the -fno-autolink option
149151
]
150152
),
@@ -181,7 +183,7 @@ let package = Package(
181183
publicHeadersPath: "Public",
182184
cSettings: [
183185
.headerSearchPath("../../"),
184-
.define("FIRABTesting_VERSION", to: "0.0.1"), // TODO: Fix version
186+
.define("FIRABTesting_VERSION", to: firebaseVersion),
185187
]
186188
),
187189
.testTarget(
@@ -241,7 +243,7 @@ let package = Package(
241243
publicHeadersPath: "Public",
242244
cSettings: [
243245
.headerSearchPath("../../"),
244-
.define("FIRAuth_VERSION", to: "0.0.1"), // TODO: Fix version
246+
.define("FIRAuth_VERSION", to: firebaseVersion),
245247
.define("FIRAuth_MINOR_VERSION", to: "1.1"), // TODO: Fix version
246248
]
247249
),
@@ -286,7 +288,7 @@ let package = Package(
286288
publicHeadersPath: "Crashlytics/Public",
287289
cSettings: [
288290
.headerSearchPath(".."),
289-
.define("DISPLAY_VERSION", to: "0.0.1"), // TODO: Fix version
291+
.define("DISPLAY_VERSION", to: firebaseVersion),
290292
.define("CLS_SDK_NAME", to: "Crashlytics iOS SDK", .when(platforms: .some([.iOS]))),
291293
.define("CLS_SDK_NAME", to: "Crashlytics macOS SDK", .when(platforms: .some([.macOS]))),
292294
.define("CLS_SDK_NAME", to: "Crashlytics tvOS SDK", .when(platforms: .some([.tvOS]))),
@@ -311,7 +313,7 @@ let package = Package(
311313
publicHeadersPath: "Public",
312314
cSettings: [
313315
.headerSearchPath("../../"),
314-
.define("FIRDatabase_VERSION", to: "0.0.1"), // TODO: Fix version
316+
.define("FIRDatabase_VERSION", to: firebaseVersion),
315317
]
316318
),
317319
.testTarget(
@@ -336,7 +338,7 @@ let package = Package(
336338
.headerSearchPath("../../"),
337339
.define("FIRDynamicLinks3P", to: "1"),
338340
.define("GIN_SCION_LOGGING", to: "1"),
339-
.define("FIRDynamicLinks_VERSION", to: "0.0.1"), // TODO: Fix version
341+
.define("FIRDynamicLinks_VERSION", to: firebaseVersion),
340342
]
341343
),
342344

@@ -395,7 +397,7 @@ let package = Package(
395397
.define("PB_FIELD_32BIT", to: "1"),
396398
.define("PB_NO_PACKED_STRUCTS", to: "1"),
397399
.define("PB_ENABLE_MALLOC", to: "1"),
398-
.define("FIRFirestore_VERSION", to: "0.0.1"), // TODO: Fix version
400+
.define("FIRFirestore_VERSION", to: firebaseVersion),
399401
]
400402
),
401403
.target(
@@ -434,7 +436,7 @@ let package = Package(
434436
publicHeadersPath: "Public",
435437
cSettings: [
436438
.headerSearchPath("../../"),
437-
.define("FIRFunctions_VERSION", to: "0.0.1"), // TODO: Fix version
439+
.define("FIRFunctions_VERSION", to: firebaseVersion),
438440
]
439441
),
440442

@@ -456,7 +458,7 @@ let package = Package(
456458
publicHeadersPath: "Public",
457459
cSettings: [
458460
.headerSearchPath("../../"),
459-
.define("FIRInAppMessaging_LIB_VERSION", to: "0.0.1"), // TODO: Fix version
461+
.define("FIRInAppMessaging_LIB_VERSION", to: firebaseVersion),
460462
.define("PB_FIELD_32BIT", to: "1"),
461463
.define("PB_NO_PACKED_STRUCTS", to: "1"),
462464
.define("PB_ENABLE_MALLOC", to: "1"),
@@ -471,7 +473,7 @@ let package = Package(
471473
// publicHeadersPath: "Public",
472474
// cSettings: [
473475
// .headerSearchPath("../../"),
474-
// .define("FIRInstanceID_LIB_VERSION", to: "0.0.1"), // TODO: Fix version
476+
// .define("FIRInstanceID_LIB_VERSION", to: firebaseVersion),
475477
// ]
476478
// ),
477479
.target(
@@ -505,7 +507,7 @@ let package = Package(
505507
publicHeadersPath: "Public",
506508
cSettings: [
507509
.headerSearchPath("../../"),
508-
.define("FIRRemoteConfig_VERSION", to: "0.0.1"), // TODO: Fix version
510+
.define("FIRRemoteConfig_VERSION", to: firebaseVersion),
509511
]
510512
),
511513
.testTarget(
@@ -539,7 +541,7 @@ let package = Package(
539541
publicHeadersPath: "Public",
540542
cSettings: [
541543
.headerSearchPath("../../"),
542-
.define("FIRStorage_VERSION", to: "0.0.1"), // TODO: Fix version
544+
.define("FIRStorage_VERSION", to: firebaseVersion),
543545
]
544546
),
545547
.testTarget(
@@ -638,6 +640,16 @@ let package = Package(
638640
],
639641
path: "SwiftPMTests/objc-import-test"
640642
),
643+
.testTarget(
644+
name: "version-test",
645+
dependencies: [
646+
"FirebaseCore",
647+
],
648+
path: "SwiftPMTests/version-test",
649+
cSettings: [
650+
.define("FIR_VERSION", to: firebaseVersion),
651+
]
652+
),
641653
.target(
642654
name: "GoogleUtilities_AppDelegateSwizzler",
643655
dependencies: ["GoogleUtilities_Environment", "GoogleUtilities_Logger",
@@ -748,7 +760,7 @@ let package = Package(
748760
// "OCMock",
749761
// "GoogleUtilities_AppDelegateSwizzler",
750762
// "GoogleUtilities_Environment",
751-
// // "GoogleUtilities_ISASwizzler", // Build needs to disable ARC.
763+
// "GoogleUtilities_ISASwizzler", // Build needs to disable ARC.
752764
// "GoogleUtilities_Logger",
753765
// "GoogleUtilities_MethodSwizzler",
754766
// "GoogleUtilities_Network",
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#import <Foundation/Foundation.h>
16+
#import <XCTest/XCTest.h>
17+
18+
// TODO(7.0): Move FIRVersion.h to a private header.
19+
FOUNDATION_EXPORT const char *const FIRVersionString;
20+
FOUNDATION_EXPORT const char *const FIRCoreVersionString;
21+
22+
// The following two macros supply the incantation so that the C
23+
// preprocessor does not try to parse the version as a floating
24+
// point number. See
25+
// https://www.guyrutenberg.com/2008/12/20/expanding-macros-into-string-constants-in-c/
26+
#define STR(x) STR_EXPAND(x)
27+
#define STR_EXPAND(x) #x
28+
29+
@interface VersionTest : XCTestCase
30+
@end
31+
32+
@implementation VersionTest
33+
34+
- (void)testVersion {
35+
NSString *version = [NSString stringWithUTF8String:(const char *const)STR(FIR_VERSION)];
36+
XCTAssertEqualObjects([NSString stringWithUTF8String:FIRVersionString], version);
37+
XCTAssertEqualObjects([NSString stringWithUTF8String:FIRCoreVersionString], version);
38+
}
39+
40+
@end

0 commit comments

Comments
 (0)