Skip to content

Commit

Permalink
Add subspec for iOS extensions without React (#471)
Browse files Browse the repository at this point in the history
* Add subspec for iOS extensions without React

* hard code script_phase to Extension subspec
  • Loading branch information
Taylor123 authored Jul 25, 2020
1 parent 07cabdc commit 38b87f9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
node_modules
xcuserdata
xcshareddata
/.idea/
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
24 changes: 22 additions & 2 deletions react-native-config.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 38b87f9

Please sign in to comment.