ammarahm-ed / react-native-mmkv-storage

An ultra fast (0.0002s read/write), small & encrypted mobile key-value storage framework for React Native written in C++ using JSI
https://rnmmkv.now.sh
MIT License
1.58k stars 109 forks source link

[Bug] iOS build breaks when using Expo SDK 45+ #258

Closed amrfarid140 closed 2 years ago

amrfarid140 commented 2 years ago

Describe the bug iOS build breaks if the project is using Expo SDK 45+. This is because react-native-mmkv-storage is using conditional imports which doesn't play well with Expo autolinking.

See this PR for more details.

To Reproduce Steps to reproduce the behavior:

  1. Create a new project with Expo 45 and react-native-mmkv-storage
  2. Try to Generate a release build for iOS

Expected behavior Build succeeds

Platform Information:

Additional context

ammarahm-ed commented 2 years ago

@amrfarid140 Have you tried to patch it and see if build succeeds on iOS after patching?

amrfarid140 commented 2 years ago

I did, here are the changes that got me a successful build. Happy to make a PR with them if they look alright to you.

diff --git a/node_modules/react-native-mmkv-storage/ios/MMKVNative.h b/node_modules/react-native-mmkv-storage/ios/MMKVNative.h
index 60a2a03..ce0934c 100644
--- a/node_modules/react-native-mmkv-storage/ios/MMKVNative.h
+++ b/node_modules/react-native-mmkv-storage/ios/MMKVNative.h
@@ -1,11 +1,5 @@
-
-#if __has_include("RCTBridgeModule.h")
-#import "RCTBridgeModule.h"
-#else
 #import <React/RCTBridgeModule.h>
 #import <React/RCTEventEmitter.h>
-#endif
-
 @interface MMKVNative : NSObject <RCTBridgeModule>

 @property (nonatomic, assign) BOOL setBridgeOnMainQueue;
diff --git a/node_modules/react-native-mmkv-storage/ios/MMKVStorage.h b/node_modules/react-native-mmkv-storage/ios/MMKVStorage.h
index b5f5823..7847f5e 100644
--- a/node_modules/react-native-mmkv-storage/ios/MMKVStorage.h
+++ b/node_modules/react-native-mmkv-storage/ios/MMKVStorage.h
@@ -1,10 +1,5 @@
-
-#if __has_include("RCTBridgeModule.h")
-#import "RCTBridgeModule.h"
-#else
 #import <React/RCTBridgeModule.h>
 #import <React/RCTEventEmitter.h>
-#endif

 @interface MMKVStorage : NSObject <RCTBridgeModule>

diff --git a/node_modules/react-native-mmkv-storage/ios/SecureStorage.h b/node_modules/react-native-mmkv-storage/ios/SecureStorage.h
index b804a64..53d6cd2 100644
--- a/node_modules/react-native-mmkv-storage/ios/SecureStorage.h
+++ b/node_modules/react-native-mmkv-storage/ios/SecureStorage.h
@@ -1,10 +1,4 @@
-
-#if __has_include("RCTBridgeModule.h")
-#import "RCTBridgeModule.h"
-#else
 #import <React/RCTBridgeModule.h>
-#endif
-
 #import <Foundation/Foundation.h>

 @interface SecureStorage: NSObject
diff --git a/node_modules/react-native-mmkv-storage/ios/SecureStorage.m b/node_modules/react-native-mmkv-storage/ios/SecureStorage.m
index 1c4e1c2..dbea26b 100644
--- a/node_modules/react-native-mmkv-storage/ios/SecureStorage.m
+++ b/node_modules/react-native-mmkv-storage/ios/SecureStorage.m
@@ -1,9 +1,4 @@
-#if __has_include("RCTBridgeModule.h")
-#import "RCTBridgeModule.h"
-#else
 #import <React/RCTBridgeModule.h>
-#endif
-
 #import "SecureStorage.h"
 #import <UIKit/UIKit.h>
ammarahm-ed commented 2 years ago

@amrfarid140 A PR would be awesome.