mirror of
https://github.com/status-im/react-native-config.git
synced 2025-02-28 15:00:45 +00:00
[ios] App extensions support (#456)
* Add support of ios app extension * Update documentation
This commit is contained in:
parent
bc3ca9d261
commit
7b188c16e7
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.DS_Store
|
||||
|
||||
node_modules
|
||||
xcuserdata
|
||||
|
12
README.md
12
README.md
@ -187,6 +187,18 @@ ios/tmp.xcconfig
|
||||
"${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildXCConfig.rb" "${SRCROOT}/.." "${SRCROOT}/tmp.xcconfig"
|
||||
```
|
||||
|
||||
#### App Extensions
|
||||
|
||||
Add dependency to `react-native-config`.
|
||||
|
||||
```
|
||||
target 'ShareExtension' do
|
||||
platform :ios, '9.0'
|
||||
|
||||
pod 'react-native-config', :path => '../node_modules/react-native-config'
|
||||
end
|
||||
```
|
||||
|
||||
### Different environments
|
||||
|
||||
Save config for different environments in different files: `.env.staging`, `.env.production`, etc.
|
||||
|
@ -20,7 +20,7 @@ public class ReactNativeConfigModule extends ReactContextBaseJavaModule {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ReactNativeConfig";
|
||||
return "ReactNativeConfigModule";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
2
index.js
2
index.js
@ -5,4 +5,4 @@
|
||||
// iOS: config vars set in xcconfig and exposed via ReactNativeConfig.m
|
||||
import { NativeModules } from 'react-native';
|
||||
|
||||
export default NativeModules.ReactNativeConfig || {};
|
||||
export default NativeModules.ReactNativeConfigModule || {};
|
||||
|
@ -7,6 +7,7 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
07BF4DBD2476FBED00E59829 /* ReactNativeConfigModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 07BF4DBC2476FBED00E59829 /* ReactNativeConfigModule.m */; };
|
||||
3DF7F6B6203AA0C200D0EAB7 /* ReactNativeConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = EBE4E8461C7D2456000F8875 /* ReactNativeConfig.m */; };
|
||||
3DF7F6B7203AA0D600D0EAB7 /* ReactNativeConfig.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = EB2648E21C7BE17A00B8F155 /* ReactNativeConfig.h */; };
|
||||
EB2648E31C7BE17A00B8F155 /* ReactNativeConfig.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = EB2648E21C7BE17A00B8F155 /* ReactNativeConfig.h */; };
|
||||
@ -56,6 +57,8 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
07BF4DBB2476FBED00E59829 /* ReactNativeConfigModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReactNativeConfigModule.h; sourceTree = "<group>"; };
|
||||
07BF4DBC2476FBED00E59829 /* ReactNativeConfigModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReactNativeConfigModule.m; sourceTree = "<group>"; };
|
||||
3DF7F6AC203AA09B00D0EAB7 /* libReactNativeConfig-tvOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libReactNativeConfig-tvOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
50406729228CAD5A00E0438A /* ReadDotEnv.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = ReadDotEnv.rb; sourceTree = "<group>"; };
|
||||
50830C45228DD3D000CEA8FC /* BuildXCConfig.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = BuildXCConfig.rb; sourceTree = "<group>"; };
|
||||
@ -106,6 +109,8 @@
|
||||
50830C45228DD3D000CEA8FC /* BuildXCConfig.rb */,
|
||||
EB2648E21C7BE17A00B8F155 /* ReactNativeConfig.h */,
|
||||
EBE4E8461C7D2456000F8875 /* ReactNativeConfig.m */,
|
||||
07BF4DBB2476FBED00E59829 /* ReactNativeConfigModule.h */,
|
||||
07BF4DBC2476FBED00E59829 /* ReactNativeConfigModule.m */,
|
||||
EBE4E8291C7BF6DD000F8875 /* BuildDotenvConfig.rb */,
|
||||
50406729228CAD5A00E0438A /* ReadDotEnv.rb */,
|
||||
);
|
||||
@ -234,6 +239,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
07BF4DBD2476FBED00E59829 /* ReactNativeConfigModule.m in Sources */,
|
||||
EBE4E8471C7D2456000F8875 /* ReactNativeConfig.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -1,11 +1,6 @@
|
||||
#if __has_include(<React/RCTBridgeModule.h>)
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#elif __has_include("React/RCTBridgeModule.h")
|
||||
#import "React/RCTBridgeModule.h"
|
||||
#else
|
||||
#import "RCTBridgeModule.h"
|
||||
#endif
|
||||
@interface ReactNativeConfig : NSObject <RCTBridgeModule>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface ReactNativeConfig : NSObject
|
||||
|
||||
+ (NSDictionary *)env;
|
||||
+ (NSString *)envFor: (NSString *)key;
|
||||
|
@ -3,13 +3,6 @@
|
||||
|
||||
@implementation ReactNativeConfig
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (NSDictionary *)env {
|
||||
return (NSDictionary *)DOT_ENV;
|
||||
}
|
||||
@ -19,8 +12,4 @@ RCT_EXPORT_MODULE()
|
||||
return value;
|
||||
}
|
||||
|
||||
- (NSDictionary *)constantsToExport {
|
||||
return DOT_ENV
|
||||
}
|
||||
|
||||
@end
|
||||
|
14
ios/ReactNativeConfig/ReactNativeConfigModule.h
Normal file
14
ios/ReactNativeConfig/ReactNativeConfigModule.h
Normal file
@ -0,0 +1,14 @@
|
||||
#if __has_include(<React/RCTBridgeModule.h>)
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#elif __has_include("React/RCTBridgeModule.h")
|
||||
#import "React/RCTBridgeModule.h"
|
||||
#else
|
||||
#import "RCTBridgeModule.h"
|
||||
#endif
|
||||
|
||||
@interface ReactNativeConfigModule : NSObject <RCTBridgeModule>
|
||||
|
||||
+ (NSDictionary *)env;
|
||||
+ (NSString *)envFor: (NSString *)key;
|
||||
|
||||
@end
|
25
ios/ReactNativeConfig/ReactNativeConfigModule.m
Normal file
25
ios/ReactNativeConfig/ReactNativeConfigModule.m
Normal file
@ -0,0 +1,25 @@
|
||||
#import "ReactNativeConfig.h"
|
||||
#import "ReactNativeConfigModule.h"
|
||||
|
||||
@implementation ReactNativeConfigModule
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (NSDictionary *)env {
|
||||
return ReactNativeConfig.env;
|
||||
}
|
||||
|
||||
+ (NSString *)envFor: (NSString *)key {
|
||||
return [ReactNativeConfig envFor:key];
|
||||
}
|
||||
|
||||
- (NSDictionary *)constantsToExport {
|
||||
return ReactNativeConfig.env;
|
||||
}
|
||||
|
||||
@end
|
Loading…
x
Reference in New Issue
Block a user