From 38b87f914db74e035230f09d95d7b09e7c4cf71d Mon Sep 17 00:00:00 2001 From: Taylor Johnson Date: Fri, 24 Jul 2020 19:06:18 -0700 Subject: [PATCH] Add subspec for iOS extensions without React (#471) * Add subspec for iOS extensions without React * hard code script_phase to Extension subspec --- .gitignore | 1 + README.md | 3 +++ package.json | 2 +- react-native-config.podspec | 24 ++++++++++++++++++++++-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 46fc795..75726df 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules xcuserdata xcshareddata +/.idea/ diff --git a/README.md b/README.md index 3f1334b..0ee3dba 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,9 @@ target 'ShareExtension' do platform :ios, '9.0' pod 'react-native-config', :path => '../node_modules/react-native-config' + + # For extensions without React dependencies + pod 'react-native-config/Extension', :path => '../node_modules/react-native-config' end ``` diff --git a/package.json b/package.json index a0df57c..d686a68 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-config", - "version": "1.3.1", + "version": "1.3.2", "description": "Expose config variables to React Native apps", "keywords": [ "env", diff --git a/react-native-config.podspec b/react-native-config.podspec index aacf1bb..2864c53 100644 --- a/react-native-config.podspec +++ b/react-native-config.podspec @@ -28,8 +28,28 @@ HOST_PATH="$SRCROOT/../.." input_files: ['$PODS_TARGET_SRCROOT/ios/ReactNativeConfig/BuildDotenvConfig.rb'] } - s.source_files = 'ios/**/*.{h,m}' s.requires_arc = true + s.default_subspec = 'App' + + s.subspec 'App' do |app| + app.source_files = 'ios/**/*.{h,m}' + app.dependency 'React' + end + + # Use this subspec for iOS extensions that cannot use React dependency + s.subspec 'Extension' do |ext| + # Had to duplicate the script_phase since it wasn't being passed down. Not sure why + ext.script_phase = { + name: 'Config codegen', + script: %( + set -ex + HOST_PATH="$SRCROOT/../.." + "${PODS_TARGET_SRCROOT}/ios/ReactNativeConfig/BuildDotenvConfig.rb" "$HOST_PATH" "${PODS_TARGET_SRCROOT}/ios/ReactNativeConfig" + ), + execution_position: :before_compile, + input_files: ['$PODS_TARGET_SRCROOT/ios/ReactNativeConfig/BuildDotenvConfig.rb'] + } + ext.source_files = ['ios/**/ReactNativeConfig.{h,m}', 'ios/**/GeneratedDotEnv.m'] + end - s.dependency 'React' end