From 6d88898404bb4a8e823fe34232f817152928c6a4 Mon Sep 17 00:00:00 2001 From: Alex Kotliarskyi Date: Fri, 20 Mar 2015 14:02:42 -0700 Subject: [PATCH] [ReactNative] Init script that bootstraps new Xcode project --- .../xcshareddata/xcschemes/SampleApp.xcscheme | 88 +++++++++++++++++++ packager/init.sh | 44 ++++++++++ 2 files changed, 132 insertions(+) create mode 100644 Examples/SampleApp/SampleApp.xcodeproj/xcshareddata/xcschemes/SampleApp.xcscheme create mode 100755 packager/init.sh diff --git a/Examples/SampleApp/SampleApp.xcodeproj/xcshareddata/xcschemes/SampleApp.xcscheme b/Examples/SampleApp/SampleApp.xcodeproj/xcshareddata/xcschemes/SampleApp.xcscheme new file mode 100644 index 000000000..a3375a020 --- /dev/null +++ b/Examples/SampleApp/SampleApp.xcodeproj/xcshareddata/xcschemes/SampleApp.xcscheme @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packager/init.sh b/packager/init.sh new file mode 100755 index 000000000..6a42b9aeb --- /dev/null +++ b/packager/init.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env ruby + +def cp(src, dest, app_name) + if File.directory?(src) + Dir.mkdir(dest) unless Dir.exists?(dest) + else + content = File.read(src) + .gsub("SampleApp", app_name) + .gsub("Examples/#{app_name}/", "") + .gsub("../../Libraries/", "node_modules/react-native/Libraries/") + .gsub("../../ReactKit/", "node_modules/react-native/ReactKit/") + File.write(dest, content) + end +end + +def main(dest, app_name) + source = File.expand_path("../../Examples/SampleApp", __FILE__) + files = Dir.chdir(source) { Dir["**/*"] } + .reject { |file| file["project.xcworkspace"] || file["xcuserdata"] } + .each { |file| + new_file = file.gsub("SampleApp", app_name) + cp File.join(source, file), File.join(dest, new_file), app_name + } +end + +if ARGV.count == 0 + puts "Usage: #{__FILE__} " + puts "" + puts "This script will bootstrap new React Native app in current folder" +else + app_name = ARGV.first + dest = Dir.pwd + puts "Setting up new React Native app in #{dest}" + puts "" + + main(dest, app_name) + + puts "Next steps:" + puts "" + puts " Open #{app_name}.xcproject in Xcode" + puts " Hit Run button" + puts "" +end +