-
Notifications
You must be signed in to change notification settings - Fork 8
Some Generalizations #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
438fca5
c96b8b0
16cd512
626393f
b290c80
c995339
8f1a45d
97bebd7
6c65965
8c8eb8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| pkg | ||
| website/_site | ||
| *.gem | ||
| *.DS_Store | ||
| xcodebuilder.gemspec | ||
| *.DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| require 'rake/tasklib' | ||
| require 'ostruct' | ||
| require 'fileutils' | ||
| require 'open3' | ||
| require 'cfpropertylist' | ||
| require File.dirname(__FILE__) + '/xcode_builder/configuration' | ||
| require File.dirname(__FILE__) + '/xcode_builder/build_output_parser' | ||
|
|
@@ -12,7 +13,7 @@ class XcodeBuilder | |
| def initialize(namespace = :xcbuild, &block) | ||
| @configuration = Configuration.new( | ||
| :configuration => "Release", | ||
| :build_dir => "build", | ||
| :build_dir => nil, | ||
| :project_file_path => nil, | ||
| :workspace_file_path => nil, | ||
| :scheme => nil, | ||
|
|
@@ -23,6 +24,7 @@ def initialize(namespace = :xcbuild, &block) | |
| :verbose => false, | ||
| :info_plist => nil, | ||
| :scm => nil, | ||
| :sdk => "iphoneos", | ||
| :pod_repo => nil, | ||
| :podspec_file => nil, | ||
| :xcodebuild_extra_args => nil, | ||
|
|
@@ -37,26 +39,56 @@ def initialize(namespace = :xcbuild, &block) | |
| @configuration.info_plist = File.expand_path @configuration.info_plist unless @configuration.info_plist == nil | ||
| end | ||
|
|
||
| def xcodebuild(*args) | ||
| def xcodebuild(capture, *args) | ||
| # we're using tee as we still want to see our build output on screen | ||
| cmd = [] | ||
| cmd << "xcrun xcodebuild" | ||
| cmd.concat args | ||
| puts "Running: #{cmd.join(" ")}" if @configuration.verbose | ||
| cmd << "| xcpretty && exit ${PIPESTATUS[0]}" | ||
| cmd = cmd.join(" ") | ||
| system(cmd) | ||
|
|
||
| if capture | ||
| Open3.capture3(cmd) | ||
| else | ||
| cmd += "| xcpretty && exit ${PIPESTATUS[0]}" | ||
| system(cmd) | ||
| end | ||
| end | ||
|
|
||
| # desc "Clean the Build" | ||
| def clean | ||
| unless @configuration.skip_clean | ||
| print "Cleaning Project..." | ||
| xcodebuild @configuration.build_arguments, "clean" | ||
| xcodebuild(false, @configuration.build_arguments, "clean") | ||
| puts "Done" | ||
| end | ||
| end | ||
|
|
||
|
|
||
| # desc "Get xcode settings" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how is this meant to be used? For purely informative purposes?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More than that. By default xcode will create builds under ~/Library/Developer/Xcode/DerivedData/etc. This method allows calling code to figure out exactly where that is (its the TARGET_DIR key in the resulting hash table). This is an alternative to specifying build_dir. In our case, we prefer to stick with the xcode defaults thus this is needed. |
||
| def settings | ||
| print "Getting Build Settings..." << "\n" | ||
| stdout, stderr, status = xcodebuild(true, @configuration.build_arguments, "-showBuildSettings") | ||
|
|
||
| unless stderr.empty? | ||
| raise(stderr) | ||
| end | ||
|
|
||
| target = nil | ||
| stdout.split(/\n/).inject(Hash.new) do |hash, line| | ||
| match = line.match(/Build settings for action build and target \"?([^":]+)/) | ||
| if match | ||
| target = match[1] | ||
| hash[target] = Hash.new | ||
| elsif target | ||
| parts = line.split('=') | ||
| unless parts.empty? | ||
| hash[target][parts.first.strip!] = parts.last.strip! | ||
| end | ||
| end | ||
| hash | ||
| end | ||
| end | ||
|
|
||
| # desc "Build the beta release of the app" | ||
| def build | ||
| clean unless @configuration.skip_clean | ||
|
|
@@ -65,8 +97,9 @@ def build | |
| @configuration.timestamp_plist if @configuration.timestamp_build | ||
|
|
||
| print "Building Project..." | ||
| success = xcodebuild @configuration.build_arguments, "build" | ||
| raise "** BUILD FAILED **" unless success | ||
|
|
||
| success = xcodebuild(false, @configuration.build_arguments, "build") | ||
| raise "** BUILD FAILED **}" unless success | ||
| puts "Done" | ||
| end | ||
|
|
||
|
|
@@ -81,7 +114,6 @@ def package | |
| end | ||
|
|
||
| # trash and create the dist IPA path if needed | ||
| FileUtils.rm_rf @configuration.package_destination_path unless !File.exists? @configuration.package_destination_path | ||
| FileUtils.mkdir_p @configuration.package_destination_path | ||
|
|
||
| # Construct the IPA and Sign it | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # -*- encoding: utf-8 -*- | ||
| # stub: xcodebuilder 0.1.1 ruby lib | ||
|
|
||
| Gem::Specification.new do |s| | ||
| s.name = "xcodebuilder" | ||
| s.version = "0.1.1" | ||
|
|
||
| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= | ||
| s.require_paths = ["lib"] | ||
| s.authors = ["Olivier Larivain"] | ||
| s.date = "2014-10-30" | ||
| s.email = ["[email protected]"] | ||
| s.extra_rdoc_files = ["README.md", "LICENSE", "CHANGES.md"] | ||
| s.files = ["CHANGES.md", "LICENSE", "README.md", "lib/xcode_builder", "lib/xcode_builder.rb", "lib/xcode_builder/build_output_parser.rb", "lib/xcode_builder/configuration.rb", "lib/xcode_builder/deployment_strategies", "lib/xcode_builder/deployment_strategies.rb", "lib/xcode_builder/deployment_strategies/testflight.rb", "lib/xcode_builder/release_strategies", "lib/xcode_builder/release_strategies.rb", "lib/xcode_builder/release_strategies/git.rb", "lib/xcodebuilder.rb"] | ||
| s.homepage = "http://github.com/olarivain/xcodebuilder" | ||
| s.rdoc_options = ["--main", "README.md"] | ||
| s.rubygems_version = "2.4.2" | ||
| s.summary = "A set of Rake tasks and utilities for building and releasing xcode projects" | ||
|
|
||
| if s.respond_to? :specification_version then | ||
| s.specification_version = 4 | ||
|
|
||
| if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then | ||
| s.add_runtime_dependency(%q<CFPropertyList>, [">= 2.0.0"]) | ||
| s.add_runtime_dependency(%q<uuid>, ["~> 2.3.1"]) | ||
| s.add_runtime_dependency(%q<rest-client>, ["~> 1.6.1"]) | ||
| s.add_runtime_dependency(%q<json>, [">= 0"]) | ||
| s.add_runtime_dependency(%q<cocoapods>, [">= 0"]) | ||
| s.add_runtime_dependency(%q<xcpretty>, [">= 0"]) | ||
| else | ||
| s.add_dependency(%q<CFPropertyList>, [">= 2.0.0"]) | ||
| s.add_dependency(%q<uuid>, ["~> 2.3.1"]) | ||
| s.add_dependency(%q<rest-client>, ["~> 1.6.1"]) | ||
| s.add_dependency(%q<json>, [">= 0"]) | ||
| s.add_dependency(%q<cocoapods>, [">= 0"]) | ||
| s.add_dependency(%q<xcpretty>, [">= 0"]) | ||
| end | ||
| else | ||
| s.add_dependency(%q<CFPropertyList>, [">= 2.0.0"]) | ||
| s.add_dependency(%q<uuid>, ["~> 2.3.1"]) | ||
| s.add_dependency(%q<rest-client>, ["~> 1.6.1"]) | ||
| s.add_dependency(%q<json>, [">= 0"]) | ||
| s.add_dependency(%q<cocoapods>, [">= 0"]) | ||
| s.add_dependency(%q<xcpretty>, [">= 0"]) | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does capture give you here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its to support getting xcode settings, the results are provided on STDOUT.