Skip to content

Commit 1793deb

Browse files
authored
Update C++/Obj C++ support for Firebase 9 (#9644)
1 parent 071902b commit 1793deb

File tree

12 files changed

+334
-14
lines changed

12 files changed

+334
-14
lines changed

.github/workflows/functions.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ jobs:
3030
runs-on: macos-11
3131
strategy:
3232
matrix:
33-
# TODO: The --skip-tests might be removable with Xcode 13.2+
34-
target: [ios, tvos, macos --skip-tests, watchos]
33+
target: [ios, tvos, macos, watchos]
3534
steps:
3635
- uses: actions/checkout@v2
3736
- name: Setup Bundler

CoreOnly/Sources/Firebase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#endif
5252
5353
#if __has_include("FirebaseFunctions-umbrella.h")
54-
@import FirebaseFunctions;
54+
#import <FirebaseFunctions/FirebaseFunctions-Swift.h>
5555
#endif
5656
5757
#if __has_include(<FirebaseInAppMessaging/FirebaseInAppMessaging.h>)
@@ -75,7 +75,7 @@
7575
#endif
7676
7777
#if __has_include("FirebaseStorage-umbrella.h")
78-
@import FirebaseStorage;
78+
#import <FirebaseStorage/FirebaseStorage-Swift.h>
7979
#endif
8080
8181
#endif // defined(__has_include)

CoreOnly/Tests/FirebasePodTest/FirebasePodTest/AppDelegate.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import Firebase
1818
import FirebaseAnalyticsSwift
1919
import FirebaseFirestoreSwift
2020
import FirebaseInAppMessagingSwift
21-
import FirebaseStorage
2221

2322
class CoreExists: FirebaseApp {}
2423
class AnalyticsExists: Analytics {}

FirebaseCore/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
- [added] The zip and Carthage distibutions now include the Swift extension frameworks. (#7819)
44
- [changed] **Breaking change**: Update the minimum supported versions for the zip and Carthage
55
distributions to iOS 11.0, tvOS 11.0 and macOS 10.13. (#9633)
6+
- [changed] **Breaking change**: CocoaPods Podfiles must include `use_frameworks!` or
7+
`use_frameworks! :linkage => :static`.
8+
- [deprecated] Usage of the Firebase pod, the Firebase module (`import Firebase`), and `Firebase.h`
9+
is deprecated. Use the specific Firebase product instead like: `pod 'FirebaseMessaging'` and
10+
`import FirebaseMessaging`.
11+
- [changed] For Swift Package Manager installations, `import Firebase` will no longer implicitly
12+
import Firebase Storage and Firebase Functions APIs. Use `import FirebaseStorage` and
13+
`import FirebaseFunctions`.
14+
- [changed] C++/Objective C++ clients should use `#import <FirebaseFunctions/FirebaseFunctions-Swift.h>`
15+
and `#import <FirebaseStorage/FirebaseStorage-Swift.h>` to access Functions and Storage APIs,
16+
respectively. C++/Objective C++ clients using Swift Package Manager should find alternative
17+
workarounds at https://forums.swift.org/t/importing-swift-libraries-from-objective-c/56730.
618

719
# Firebase 8.10.0
820
- [fixed] Fixed platform availability checks in Swift Package Manager that may prevent code

FirebaseFunctions.podspec

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ Cloud Functions for Firebase.
4545
s.dependency 'FirebaseSharedSwift', '~> 9.0'
4646
s.dependency 'GTMSessionFetcher/Core', '~> 1.5'
4747

48+
s.test_spec 'objc' do |objc_tests|
49+
objc_tests.platforms = {
50+
:ios => ios_deployment_target,
51+
:osx => '10.15',
52+
:tvos => tvos_deployment_target
53+
}
54+
objc_tests.source_files = [
55+
'FirebaseFunctions/Tests/ObjCIntegration/ObjC*'
56+
]
57+
end
58+
4859
s.test_spec 'integration' do |int_tests|
4960
int_tests.platforms = {
5061
:ios => ios_deployment_target,

FirebaseFunctions/Tests/ObjCIntegration/ObjCAPITests.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ - (void)apis {
3535

3636
FIRHTTPSCallable *callable = [func HTTPSCallableWithName:@"name"];
3737

38-
[func useEmulatorWithHost:@"host" port:@"port"];
38+
[func useEmulatorWithHost:@"host" port:123];
3939

4040
#pragma mark - HTTPSCallable and HTTPSCallableResult
4141
[callable
@@ -73,5 +73,6 @@ - (FIRFunctionsErrorCode)errorCodes:(NSError *)error {
7373
case FIRFunctionsErrorCodeUnauthenticated:
7474
return error.code;
7575
}
76+
return error.code;
7677
}
7778
@end
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// Copyright 2022 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 <XCTest/XCTest.h>
16+
17+
#import <FirebaseFunctions/FirebaseFunctions-Swift.h>
18+
#import "FirebaseCore/FirebaseCore.h"
19+
20+
@interface ObjCPPAPICoverage : XCTestCase
21+
@end
22+
23+
@implementation ObjCPPAPICoverage
24+
25+
- (void)apis {
26+
#pragma mark - Functions
27+
28+
FIRApp *app = [FIRApp defaultApp];
29+
FIRFunctions *func = [FIRFunctions functions];
30+
func = [FIRFunctions functionsForApp:app];
31+
func = [FIRFunctions functionsForRegion:@"my-region"];
32+
func = [FIRFunctions functionsForCustomDomain:@"my-domain"];
33+
func = [FIRFunctions functionsForApp:app region:@"my-region"];
34+
func = [FIRFunctions functionsForApp:app customDomain:@"my-domain"];
35+
36+
FIRHTTPSCallable *callable = [func HTTPSCallableWithName:@"name"];
37+
38+
[func useEmulatorWithHost:@"host" port:123];
39+
40+
#pragma mark - HTTPSCallable and HTTPSCallableResult
41+
[callable
42+
callWithCompletion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) {
43+
__unused id data = result.data;
44+
}];
45+
[callable callWithObject:nil
46+
completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) {
47+
[result data];
48+
}];
49+
callable.timeoutInterval = 60;
50+
[callable timeoutInterval];
51+
}
52+
53+
#pragma mark - FunctionsError
54+
55+
- (FIRFunctionsErrorCode)errorCodes:(NSError *)error {
56+
switch (error.code) {
57+
case FIRFunctionsErrorCodeOK:
58+
case FIRFunctionsErrorCodeCancelled:
59+
case FIRFunctionsErrorCodeUnknown:
60+
case FIRFunctionsErrorCodeInvalidArgument:
61+
case FIRFunctionsErrorCodeDeadlineExceeded:
62+
case FIRFunctionsErrorCodeNotFound:
63+
case FIRFunctionsErrorCodeAlreadyExists:
64+
case FIRFunctionsErrorCodePermissionDenied:
65+
case FIRFunctionsErrorCodeResourceExhausted:
66+
case FIRFunctionsErrorCodeFailedPrecondition:
67+
case FIRFunctionsErrorCodeAborted:
68+
case FIRFunctionsErrorCodeOutOfRange:
69+
case FIRFunctionsErrorCodeUnimplemented:
70+
case FIRFunctionsErrorCodeInternal:
71+
case FIRFunctionsErrorCodeUnavailable:
72+
case FIRFunctionsErrorCodeDataLoss:
73+
case FIRFunctionsErrorCodeUnauthenticated:
74+
return (FIRFunctionsErrorCode)error.code;
75+
}
76+
return (FIRFunctionsErrorCode)error.code;
77+
}
78+
@end

FirebaseStorage.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Firebase Storage provides robust, secure file uploads and downloads from Firebas
5454
}
5555
objc_tests.source_files = [
5656
'FirebaseStorageInternal/Tests/Integration/*.[mh]',
57-
'FirebaseStorage/Tests/ObjCIntegration/*.m',
57+
'FirebaseStorage/Tests/ObjCIntegration/*.{m,mm}',
5858
]
5959
objc_tests.requires_app_host = true
6060
objc_tests.resources = 'FirebaseStorageInternal/Tests/Integration/Resources/1mb.dat',

FirebaseStorage/Tests/ObjCIntegration/ObjCAPITests.m

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,6 @@ - (void)FIRStorageConstantsTypedefs {
115115
}
116116
#endif
117117

118-
#ifdef Firebase9Breaking
119-
- (NSString *)FIRStorageConstantsGlobal {
120-
return FIRStorageErrorDomain;
121-
}
122-
#endif
123-
124118
- (void)FIRStorageListResultApis:(FIRStorageListResult *)result {
125119
NSArray<FIRStorageReference *> __unused *prefixes = [result prefixes];
126120
NSArray<FIRStorageReference *> __unused *items = [result items];

0 commit comments

Comments
 (0)