Skip to content

Commit 547445c

Browse files
author
Krzysztof Borowy
authored
fix: same directory name for storage on ios
- Example was unlinked, so linked it back - Uses same directory name as internal Async Storage, so transition is smooth - Removed reference to RN's internal Async Storage - this sometimes thrown error `.multiMerge` error - Throws error when not linked
1 parent 7a78492 commit 547445c

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

example/ios/AsyncStorageExample.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
2222
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
2323
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
24+
3D82E3B72248BD39001F5D1A /* libRNCAsyncStorage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DC5398C220F2C940035D3A3 /* libRNCAsyncStorage.a */; };
2425
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
2526
ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */; };
2627
ED297163215061F000B7C4FE /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED297162215061F000B7C4FE /* JavaScriptCore.framework */; };
@@ -327,6 +328,7 @@
327328
isa = PBXFrameworksBuildPhase;
328329
buildActionMask = 2147483647;
329330
files = (
331+
3D82E3B72248BD39001F5D1A /* libRNCAsyncStorage.a in Frameworks */,
330332
ED297163215061F000B7C4FE /* JavaScriptCore.framework in Frameworks */,
331333
ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */,
332334
11D1A2F320CAFA9E000508D9 /* libRCTAnimation.a in Frameworks */,

ios/RNCAsyncStorage.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#import <React/RCTLog.h>
1717
#import <React/RCTUtils.h>
1818

19-
static NSString *const RCTStorageDirectory = @"RNCAsyncLocalStorage_V1";
19+
static NSString *const RCTStorageDirectory = @"RCTAsyncLocalStorage_V1";
2020
static NSString *const RCTManifestFileName = @"manifest.json";
2121
static const NSUInteger RCTInlineValueThreshold = 1024;
2222

lib/AsyncStorage.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,21 @@
1313

1414
const {NativeModules} = require('react-native');
1515

16-
// Use RocksDB if available, then SQLite, then file storage.
17-
// Changed Name of SQLite DB, to not conflict with AsyncStorage from RN repo
1816
const RCTAsyncStorage =
19-
NativeModules.AsyncRocksDBStorage ||
20-
NativeModules.RNC_AsyncSQLiteDBStorage ||
21-
NativeModules.RNCAsyncStorage ||
22-
NativeModules.AsyncLocalStorage;
17+
NativeModules.RNC_AsyncSQLiteDBStorage || NativeModules.RNCAsyncStorage;
18+
19+
if (!RCTAsyncStorage) {
20+
throw new Error(`@RNCommunity/AsyncStorage: NativeModule.RCTAsyncStorage is null.
21+
22+
To fix this issue try these steps:
23+
• Run \`react-native link @react-native-community/async-storage\` in the project root.
24+
• Rebuild and re-run the app.
25+
• Restart the packager with \`--clearCache\` flag.
26+
• If you are using CocoaPods on iOS, run \`pod install\` in the \`ios\` directory and then rebuild and re-run the app.
27+
28+
If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-community/react-native-async-storage/issues
29+
`);
30+
}
2331

2432
type ReadOnlyArrayString = $ReadOnlyArray<string>;
2533

0 commit comments

Comments
 (0)