Skip to content

Commit 87a206e

Browse files
authored
Functions Interop (#2113)
* Functions Interop Convert Firebase Functions to use the Auth Interop pod * Style FIxes * Style fixes (from clang-format 7) * Attempt to fix Travis Build * Add Firebase/Core/Private to header search path * Switch to using non-internal header * Add Firebase Core private headers to search path * Change Podfile to use Interop pods I also removed a doubly-defined `FRAMEWORK_SEARCH_PATHS` * Add Private Headers to search path I also cleaned up some more project settings * PR Feedback * Looking for container headers * PR Feedback I also attempted moving the FakeApp class to the test targets and further simplified the project file. * Re-add -all_load * Set test target headers I also moved the Podfile pods to the app target rather than the top-level * Whitespace * Re-add FirebaseFunctions to search path * Revert project file back to origin/master * Found the headers! - Remove `FUNFakeApp` from app target + Add `FUNFakeApp` to test targets + Add `$(inherited)` to `HEADER_SEARCH_PATH` as per CocoaPods warning + Add `$(SRCROOT)/../../Firebase/Core/Private` to find `FIRComponentContainerInternal` header ~ Change import from frameworks import to regular import * Revert xcsheme to previous version * Update FIRFunctions.m * CL Feedback - Delete `FUNFakeApp` + Add `FIRAuthInteropFake` to test targets ~ Update initializer to use projectID instead of app * Style fixes * CL Feedback * Fix Integration tests * Set the region to the expected value * Update node package.json to latest versions
1 parent 522f012 commit 87a206e

File tree

12 files changed

+132
-176
lines changed

12 files changed

+132
-176
lines changed

FirebaseFunctions.podspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ iOS SDK for Cloud Functions for Firebase.
2424
s.source_files = 'Functions/FirebaseFunctions/**/*'
2525
s.public_header_files = 'Functions/FirebaseFunctions/Public/*.h'
2626

27-
s.dependency 'FirebaseCore', '~> 5.0'
27+
s.dependency 'FirebaseAuthInterop', '~> 1.0'
28+
s.dependency 'FirebaseCore', '~> 5.1'
2829
s.dependency 'GTMSessionFetcher/Core', '~> 1.1'
2930

3031
s.pod_target_xcconfig = {

Functions/Backend/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"name": "functions",
33
"description": "Cloud Functions for Firebase",
44
"dependencies": {
5-
"firebase-admin": "~4.2.1",
6-
"firebase-functions": "^0.5.7"
5+
"firebase-admin": "^6.0.0",
6+
"firebase-functions": "^2.1.0"
77
},
88
"private": true,
99
"devDependencies": {
10-
"@google-cloud/functions-emulator": "^1.0.0-alpha.21"
10+
"@google-cloud/functions-emulator": "^1.0.0-beta.5"
1111
}
1212
}

Functions/Example/FirebaseFunctions.xcodeproj/project.pbxproj

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
7CBFAA88205702AB00A65866 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; };
2929
7CBFAA8B205702AB00A65866 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; };
3030
7CF3BEC21F97EE2F00B16B6E /* FUNFakeInstanceID.m in Sources */ = {isa = PBXBuildFile; fileRef = 7CF3BEC01F97EE2F00B16B6E /* FUNFakeInstanceID.m */; };
31-
7CF563091F1FE70600FEE1F4 /* FUNFakeApp.m in Sources */ = {isa = PBXBuildFile; fileRef = 7CF563081F1FE70600FEE1F4 /* FUNFakeApp.m */; };
3231
873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; };
32+
C8AEC40B21B7EE440051C01E /* FIRAuthInteropFake.m in Sources */ = {isa = PBXBuildFile; fileRef = C8AEC40A21B7EE440051C01E /* FIRAuthInteropFake.m */; };
3333
/* End PBXBuildFile section */
3434

3535
/* Begin PBXContainerItemProxy section */
@@ -74,9 +74,9 @@
7474
7CBFAA91205702AB00A65866 /* FirebaseFunctions_IntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FirebaseFunctions_IntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
7575
7CF3BEC01F97EE2F00B16B6E /* FUNFakeInstanceID.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUNFakeInstanceID.m; sourceTree = "<group>"; };
7676
7CF3BEC11F97EE2F00B16B6E /* FUNFakeInstanceID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUNFakeInstanceID.h; sourceTree = "<group>"; };
77-
7CF563081F1FE70600FEE1F4 /* FUNFakeApp.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FUNFakeApp.m; sourceTree = "<group>"; };
78-
7CF5630A1F1FE76700FEE1F4 /* FUNFakeApp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FUNFakeApp.h; sourceTree = "<group>"; };
7977
873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
78+
C8AEC40921B7EE440051C01E /* FIRAuthInteropFake.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FIRAuthInteropFake.h; path = ../../../Example/Shared/FIRAuthInteropFake.h; sourceTree = "<group>"; };
79+
C8AEC40A21B7EE440051C01E /* FIRAuthInteropFake.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FIRAuthInteropFake.m; path = ../../../Example/Shared/FIRAuthInteropFake.m; sourceTree = "<group>"; };
8080
E0A8D570636E99E7C3396DF8 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
8181
F1F2A7C03C10A3A03F9502B8 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
8282
/* End PBXFileReference section */
@@ -207,8 +207,8 @@
207207
7C70065B20572C1B007A5573 /* TestUtils */ = {
208208
isa = PBXGroup;
209209
children = (
210-
7CF5630A1F1FE76700FEE1F4 /* FUNFakeApp.h */,
211-
7CF563081F1FE70600FEE1F4 /* FUNFakeApp.m */,
210+
C8AEC40921B7EE440051C01E /* FIRAuthInteropFake.h */,
211+
C8AEC40A21B7EE440051C01E /* FIRAuthInteropFake.m */,
212212
7CF3BEC11F97EE2F00B16B6E /* FUNFakeInstanceID.h */,
213213
7CF3BEC01F97EE2F00B16B6E /* FUNFakeInstanceID.m */,
214214
);
@@ -349,7 +349,6 @@
349349
isa = PBXSourcesBuildPhase;
350350
buildActionMask = 2147483647;
351351
files = (
352-
7CF563091F1FE70600FEE1F4 /* FUNFakeApp.m in Sources */,
353352
6003F59E195388D20070C39A /* FIRAppDelegate.m in Sources */,
354353
6003F5A7195388D20070C39A /* FIRViewController.m in Sources */,
355354
7CF3BEC21F97EE2F00B16B6E /* FUNFakeInstanceID.m in Sources */,
@@ -370,6 +369,7 @@
370369
isa = PBXSourcesBuildPhase;
371370
buildActionMask = 2147483647;
372371
files = (
372+
C8AEC40B21B7EE440051C01E /* FIRAuthInteropFake.m in Sources */,
373373
7CBFAA82205702AB00A65866 /* FIRIntegrationTests.m in Sources */,
374374
);
375375
runOnlyForDeploymentPostprocessing = 0;
@@ -538,7 +538,11 @@
538538
"DEBUG=1",
539539
"$(inherited)",
540540
);
541-
HEADER_SEARCH_PATHS = "$(SRCROOT)/../FirebaseFunctions";
541+
HEADER_SEARCH_PATHS = (
542+
"$(inherited)",
543+
"$(SRCROOT)/../../Firebase/Core/Private",
544+
"$(SRCROOT)/../FirebaseFunctions",
545+
);
542546
INFOPLIST_FILE = "Tests/Tests-Info.plist";
543547
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
544548
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -557,7 +561,11 @@
557561
"$(DEVELOPER_FRAMEWORKS_DIR)",
558562
);
559563
GCC_PRECOMPILE_PREFIX_HEADER = NO;
560-
HEADER_SEARCH_PATHS = "$(SRCROOT)/../FirebaseFunctions";
564+
HEADER_SEARCH_PATHS = (
565+
"$(inherited)",
566+
"$(SRCROOT)/../../Firebase/Core/Private",
567+
"$(SRCROOT)/../FirebaseFunctions",
568+
);
561569
INFOPLIST_FILE = "Tests/Tests-Info.plist";
562570
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
563571
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -580,7 +588,11 @@
580588
"DEBUG=1",
581589
"$(inherited)",
582590
);
583-
HEADER_SEARCH_PATHS = "$(SRCROOT)/../FirebaseFunctions";
591+
HEADER_SEARCH_PATHS = (
592+
"$(inherited)",
593+
"$(SRCROOT)/../../Firebase/Core/Private",
594+
"$(SRCROOT)/../FirebaseFunctions",
595+
);
584596
INFOPLIST_FILE = "IntegrationTests/IntegrationTests-Info.plist";
585597
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
586598
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -599,7 +611,11 @@
599611
"$(DEVELOPER_FRAMEWORKS_DIR)",
600612
);
601613
GCC_PRECOMPILE_PREFIX_HEADER = NO;
602-
HEADER_SEARCH_PATHS = "$(SRCROOT)/../FirebaseFunctions";
614+
HEADER_SEARCH_PATHS = (
615+
"$(inherited)",
616+
"$(SRCROOT)/../../Firebase/Core/Private",
617+
"$(SRCROOT)/../FirebaseFunctions",
618+
);
603619
INFOPLIST_FILE = "IntegrationTests/IntegrationTests-Info.plist";
604620
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
605621
PRODUCT_NAME = "$(TARGET_NAME)";

Functions/Example/IntegrationTests/FIRIntegrationTests.m

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414

1515
#import <XCTest/XCTest.h>
1616

17+
#import "FIRAuthInteropFake.h"
1718
#import "FIRError.h"
1819
#import "FIRFunctions+Internal.h"
1920
#import "FIRFunctions.h"
2021
#import "FIRHTTPSCallable.h"
21-
#import "FUNFakeApp.h"
2222
#import "FUNFakeInstanceID.h"
2323

24+
// Project ID used by these tests.
25+
static NSString *const kProjectID = @"functions-integration-test";
26+
2427
@interface FIRIntegrationTests : XCTestCase {
2528
FIRFunctions *_functions;
2629
}
@@ -30,8 +33,10 @@ @implementation FIRIntegrationTests
3033

3134
- (void)setUp {
3235
[super setUp];
33-
id app = [[FUNFakeApp alloc] initWithProjectID:@"functions-integration-test"];
34-
_functions = [FIRFunctions functionsForApp:app];
36+
_functions = [[FIRFunctions alloc]
37+
initWithProjectID:kProjectID
38+
region:@"us-central1"
39+
auth:[[FIRAuthInteropFake alloc] initWithToken:nil userID:nil error:nil]];
3540
[_functions useLocalhost];
3641
}
3742

@@ -76,8 +81,10 @@ - (void)testScalar {
7681

7782
- (void)testToken {
7883
// Recreate _functions with a token.
79-
id app = [[FUNFakeApp alloc] initWithProjectID:@"functions-integration-test" token:@"token"];
80-
FIRFunctions *functions = [FIRFunctions functionsForApp:app];
84+
FIRFunctions *functions = [[FIRFunctions alloc]
85+
initWithProjectID:kProjectID
86+
region:@"us-central1"
87+
auth:[[FIRAuthInteropFake alloc] initWithToken:@"token" userID:nil error:nil]];
8188
[functions useLocalhost];
8289

8390
XCTestExpectation *expectation = [[XCTestExpectation alloc] init];
@@ -115,6 +122,7 @@ - (void)testNull {
115122
[self waitForExpectations:@[ expectation ] timeout:10];
116123

117124
// Test the version with no arguments.
125+
expectation = [[XCTestExpectation alloc] init];
118126
[function
119127
callWithCompletion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) {
120128
XCTAssertEqualObjects([NSNull null], result.data);

Functions/Example/Podfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ use_frameworks!
33
target 'FirebaseFunctions_Example' do
44
platform :ios, '8.0'
55

6+
pod 'FirebaseAuthInterop', :path => '../../'
67
pod 'FirebaseCore', :path => '../../'
7-
pod 'GoogleUtilities', :path => '../../'
88
pod 'FirebaseFunctions', :path => '../../'
9+
pod 'GoogleUtilities', :path => '../../'
910

1011
target 'FirebaseFunctions_Tests' do
1112
inherit! :search_paths

Functions/Example/TestUtils/FUNFakeApp.h

Lines changed: 0 additions & 39 deletions
This file was deleted.

Functions/Example/TestUtils/FUNFakeApp.m

Lines changed: 0 additions & 73 deletions
This file was deleted.

Functions/Example/Tests/FIRFunctionsTests.m

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#import "FIRFunctions+Internal.h"
1818
#import "FIRFunctions.h"
1919

20-
#import "FUNFakeApp.h"
21-
2220
@interface FIRFunctionsTests : XCTestCase
2321
@end
2422

@@ -33,14 +31,10 @@ - (void)tearDown {
3331
}
3432

3533
- (void)testURLWithName {
36-
id app = [[FUNFakeApp alloc] initWithProjectID:@"my-project"];
37-
FIRFunctions *functions = [FIRFunctions functionsForApp:app region:@"my-region"];
34+
FIRFunctions *functions =
35+
[[FIRFunctions alloc] initWithProjectID:@"my-project" region:@"my-region" auth:nil];
3836
NSString *url = [functions URLWithName:@"my-endpoint"];
3937
XCTAssertEqualObjects(@"https://my-region-my-project.cloudfunctions.net/my-endpoint", url);
40-
41-
functions = [FIRFunctions functionsForApp:app];
42-
url = [functions URLWithName:@"my-endpoint"];
43-
XCTAssertEqualObjects(@"https://us-central1-my-project.cloudfunctions.net/my-endpoint", url);
4438
}
4539

4640
@end

Functions/FirebaseFunctions/FIRFunctions+Internal.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#import "FIRFunctions.h"
1818

19+
@protocol FIRAuthInterop;
1920
@class FIRHTTPSCallableResult;
2021

2122
NS_ASSUME_NONNULL_BEGIN
@@ -45,6 +46,16 @@ NS_ASSUME_NONNULL_BEGIN
4546
*/
4647
- (void)useLocalhost;
4748

49+
/**
50+
* Internal initializer for the Cloud Functions client.
51+
* @param projectID The project ID for the Firebase project.
52+
* @param region The region for the http trigger, such as "us-central1".
53+
* @param auth The auth provider to use (optional).
54+
*/
55+
- (id)initWithProjectID:(NSString *)projectID
56+
region:(NSString *)region
57+
auth:(nullable id<FIRAuthInterop>)auth;
58+
4859
@end
4960

5061
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)