Created
November 25, 2018 16:17
-
-
Save zhangtaii/775ebfdf1d8973f5f9500814e212c0d2 to your computer and use it in GitHub Desktop.
Add launchPackager shell script to React Native with CocoaPods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The target name is most likely the name of your project. | |
target 'NumberTileGame' do | |
# Your 'node_modules' directory is probably in the root of your project, | |
# but if not, adjust the `:path` accordingly | |
pod 'React', :path => '../node_modules/react-native', :subspecs => [ | |
'Core', | |
'CxxBridge', # Include this for RN >= 0.47 | |
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43 | |
'RCTText', | |
'RCTNetwork', | |
'RCTWebSocket', # Needed for debugging | |
'RCTAnimation', # Needed for FlatList and animations running on native UI thread | |
# Add any other subspecs you want to use in your project | |
] | |
# Explicitly include Yoga if you are using RN >= 0.42.0 | |
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga' | |
# Third party deps podspec link | |
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' | |
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' | |
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec' | |
# add launchPackager shell script to 'React' target | |
post_install do |installer| | |
target = installer.pods_project.targets.select{|t| 'React' == t.name}.first | |
phase = target.new_shell_script_build_phase('Run Script') | |
phase.shell_script = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment