diff --git a/Libraries/Settings/RCTSettingsManager.m b/Libraries/Settings/RCTSettingsManager.mm similarity index 72% rename from Libraries/Settings/RCTSettingsManager.m rename to Libraries/Settings/RCTSettingsManager.mm index 5e3757d30cd..d55adcfaed3 100644 --- a/Libraries/Settings/RCTSettingsManager.m +++ b/Libraries/Settings/RCTSettingsManager.mm @@ -7,11 +7,17 @@ #import +#import #import #import #import #import +#import "RCTSettingsPlugins.h" + +@interface RCTSettingsManager() +@end + @implementation RCTSettingsManager { BOOL _ignoringUpdates; @@ -51,14 +57,16 @@ RCT_EXPORT_MODULE() [[NSNotificationCenter defaultCenter] removeObserver:self]; } -- (NSDictionary *)constantsToExport +- (facebook::react::ModuleConstants)constantsToExport { - return [self getConstants]; + return (facebook::react::ModuleConstants)[self getConstants]; } -- (NSDictionary *)getConstants +- (facebook::react::ModuleConstants)getConstants { - return @{@"settings": RCTJSONClean([_defaults dictionaryRepresentation])}; + return facebook::react::typedConstants({ + .settings = RCTJSONClean([_defaults dictionaryRepresentation]) + }); } - (void)userDefaultsDidChange:(NSNotification *)note @@ -109,4 +117,15 @@ RCT_EXPORT_METHOD(deleteValues:(NSArray *)keys) _ignoringUpdates = NO; } +- (std::shared_ptr)getTurboModuleWithJsInvoker: + (std::shared_ptr)jsInvoker +{ + return std::make_shared(self, jsInvoker); +} + @end + +Class RCTSettingsManagerCls(void) +{ + return RCTSettingsManager.class; +} diff --git a/Libraries/Settings/RCTSettingsPlugins.h b/Libraries/Settings/RCTSettingsPlugins.h new file mode 100644 index 00000000000..0967c097d21 --- /dev/null +++ b/Libraries/Settings/RCTSettingsPlugins.h @@ -0,0 +1,40 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @generated by an internal plugin build system + */ + +#ifdef RN_DISABLE_OSS_PLUGIN_HEADER + +// FB Internal: Plugins.h is autogenerated by the build system. +#import "Plugins.h" + +#else + +// OSS-compatibility layer + +#import + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wreturn-type-c-linkage" + +#ifdef __cplusplus +extern "C" { +#endif + +// RCTTurboModuleManagerDelegate should call this to resolve module classes. +Class RCTSettingsClassProvider(const char *name); + +// Lookup functions +Class RCTSettingsManagerCls(void); + +#ifdef __cplusplus +} +#endif + +#pragma GCC diagnostic pop + +#endif // RN_DISABLE_OSS_PLUGIN_HEADER diff --git a/Libraries/Settings/RCTSettingsPlugins.mm b/Libraries/Settings/RCTSettingsPlugins.mm new file mode 100644 index 00000000000..09438ed1fc3 --- /dev/null +++ b/Libraries/Settings/RCTSettingsPlugins.mm @@ -0,0 +1,32 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @generated by an internal plugin build system + */ + +#ifndef RN_DISABLE_OSS_PLUGIN_HEADER + +// OSS-compatibility layer + +#import "RCTSettingsPlugins.h" + +#import +#import + +Class RCTSettingsClassProvider(const char *name) { + static std::unordered_map sCoreModuleClassMap = { + {"SettingsManager", RCTSettingsManagerCls}, + }; + + auto p = sCoreModuleClassMap.find(name); + if (p != sCoreModuleClassMap.end()) { + auto classFunc = p->second; + return classFunc(); + } + return nil; +} + +#endif // RN_DISABLE_OSS_PLUGIN_HEADER diff --git a/Libraries/Settings/React-RCTSettings.podspec b/Libraries/Settings/React-RCTSettings.podspec index fe3ae075b13..e7f06c859c6 100644 --- a/Libraries/Settings/React-RCTSettings.podspec +++ b/Libraries/Settings/React-RCTSettings.podspec @@ -17,19 +17,30 @@ else source[:tag] = "v#{version}" end +folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' +folly_version = '2018.10.22.00' + Pod::Spec.new do |s| s.name = "React-RCTSettings" s.version = version - s.summary = "A wrapper for NSUserDefaults, a persistent key-value store available only on iOS." + s.summary = "A wrapper for NSUserDefaults, a persistent key-value store available only on iOS." s.homepage = "http://facebook.github.io/react-native/" s.documentation_url = "https://facebook.github.io/react-native/docs/settings" s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" s.platforms = { :ios => "9.0", :tvos => "9.2" } + s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness' s.source = source - s.source_files = "*.{m}" + s.source_files = "*.{m,mm}" s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs" s.header_dir = "RCTSettings" + s.pod_target_xcconfig = { + "USE_HEADERMAP" => "YES", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", + "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Folly\"" + } + s.dependency "Folly", folly_version + s.dependency "FBReactNativeSpec", version s.dependency "React-Core/RCTSettingsHeaders", version end diff --git a/RNTester/Podfile.lock b/RNTester/Podfile.lock index ffbdd2c9df3..67d299bede1 100644 --- a/RNTester/Podfile.lock +++ b/RNTester/Podfile.lock @@ -219,6 +219,8 @@ PODS: - React-RCTPushNotification (1000.0.0): - React-Core/RCTPushNotificationHeaders (= 1000.0.0) - React-RCTSettings (1000.0.0): + - FBReactNativeSpec (= 1000.0.0) + - Folly (= 2018.10.22.00) - React-Core/RCTSettingsHeaders (= 1000.0.0) - React-RCTTest (1000.0.0): - React-Core (= 1000.0.0) @@ -372,7 +374,7 @@ SPEC CHECKSUMS: React-RCTLinking: d7d7f792e63a8d57380cecbb9b7a3b31f92d1bb6 React-RCTNetwork: c8f9d40297f35ea3792ea81866f33e8b45c25935 React-RCTPushNotification: acffa8af6a20e6d41b041a8c4cb4bea0de9df0dd - React-RCTSettings: dd4009546ce88c3647c32f0b5922459ab313fdca + React-RCTSettings: 86311240a0ebe1da843564c2c22498f7cb366181 React-RCTTest: 73df09ec226fcad6e7e058a313e5dd16cccf86a8 React-RCTText: 9078167d3bc011162326f2d8ef4dd580ec1eca17 React-RCTVibration: bf05159719598f876ba763e5a58ccbad21e2e82f