Skip to content

Commit

Permalink
fix(apple): fix build issues discovered by stricter build flags (#1178)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saadnajmi authored Feb 2, 2025
1 parent 92cf918 commit 5042047
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/modern-bugs-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@react-native-async-storage/async-storage": patch
---

Mark some methods as nonnull
5 changes: 5 additions & 0 deletions packages/default-storage/ios/RNCAsyncStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
*
* Keys and values must always be strings or an error is returned.
*/

NS_ASSUME_NONNULL_BEGIN

@interface RNCAsyncStorage : NSObject <
#ifdef RCT_NEW_ARCH_ENABLED
NativeAsyncStorageModuleSpec
Expand Down Expand Up @@ -60,3 +63,5 @@
- (void)getAllKeys:(RCTResponseSenderBlock)callback;

@end

NS_ASSUME_NONNULL_END
14 changes: 7 additions & 7 deletions packages/default-storage/ios/RNCAsyncStorage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ static void RCTStorageDirectoryMigrate(NSString *oldDirectoryPath,
// this folder and attempt folder copying again
if (error != nil && error.code == 4 &&
[newDirectoryPath isEqualToString:RCTGetStorageDirectory()]) {
NSError *error = nil;
error = nil;
_createStorageDirectory(RCTCreateStorageDirectoryPath(@""), &error);
if (error == nil) {
RCTStorageDirectoryMigrate(
Expand Down Expand Up @@ -559,7 +559,7 @@ - (NSDictionary *)_ensureSetup
return nil;
}

- (NSDictionary *)_writeManifest:(NSMutableArray<NSDictionary *> **)errors
- (NSDictionary *)_writeManifest:(NSMutableArray<NSDictionary *> *__autoreleasing *)errors
{
NSError *error;
NSString *serialized = RCTJSONStringify(_manifest, &error);
Expand Down Expand Up @@ -587,7 +587,7 @@ - (NSDictionary *)_appendItemForKey:(NSString *)key
return errorOut;
}

- (NSString *)_getValueForKey:(NSString *)key errorOut:(NSDictionary **)errorOut
- (NSString *)_getValueForKey:(NSString *)key errorOut:(NSDictionary *__autoreleasing *)errorOut
{
NSString *value =
_manifest[key]; // nil means missing, null means there may be a data file, else: NSString
Expand Down Expand Up @@ -699,14 +699,14 @@ - (BOOL)_passthroughDelegate
}
}

NSDictionary *errorOut = [self _ensureSetup];
if (errorOut) {
callback(@[@[errorOut], (id)kCFNull]);
NSDictionary *ensureSetupErrorOut = [self _ensureSetup];
if (ensureSetupErrorOut) {
callback(@[@[ensureSetupErrorOut], (id)kCFNull]);
return;
}
[self _multiGet:keys
callback:callback
getter:^(NSUInteger i, NSString *key, NSDictionary **errorOut) {
getter:^(__unused NSUInteger i, NSString *key, NSDictionary **errorOut) {
return [self _getValueForKey:key errorOut:errorOut];
}];
}
Expand Down

0 comments on commit 5042047

Please sign in to comment.