Skip to content

Commit 79c3cf2

Browse files
committed
Make all Storage APIs available via Swift
1 parent 15b0286 commit 79c3cf2

File tree

85 files changed

+2621
-1177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+2621
-1177
lines changed

CocoapodsIntegrationTest/TestEnvironments/Cocoapods_multiprojects_frameworks/Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ target 'CocoapodsIntegrationTest' do
2727
pod 'FirebaseMessagingInterop', :path => '../'
2828
pod 'FirebasePerformance', :path => '../'
2929
pod 'FirebaseStorage', :path => '../'
30+
pod 'FirebaseStorageObjC', :path => '../'
3031
end
3132

3233
# Using the new speed-enhancing features available with CocoaPods 1.7+

FirebaseAppCheckInterop.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FirebaseAppCheckInterop'
3-
s.version = '8.12.0'
3+
s.version = '8.13.0'
44
s.summary = 'Interfaces that allow other Firebase SDKs to use AppCheck functionality.'
55

66
s.description = <<-DESC

FirebaseAuthInterop.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FirebaseAuthInterop'
3-
s.version = '8.12.0'
3+
s.version = '8.13.0'
44
s.summary = 'Interfaces that allow other Firebase SDKs to use Auth functionality.'
55

66
s.description = <<-DESC

FirebaseCore/Sources/FIRApp.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,10 @@ + (void)registerSwiftComponents {
836836
SEL componentsToRegisterSEL = @selector(componentsToRegister);
837837
// Dictionary of class names that conform to `FIRLibrary` and their user agents. These should only
838838
// be SDKs that are written in Swift but still visible to ObjC.
839-
NSDictionary<NSString *, NSString *> *swiftLibs = @{@"FIRFunctionsComponent" : @"fire-fun"};
839+
NSDictionary<NSString *, NSString *> *swiftLibs = @{
840+
@"FIRFunctionsComponent" : @"fire-fun",
841+
@"FIRStorageComponent" : @"fire-str",
842+
};
840843
for (NSString *className in swiftLibs.allKeys) {
841844
Class klass = NSClassFromString(className);
842845
if (klass && [klass respondsToSelector:componentsToRegisterSEL]) {

FirebaseCoreInternal.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FirebaseCoreInternal'
3-
s.version = '8.12.0'
3+
s.version = '8.13.0'
44
s.summary = 'APIs only for Firebase internal usage'
55

66
s.description = <<-DESC

FirebaseMessagingInterop.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FirebaseMessagingInterop'
3-
s.version = '8.12.0'
3+
s.version = '8.13.0'
44
s.summary = 'Interfaces that allow other Firebase SDKs to use Messaging functionality.'
55

66
s.description = <<-DESC

FirebaseStorage.podspec

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,30 @@ Firebase Storage provides robust, secure file uploads and downloads from Firebas
3636
'FirebaseStorageSwift/Sources/*.swift',
3737
]
3838

39-
s.dependency 'FirebaseStorageObjC', '~> 8.10'
39+
s.dependency 'FirebaseStorageObjC', '~> 8.13'
40+
s.dependency 'FirebaseAppCheckInterop', '~> 8.13'
41+
s.dependency 'FirebaseAuthInterop', '~> 8.13'
42+
s.dependency 'FirebaseCoreInternal', '~> 8.13'
43+
44+
s.test_spec 'objcIntegration' do |objc_tests|
45+
objc_tests.scheme = { :code_coverage => true }
46+
objc_tests.platforms = {
47+
:ios => ios_deployment_target,
48+
:osx => osx_deployment_target,
49+
:tvos => tvos_deployment_target
50+
}
51+
objc_tests.source_files = [
52+
'FirebaseStorage/Tests/Integration/*.[mh]',
53+
'FirebaseStorageSwift/Tests/ObjCIntegration/*.m',
54+
]
55+
objc_tests.requires_app_host = true
56+
objc_tests.resources = 'FirebaseStorage/Tests/Integration/Resources/1mb.dat',
57+
'FirebaseStorage/Tests/Integration/Resources/GoogleService-Info.plist'
58+
objc_tests.dependency 'FirebaseAuth', '~> 8.0'
59+
objc_tests.pod_target_xcconfig = {
60+
'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"'
61+
}
62+
end
4063

4164
s.test_spec 'integration' do |int_tests|
4265
int_tests.scheme = { :code_coverage => true }
@@ -50,6 +73,6 @@ Firebase Storage provides robust, secure file uploads and downloads from Firebas
5073
int_tests.resources = 'FirebaseStorage/Tests/Integration/Resources/1mb.dat',
5174
'FirebaseStorage/Tests/Integration/Resources/GoogleService-Info.plist',
5275
'FirebaseStorage/Tests/Integration/Resources/HomeImprovement.numbers'
53-
int_tests.dependency 'FirebaseAuth', '~> 8.0'
76+
int_tests.dependency 'FirebaseAuth', '~> 8.13'
5477
end
5578
end

FirebaseStorage/Sources/FIRStorage.m

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#import "FirebaseStorage/Sources/Public/FirebaseStorage/FIRStorage.h"
1616
#import "FirebaseStorage/Sources/Public/FirebaseStorage/FIRStorageReference.h"
1717

18-
#import "FirebaseStorage/Sources/FIRStorageComponent.h"
1918
#import "FirebaseStorage/Sources/FIRStorageConstants_Private.h"
2019
#import "FirebaseStorage/Sources/FIRStoragePath.h"
2120
#import "FirebaseStorage/Sources/FIRStorageReference_Private.h"
@@ -39,7 +38,7 @@
3938
NSMutableDictionary<NSString * /* bucket */, GTMSessionFetcherService *> *> *_fetcherServiceMap;
4039
static GTMSessionFetcherRetryBlock _retryWhenOffline;
4140

42-
@interface FIRStorage () {
41+
@interface FIRIMPLStorage () {
4342
/// Stored Auth reference, if it exists. This needs to be stored for `copyWithZone:`.
4443
id<FIRAuthInterop> _Nullable _auth;
4544
id<FIRAppCheckInterop> _Nullable _appCheck;
@@ -50,7 +49,7 @@ @interface FIRStorage () {
5049
}
5150
@end
5251

53-
@implementation FIRStorage
52+
@implementation FIRIMPLStorage
5453

5554
+ (void)initialize {
5655
static dispatch_once_t onceToken;
@@ -102,16 +101,12 @@ + (void)setGTMSessionFetcherLoggingEnabled:(BOOL)isLoggingEnabled {
102101
[GTMSessionFetcher setLoggingEnabled:isLoggingEnabled];
103102
}
104103

105-
+ (instancetype)storage {
106-
return [self storageForApp:[FIRApp defaultApp]];
107-
}
108-
109-
+ (instancetype)storageForApp:(FIRApp *)app {
104+
+ (NSString *)bucketForApp:(FIRApp *)app {
110105
if (app.options.storageBucket) {
111106
NSString *url = [app.options.storageBucket isEqualToString:@""]
112107
? @""
113108
: [@"gs://" stringByAppendingString:app.options.storageBucket];
114-
return [self storageForApp:app URL:url];
109+
return [self bucketForApp:app URL:url];
115110
} else {
116111
NSString *const kAppNotConfiguredMessage =
117112
@"No default Storage bucket found. Did you configure Firebase Storage properly?";
@@ -120,11 +115,7 @@ + (instancetype)storageForApp:(FIRApp *)app {
120115
}
121116
}
122117

123-
+ (instancetype)storageWithURL:(NSString *)url {
124-
return [self storageForApp:[FIRApp defaultApp] URL:url];
125-
}
126-
127-
+ (instancetype)storageForApp:(FIRApp *)app URL:(NSString *)url {
118+
+ (NSString *)bucketForApp:(FIRApp *)app URL:(NSString *)url {
128119
NSString *bucket;
129120
if ([url isEqualToString:@""]) {
130121
bucket = @"";
@@ -145,11 +136,7 @@ + (instancetype)storageForApp:(FIRApp *)app URL:(NSString *)url {
145136

146137
bucket = path.bucket;
147138
}
148-
149-
// Retrieve the instance provider from the app's container to inject dependencies as needed.
150-
id<FIRStorageMultiBucketProvider> provider =
151-
FIR_COMPONENT(FIRStorageMultiBucketProvider, app.container);
152-
return [provider storageForBucket:bucket];
139+
return bucket;
153140
}
154141

155142
- (instancetype)initWithApp:(FIRApp *)app
@@ -190,10 +177,10 @@ - (instancetype)init {
190177
#pragma mark - NSObject overrides
191178

192179
- (instancetype)copyWithZone:(NSZone *)zone {
193-
FIRStorage *storage = [[[self class] allocWithZone:zone] initWithApp:_app
194-
bucket:_storageBucket
195-
auth:_auth
196-
appCheck:_appCheck];
180+
FIRIMPLStorage *storage = [[[self class] allocWithZone:zone] initWithApp:_app
181+
bucket:_storageBucket
182+
auth:_auth
183+
appCheck:_appCheck];
197184
storage.callbackQueue = self.callbackQueue;
198185
return storage;
199186
}
@@ -204,15 +191,15 @@ - (BOOL)isEqual:(id)object {
204191
return YES;
205192
}
206193

207-
if (![object isKindOfClass:[FIRStorage class]]) {
194+
if (![object isKindOfClass:[FIRIMPLStorage class]]) {
208195
return NO;
209196
}
210197

211-
BOOL isEqualObject = [self isEqualToFIRStorage:(FIRStorage *)object];
198+
BOOL isEqualObject = [self isEqualToFIRStorage:(FIRIMPLStorage *)object];
212199
return isEqualObject;
213200
}
214201

215-
- (BOOL)isEqualToFIRStorage:(FIRStorage *)storage {
202+
- (BOOL)isEqualToFIRStorage:(FIRIMPLStorage *)storage {
216203
BOOL isEqual =
217204
[_app isEqual:storage.app] && [_storageBucket isEqualToString:storage.storageBucket];
218205
return isEqual;
@@ -273,21 +260,22 @@ - (NSTimeInterval)maxOperationRetryTime {
273260

274261
#pragma mark - Public methods
275262

276-
- (FIRStorageReference *)reference {
263+
- (FIRIMPLStorageReference *)reference {
277264
[self ensureConfigured];
278265

279266
FIRStoragePath *path = [[FIRStoragePath alloc] initWithBucket:_storageBucket object:nil];
280-
return [[FIRStorageReference alloc] initWithStorage:self path:path];
267+
return [[FIRIMPLStorageReference alloc] initWithStorage:self path:path];
281268
}
282269

283-
- (FIRStorageReference *)referenceForURL:(NSString *)string {
270+
- (FIRIMPLStorageReference *)referenceForURL:(NSString *)string {
284271
[self ensureConfigured];
285272

286273
FIRStoragePath *path = [FIRStoragePath pathFromString:string];
287274

288275
// If no default bucket exists (empty string), accept anything.
289276
if ([_storageBucket isEqual:@""]) {
290-
FIRStorageReference *reference = [[FIRStorageReference alloc] initWithStorage:self path:path];
277+
FIRIMPLStorageReference *reference = [[FIRIMPLStorageReference alloc] initWithStorage:self
278+
path:path];
291279
return reference;
292280
}
293281

@@ -299,12 +287,13 @@ - (FIRStorageReference *)referenceForURL:(NSString *)string {
299287
format:kInvalidBucketFormat, path.bucket, _storageBucket];
300288
}
301289

302-
FIRStorageReference *reference = [[FIRStorageReference alloc] initWithStorage:self path:path];
290+
FIRIMPLStorageReference *reference = [[FIRIMPLStorageReference alloc] initWithStorage:self
291+
path:path];
303292
return reference;
304293
}
305294

306-
- (FIRStorageReference *)referenceWithPath:(NSString *)string {
307-
FIRStorageReference *reference = [[self reference] child:string];
295+
- (FIRIMPLStorageReference *)referenceWithPath:(NSString *)string {
296+
FIRIMPLStorageReference *reference = [[self reference] child:string];
308297
return reference;
309298
}
310299

@@ -347,22 +336,22 @@ + (void)enableBackgroundTasks:(BOOL)isEnabled {
347336
[NSException raise:NSGenericException format:@"enableBackgroundTasks not implemented"];
348337
}
349338

350-
- (NSArray<FIRStorageUploadTask *> *)uploadTasks {
339+
- (NSArray<FIRIMPLStorageUploadTask *> *)uploadTasks {
351340
[NSException raise:NSGenericException format:@"getUploadTasks not implemented"];
352341
return nil;
353342
}
354343

355-
- (NSArray<FIRStorageDownloadTask *> *)downloadTasks {
344+
- (NSArray<FIRIMPLStorageDownloadTask *> *)downloadTasks {
356345
[NSException raise:NSGenericException format:@"getDownloadTasks not implemented"];
357346
return nil;
358347
}
359348

360349
- (void)ensureConfigured {
361350
if (!_fetcherServiceForApp) {
362-
_fetcherServiceForApp = [FIRStorage fetcherServiceForApp:_app
363-
bucket:_storageBucket
364-
auth:_auth
365-
appCheck:_appCheck];
351+
_fetcherServiceForApp = [FIRIMPLStorage fetcherServiceForApp:_app
352+
bucket:_storageBucket
353+
auth:_auth
354+
appCheck:_appCheck];
366355
if (_usesEmulator) {
367356
_fetcherServiceForApp.allowLocalhostRequest = YES;
368357
_fetcherServiceForApp.allowedInsecureSchemes = @[ @"http" ];

FirebaseStorage/Sources/FIRStorageComponent.h

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

0 commit comments

Comments
 (0)