Skip to content

Commit 4f5b8a3

Browse files
committed
Fixed dynamic loading for on-device builds
1 parent d1dce21 commit 4f5b8a3

File tree

51 files changed

+638
-414
lines changed

Some content is hidden

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

51 files changed

+638
-414
lines changed

ios/Firestack.xcodeproj/project.pbxproj

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
A4830B59CA0CDCC7AC616D7C /* Pods_Firestack.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F73732AB87B93D6C70882AD0 /* Pods_Firestack.framework */; };
1110
D950369E1D19C77400F7094D /* Firestack.m in Sources */ = {isa = PBXBuildFile; fileRef = D950369D1D19C77400F7094D /* Firestack.m */; };
12-
D9FF4BF31D19F5FF00238046 /* Pods_Firestack.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D95036B81D19C90300F7094D /* Pods_Firestack.framework */; };
11+
D9FF4BF31D19F5FF00238046 /* Pods_Firestack.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D95036B81D19C90300F7094D /* Pods_Firestack.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
1312
/* End PBXBuildFile section */
1413

1514
/* Begin PBXContainerItemProxy section */
@@ -20,6 +19,13 @@
2019
remoteGlobalIDString = 6A0E8DDC7C16F5507F1B7E4EF54F4E39;
2120
remoteInfo = "Pods-Firestack";
2221
};
22+
D9841C431D4A7E8C00C9BEA8 /* PBXContainerItemProxy */ = {
23+
isa = PBXContainerItemProxy;
24+
containerPortal = D95036B31D19C90300F7094D /* Pods.xcodeproj */;
25+
proxyType = 1;
26+
remoteGlobalIDString = 7EC314ECB2B8568E8C3AAE095E7F7E98;
27+
remoteInfo = "Pods-Firestack";
28+
};
2329
/* End PBXContainerItemProxy section */
2430

2531
/* Begin PBXCopyFilesBuildPhase section */
@@ -41,7 +47,6 @@
4147
D950369C1D19C77400F7094D /* Firestack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Firestack.h; path = Firestack/Firestack.h; sourceTree = "<group>"; };
4248
D950369D1D19C77400F7094D /* Firestack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Firestack.m; path = Firestack/Firestack.m; sourceTree = "<group>"; };
4349
D95036B31D19C90300F7094D /* Pods.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Pods.xcodeproj; path = Pods/Pods.xcodeproj; sourceTree = "<group>"; };
44-
D9FF4C201D19F96C00238046 /* libReact.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libReact.a; path = "../../../React/build/Debug-iphoneos/libReact.a"; sourceTree = "<group>"; };
4550
F73732AB87B93D6C70882AD0 /* Pods_Firestack.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Firestack.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4651
/* End PBXFileReference section */
4752

@@ -51,7 +56,6 @@
5156
buildActionMask = 2147483647;
5257
files = (
5358
D9FF4BF31D19F5FF00238046 /* Pods_Firestack.framework in Frameworks */,
54-
A4830B59CA0CDCC7AC616D7C /* Pods_Firestack.framework in Frameworks */,
5559
);
5660
runOnlyForDeploymentPostprocessing = 0;
5761
};
@@ -69,7 +73,6 @@
6973
4C361DE13748C14BF1F87624 /* Frameworks */ = {
7074
isa = PBXGroup;
7175
children = (
72-
D9FF4C201D19F96C00238046 /* libReact.a */,
7376
D95036B31D19C90300F7094D /* Pods.xcodeproj */,
7477
F73732AB87B93D6C70882AD0 /* Pods_Firestack.framework */,
7578
);
@@ -120,6 +123,7 @@
120123
buildRules = (
121124
);
122125
dependencies = (
126+
D9841C441D4A7E8C00C9BEA8 /* PBXTargetDependency */,
123127
);
124128
name = Firestack;
125129
productName = RCTDataManager;
@@ -217,6 +221,14 @@
217221
};
218222
/* End PBXSourcesBuildPhase section */
219223

224+
/* Begin PBXTargetDependency section */
225+
D9841C441D4A7E8C00C9BEA8 /* PBXTargetDependency */ = {
226+
isa = PBXTargetDependency;
227+
name = "Pods-Firestack";
228+
targetProxy = D9841C431D4A7E8C00C9BEA8 /* PBXContainerItemProxy */;
229+
};
230+
/* End PBXTargetDependency section */
231+
220232
/* Begin XCBuildConfiguration section */
221233
58B511ED1A9E6C8500147676 /* Debug */ = {
222234
isa = XCBuildConfiguration;
@@ -298,6 +310,8 @@
298310
isa = XCBuildConfiguration;
299311
baseConfigurationReference = CEE8E427185097CF7EF3A3EB /* Pods-Firestack.debug.xcconfig */;
300312
buildSettings = {
313+
DYLIB_INSTALL_NAME_BASE = "@rpath";
314+
ENABLE_BITCODE = NO;
301315
FRAMEWORK_SEARCH_PATHS = (
302316
"$(inherited)",
303317
"$(PROJECT_DIR)/Pods/FirebaseAnalytics/Frameworks",
@@ -312,6 +326,7 @@
312326
"$(SRCROOT)/../../node_modules/react-native/React/**",
313327
"$(SRCROOT)/../../react-native/React/**",
314328
);
329+
LD_DYLIB_INSTALL_NAME = "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)";
315330
LIBRARY_SEARCH_PATHS = "$(inherited)";
316331
MACH_O_TYPE = mh_dylib;
317332
ONLY_ACTIVE_ARCH = YES;
@@ -329,6 +344,8 @@
329344
isa = XCBuildConfiguration;
330345
baseConfigurationReference = 612D3268D15D0E9231997758 /* Pods-Firestack.release.xcconfig */;
331346
buildSettings = {
347+
DYLIB_INSTALL_NAME_BASE = "@rpath";
348+
ENABLE_BITCODE = NO;
332349
FRAMEWORK_SEARCH_PATHS = (
333350
"$(inherited)",
334351
"$(PROJECT_DIR)/Pods/FirebaseAnalytics/Frameworks",
@@ -343,6 +360,7 @@
343360
"$(SRCROOT)/../../node_modules/react-native/React/**",
344361
"$(SRCROOT)/../../react-native/React/**",
345362
);
363+
LD_DYLIB_INSTALL_NAME = "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)";
346364
LIBRARY_SEARCH_PATHS = "$(inherited)";
347365
MACH_O_TYPE = mh_dylib;
348366
OTHER_LDFLAGS = (

ios/Firestack/Firestack.m

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ @implementation Firestack
1717
{
1818
// Are we debugging, yo?
1919
self.debug = [opts valueForKey:@"debug"] != nil ? YES : NO;
20-
20+
2121
FIROptions *firestackOptions = [FIROptions defaultOptions];
2222
// Bundle ID either from options OR from the main bundle
2323
NSString *bundleID;
@@ -31,7 +31,7 @@ @implementation Firestack
3131
@"GCMSenderID", @"androidClientID",
3232
@"googleAppID", @"databaseURL",
3333
@"deepLinkURLScheme", @"storageBucket"];
34-
34+
3535
NSMutableDictionary *props = [[NSMutableDictionary alloc] initWithCapacity:[keyOptions count]];
3636
for (int i=0; i < [keyOptions count]; i++) {
3737
// Traditional for loop here
@@ -49,7 +49,7 @@ @implementation Firestack
4949
NSLog(@"An error occurred: %@", err);
5050
}
5151
}
52-
52+
5353
@try {
5454
FIROptions *finalOptions = [[FIROptions alloc] initWithGoogleAppID:[props valueForKey:@"googleAppID"]
5555
bundleID:bundleID
@@ -61,16 +61,16 @@ @implementation Firestack
6161
databaseURL:[props valueForKey:@"databaseURL"]
6262
storageBucket:[props valueForKey:@"storageBucket"]
6363
deepLinkURLScheme:[props valueForKey:@"deepLinkURLScheme"]];
64-
64+
6565
for (NSString *key in props) {
6666
[self debugLog:key msg:[finalOptions valueForKey:key]];
6767
}
6868
[self debugLog:@"bundleID" msg:bundleID];
69-
69+
7070
// Save configuration option
7171
NSDictionary *cfg = [self getConfig];
7272
[cfg setValuesForKeysWithDictionary:props];
73-
73+
7474
if (!self.configured) {
7575
[FIRApp configureWithOptions:finalOptions];
7676
self->_configured = YES;
@@ -111,9 +111,9 @@ @implementation Firestack
111111
};
112112
return callback(@[err]);
113113
}
114-
114+
115115
NSLog(@"signinWithCredential: %@", credential);
116-
116+
117117
@try {
118118
[[FIRAuth auth] signInWithCredential:credential
119119
completion:^(FIRUser *user, NSError *error) {
@@ -159,7 +159,7 @@ @implementation Firestack
159159
{
160160
self->authListenerHandle = [[FIRAuth auth] addAuthStateDidChangeListener:^(FIRAuth *_Nonnull auth,
161161
FIRUser *_Nullable user) {
162-
162+
163163
if (user != nil) {
164164
// User is signed in.
165165
NSDictionary *userProps = [self userPropsFromFIRUser:user];
@@ -195,7 +195,7 @@ @implementation Firestack
195195
RCT_EXPORT_METHOD(getCurrentUser:(RCTResponseSenderBlock)callback)
196196
{
197197
FIRUser *user = [FIRAuth auth].currentUser;
198-
198+
199199
if (user != nil) {
200200
NSDictionary *userProps = [self userPropsFromFIRUser:user];
201201
callback(@[[NSNull null], userProps]);
@@ -255,7 +255,7 @@ @implementation Firestack
255255
callback:(RCTResponseSenderBlock) callback)
256256
{
257257
FIRUser *user = [FIRAuth auth].currentUser;
258-
258+
259259
[user updateEmail:email completion:^(NSError *_Nullable error) {
260260
if (error) {
261261
// An error happened.
@@ -275,9 +275,9 @@ @implementation Firestack
275275
RCT_EXPORT_METHOD(updateUserPassword:(NSString *)newPassword
276276
callback:(RCTResponseSenderBlock) callback)
277277
{
278-
278+
279279
FIRUser *user = [FIRAuth auth].currentUser;
280-
280+
281281
[user updatePassword:newPassword completion:^(NSError *_Nullable error) {
282282
if (error) {
283283
// An error happened.
@@ -297,7 +297,7 @@ @implementation Firestack
297297
RCT_EXPORT_METHOD(sendPasswordResetWithEmail:(NSString *)email
298298
callback:(RCTResponseSenderBlock) callback)
299299
{
300-
300+
301301
[[FIRAuth auth] sendPasswordResetWithEmail:email
302302
completion:^(NSError *_Nullable error) {
303303
if (error) {
@@ -319,7 +319,7 @@ @implementation Firestack
319319
RCT_EXPORT_METHOD(deleteUser:(RCTResponseSenderBlock) callback)
320320
{
321321
FIRUser *user = [FIRAuth auth].currentUser;
322-
322+
323323
[user deleteWithCompletion:^(NSError *_Nullable error) {
324324
if (error) {
325325
NSDictionary *err =
@@ -348,9 +348,9 @@ @implementation Firestack
348348
};
349349
return callback(@[err]);
350350
}
351-
351+
352352
FIRUser *user = [FIRAuth auth].currentUser;
353-
353+
354354
[user reauthenticateWithCredential:credential completion:^(NSError *_Nullable error) {
355355
if (error) {
356356
NSDictionary *err =
@@ -370,7 +370,7 @@ @implementation Firestack
370370
{
371371
FIRUser *user = [FIRAuth auth].currentUser;
372372
FIRUserProfileChangeRequest *changeRequest = [user profileChangeRequest];
373-
373+
374374
NSMutableArray *allKeys = [[userProps allKeys] mutableCopy];
375375
for (NSString *key in allKeys) {
376376
// i.e. changeRequest.displayName = userProps[displayName];
@@ -429,23 +429,23 @@ - (NSString *) getStorageUrl
429429
callback:(RCTResponseSenderBlock) callback)
430430
{
431431
NSDictionary *cfg = [self getConfig];
432-
432+
433433
NSString *urlStr = [self getStorageUrl];
434-
434+
435435
if (urlStr == nil) {
436436
NSError *err = [[NSError alloc] init];
437437
[err setValue:@"Storage configuration error" forKey:@"name"];
438438
[err setValue:@"Call setStorageUrl() first" forKey:@"description"];
439439
return callback(@[err]);
440440
}
441-
441+
442442
FIRStorageReference *storageRef = [[FIRStorage storage] referenceForURL:urlStr];
443443
FIRStorageReference *uploadRef = [storageRef child:name];
444-
444+
445445
NSURL *localFile = [NSURL fileURLWithPath:path];
446-
446+
447447
FIRStorageMetadata *firmetadata = [[FIRStorageMetadata alloc] initWithDictionary:metadata];
448-
448+
449449
FIRStorageUploadTask *uploadTask = [uploadRef putFile:localFile
450450
metadata:firmetadata];
451451
// Listen for state changes, errors, and completion of the upload.
@@ -455,7 +455,7 @@ - (NSString *) getStorageUrl
455455
@"ref": snapshot.reference.bucket
456456
}];
457457
}];
458-
458+
459459
[uploadTask observeStatus:FIRStorageTaskStatusPause handler:^(FIRStorageTaskSnapshot *snapshot) {
460460
// Upload paused
461461
[self sendJSEvent:@"uploadPaused" props:@{
@@ -465,13 +465,13 @@ - (NSString *) getStorageUrl
465465
[uploadTask observeStatus:FIRStorageTaskStatusProgress handler:^(FIRStorageTaskSnapshot *snapshot) {
466466
// Upload reported progress
467467
double percentComplete = 100.0 * (snapshot.progress.completedUnitCount) / (snapshot.progress.totalUnitCount);
468-
468+
469469
[self sendJSEvent:@"uploadProgress" props:@{
470470
@"progress": @(percentComplete || 0.0)
471471
}];
472-
472+
473473
}];
474-
474+
475475
[uploadTask observeStatus:FIRStorageTaskStatusSuccess handler:^(FIRStorageTaskSnapshot *snapshot) {
476476
// Upload completed successfully
477477
FIRStorageReference *ref = snapshot.reference;
@@ -481,10 +481,10 @@ - (NSString *) getStorageUrl
481481
@"name": ref.name,
482482
@"metadata": [snapshot.metadata dictionaryRepresentation]
483483
};
484-
484+
485485
callback(@[[NSNull null], props]);
486486
}];
487-
487+
488488
[uploadTask observeStatus:FIRStorageTaskStatusFailure handler:^(FIRStorageTaskSnapshot *snapshot) {
489489
if (snapshot.error != nil) {
490490
NSError *err = [[NSError alloc] init];
@@ -506,7 +506,7 @@ - (NSString *) getStorageUrl
506506
[err setValue:@"Unknown error" forKey:@"description"];
507507
break;
508508
}
509-
509+
510510
callback(@[err]);
511511
}}];
512512
}
@@ -520,7 +520,7 @@ - (NSString *) getStorageUrl
520520
// Create remote Config instance
521521
self.remoteConfigInstance = [FIRRemoteConfig remoteConfig];
522522
}
523-
523+
524524
[self.remoteConfigInstance setDefaults:props];
525525
callback(@[[NSNull null], props]);
526526
}
@@ -542,10 +542,15 @@ - (NSString *) getStorageUrl
542542
};
543543
callback(@[err]);
544544
}
545-
546-
545+
546+
547547
FIRRemoteConfigValue *value = [self.remoteConfigInstance configValueForKey:name];
548-
callback(@[[NSNull null], value.stringValue]);
548+
NSString *valueStr = value.stringValue;
549+
550+
if (valueStr == nil) {
551+
valueStr = @"";
552+
}
553+
callback(@[[NSNull null], valueStr]);
549554
}
550555

551556
RCT_EXPORT_METHOD(fetchWithExpiration:(NSNumber*)expirationSeconds
@@ -558,22 +563,22 @@ - (NSString *) getStorageUrl
558563
};
559564
callback(@[err]);
560565
}
561-
566+
562567
NSTimeInterval expirationDuration = [expirationSeconds doubleValue];
563-
568+
564569
[self.remoteConfigInstance fetchWithExpirationDuration:expirationDuration completionHandler:^(FIRRemoteConfigFetchStatus status, NSError *error) {
565570
if (status == FIRRemoteConfigFetchStatusSuccess) {
566571
NSLog(@"Config fetched!");
567572
[self.remoteConfigInstance activateFetched];
568573
callback(@[[NSNull null], @(YES)]);
569574
} else {
570575
NSLog(@"Error %@", error.localizedDescription);
571-
576+
572577
NSDictionary *err = @{
573578
@"error": @"No configuration instance",
574579
@"msg": [error localizedDescription]
575580
};
576-
581+
577582
callback(@[err]);
578583
}
579584
}];
@@ -599,7 +604,7 @@ - (NSDictionary *) handleFirebaseError:(NSString *) name
599604
[error localizedDescription], @"rawDescription",
600605
[[error userInfo] description], @"userInfo",
601606
nil];
602-
607+
603608
NSString *description = @"Unknown error";
604609
switch (error.code) {
605610
case FIRAuthErrorCodeInvalidEmail:
@@ -630,12 +635,12 @@ - (NSDictionary *) userPropsFromFIRUser:(FIRUser *) user
630635
@"anonymous": @(user.anonymous),
631636
@"displayName": user.displayName ? user.displayName : @""
632637
} mutableCopy];
633-
638+
634639
if ([user valueForKey:@"photoURL"] != nil) {
635640
[userProps setValue: [NSString stringWithFormat:@"%@", user.photoURL]
636641
forKey:@"photoURL"];
637642
}
638-
643+
639644
return userProps;
640645
}
641646

0 commit comments

Comments
 (0)