Last active
August 29, 2015 14:16
-
-
Save inquisitiveSoft/20e71bb3dc768480ab8f to your computer and use it in GitHub Desktop.
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
#!/usr/bin/ruby | |
# MIT License: http://www.opensource.org/licenses/MIT | |
require 'pathname' | |
require 'open3' | |
# read arguments | |
shouldBuild = FALSE | |
initialDirectory = Pathname.getwd | |
# Using a path to differentiate between multiple versions of Xcode | |
pathToXcodeApp = "/Applications/Xcode.app" | |
for argument in ARGV | |
if argument.match(/-b/i) || argument.match(/--build/i) | |
shouldBuild = TRUE | |
# elsif argument.match(/-6/i) | |
# pathToXcodeApp = "/Applications/Xcode.app" | |
elsif argument.length | |
initialDirectory += argument | |
end | |
end | |
success = FALSE | |
initialDirectory.ascend do | directory | | |
directory.each_entry do | path | | |
if path.basename.fnmatch("*.xcworkspace") | |
system "open '#{directory + path}' -a '#{pathToXcodeApp}'" | |
success = TRUE; | |
end | |
end | |
if !success | |
directory.each_entry do | path | | |
if path.basename.fnmatch("*.xcodeproj") | |
if shouldBuild | |
stdin, stdout, stderr = Open3.popen3("xcodebuild -project '#{directory + path}' -scheme Debug") | |
log = stdout.read | |
if $?.exitstatus == 0 | |
puts '** BUILD SUCCEDED **' | |
else | |
puts '** BUILD FAILED **' | |
puts log | |
end | |
else | |
system "open '#{directory + path}' -a '#{pathToXcodeApp}'" | |
end | |
success = TRUE; | |
end | |
end | |
end | |
end | |
if !success | |
print " Couldn't find an Xcode project or workspace for the '#{Pathname.getwd}' directory\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment