From 712679ff892a386f1ad678ed519bb390539304a7 Mon Sep 17 00:00:00 2001 From: Julien K Date: Thu, 24 Aug 2017 23:21:36 +0200 Subject: [PATCH] Add react-native-keychain on tvOS (#78) * [tvOS] Update podspec * [tvOS] Add target * [SecRequestSharedWebCredential] is only available on iOS and not tvOS * [Security] Move into the same folder Framework * [RNKeychainManager.m] Change indentation --- RNKeychain.podspec | 3 +- RNKeychain.xcodeproj/project.pbxproj | 106 +++++++++++++++++++++++++- RNKeychainManager/RNKeychainManager.m | 2 + 3 files changed, 109 insertions(+), 2 deletions(-) diff --git a/RNKeychain.podspec b/RNKeychain.podspec index 1f67790..c046c4a 100644 --- a/RNKeychain.podspec +++ b/RNKeychain.podspec @@ -9,7 +9,8 @@ Pod::Spec.new do |s| s.homepage = "https://github.com/oblador/react-native-keychain" s.license = "MIT" s.author = { "Joel Arvidsson" => "joel@oblador.se" } - s.platform = :ios, "7.0" + s.ios.deployment_target = '7.0' + s.tvos.deployment_target = '9.0' s.source = { :git => "https://github.com/oblador/react-native-keychain.git", :tag => "v#{s.version}" } s.source_files = 'RNKeychainManager/**/*.{h,m}' s.preserve_paths = "**/*.js" diff --git a/RNKeychain.xcodeproj/project.pbxproj b/RNKeychain.xcodeproj/project.pbxproj index 6ed08fa..e074281 100644 --- a/RNKeychain.xcodeproj/project.pbxproj +++ b/RNKeychain.xcodeproj/project.pbxproj @@ -9,6 +9,8 @@ /* Begin PBXBuildFile section */ 5D82368F1B0CE3CB005A9EF3 /* RNKeychainManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D82368C1B0CE2A6005A9EF3 /* RNKeychainManager.m */; }; 5D8236911B0CE3D6005A9EF3 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D8236901B0CE3D6005A9EF3 /* Security.framework */; }; + 6478986A1F38BF9D00DA1C12 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 647898691F38BF9D00DA1C12 /* Security.framework */; }; + 6478986B1F38BFA100DA1C12 /* RNKeychainManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D82368C1B0CE2A6005A9EF3 /* RNKeychainManager.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -22,6 +24,15 @@ name = "Copy Files"; runOnlyForDeploymentPostprocessing = 0; }; + 6478985D1F38BF9100DA1C12 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -29,6 +40,8 @@ 5D82368B1B0CE2A6005A9EF3 /* RNKeychainManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNKeychainManager.h; sourceTree = ""; }; 5D82368C1B0CE2A6005A9EF3 /* RNKeychainManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNKeychainManager.m; sourceTree = ""; }; 5D8236901B0CE3D6005A9EF3 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; + 6478985F1F38BF9100DA1C12 /* libRNKeychain.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNKeychain.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 647898691F38BF9D00DA1C12 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS10.2.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -40,15 +53,23 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6478985C1F38BF9100DA1C12 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6478986A1F38BF9D00DA1C12 /* Security.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 5D8236661B0CE05B005A9EF3 = { isa = PBXGroup; children = ( - 5D8236901B0CE3D6005A9EF3 /* Security.framework */, 5D82368A1B0CE2A6005A9EF3 /* RNKeychainManager */, 5D8236701B0CE05B005A9EF3 /* Products */, + 647898681F38BF9C00DA1C12 /* Frameworks */, ); sourceTree = ""; wrapsLines = 0; @@ -57,6 +78,7 @@ isa = PBXGroup; children = ( 5D82366F1B0CE05B005A9EF3 /* libRNKeychain.a */, + 6478985F1F38BF9100DA1C12 /* libRNKeychain.a */, ); name = Products; sourceTree = ""; @@ -70,6 +92,15 @@ path = RNKeychainManager; sourceTree = ""; }; + 647898681F38BF9C00DA1C12 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 5D8236901B0CE3D6005A9EF3 /* Security.framework */, + 647898691F38BF9D00DA1C12 /* Security.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -90,6 +121,23 @@ productReference = 5D82366F1B0CE05B005A9EF3 /* libRNKeychain.a */; productType = "com.apple.product-type.library.static"; }; + 6478985E1F38BF9100DA1C12 /* RNKeychain-tvOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 647898671F38BF9100DA1C12 /* Build configuration list for PBXNativeTarget "RNKeychain-tvOS" */; + buildPhases = ( + 6478985B1F38BF9100DA1C12 /* Sources */, + 6478985C1F38BF9100DA1C12 /* Frameworks */, + 6478985D1F38BF9100DA1C12 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "RNKeychain-tvOS"; + productName = "RNKeychain-tvOS"; + productReference = 6478985F1F38BF9100DA1C12 /* libRNKeychain.a */; + productType = "com.apple.product-type.library.static"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -102,6 +150,10 @@ 5D82366E1B0CE05B005A9EF3 = { CreatedOnToolsVersion = 6.3.1; }; + 6478985E1F38BF9100DA1C12 = { + CreatedOnToolsVersion = 8.3.3; + ProvisioningStyle = Automatic; + }; }; }; buildConfigurationList = 5D82366A1B0CE05B005A9EF3 /* Build configuration list for PBXProject "RNKeychain" */; @@ -117,6 +169,7 @@ projectRoot = ""; targets = ( 5D82366E1B0CE05B005A9EF3 /* RNKeychain */, + 6478985E1F38BF9100DA1C12 /* RNKeychain-tvOS */, ); }; /* End PBXProject section */ @@ -130,6 +183,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6478985B1F38BF9100DA1C12 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6478986B1F38BFA100DA1C12 /* RNKeychainManager.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ @@ -243,6 +304,40 @@ }; name = Release; }; + 647898651F38BF9100DA1C12 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_TESTABILITY = YES; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = RNKeychain; + SDKROOT = appletvos; + SKIP_INSTALL = YES; + TVOS_DEPLOYMENT_TARGET = 10.2; + }; + name = Debug; + }; + 647898661F38BF9100DA1C12 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = RNKeychain; + SDKROOT = appletvos; + SKIP_INSTALL = YES; + TVOS_DEPLOYMENT_TARGET = 10.2; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -264,6 +359,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 647898671F38BF9100DA1C12 /* Build configuration list for PBXNativeTarget "RNKeychain-tvOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 647898651F38BF9100DA1C12 /* Debug */, + 647898661F38BF9100DA1C12 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 5D8236671B0CE05B005A9EF3 /* Project object */; diff --git a/RNKeychainManager/RNKeychainManager.m b/RNKeychainManager/RNKeychainManager.m index c0a9df1..bf4962f 100644 --- a/RNKeychainManager/RNKeychainManager.m +++ b/RNKeychainManager/RNKeychainManager.m @@ -285,6 +285,7 @@ RCT_EXPORT_METHOD(resetInternetCredentialsForServer:(NSString *)server withOptio } +#if TARGET_OS_IOS RCT_EXPORT_METHOD(requestSharedWebCredentials:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { SecRequestSharedWebCredential(NULL, NULL, ^(CFArrayRef credentials, CFErrorRef error) { @@ -328,5 +329,6 @@ RCT_EXPORT_METHOD(setSharedWebCredentialsForServer:(NSString *)server withUserna resolve(@(YES)); }); } +#endif @end