Class: XcodeBuilder::XcodeBuilder
- Inherits:
-
Object
- Object
- XcodeBuilder::XcodeBuilder
- Defined in:
- lib/xcode_builder.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
-
#build ⇒ Object
desc “Build the beta release of the app”.
-
#clean ⇒ Object
desc “Clean the Build”.
- #deploy ⇒ Object
-
#initialize(namespace = :xcbuild) {|@configuration| ... } ⇒ XcodeBuilder
constructor
A new instance of XcodeBuilder.
-
#package ⇒ Object
desc “Package the release as a distributable archive”.
-
#pod_dry_run ⇒ Object
runs a pod dry run before tagging.
-
#pod_release ⇒ Object
desc “For CocoaPod libraries: dry run, tags SCM, pushes to cocoapod and increments build number”.
- #push_pod ⇒ Object
- #release ⇒ Object
- #xcodebuild(*args) ⇒ Object
Constructor Details
#initialize(namespace = :xcbuild) {|@configuration| ... } ⇒ XcodeBuilder
Returns a new instance of XcodeBuilder.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/xcode_builder.rb', line 12 def initialize(namespace = :xcbuild, &block) @configuration = Configuration.new( :configuration => "Release", :build_dir => "build", :project_file_path => nil, :workspace_file_path => nil, :scheme => nil, :app_name => nil, :signing_identity => nil, :package_destination_path => "./pkg", :skip_clean => false, :verbose => false, :info_plist => nil, :scm => nil, :pod_repo => nil, :podspec_file => nil, :xcodebuild_extra_args => nil, :xcrun_extra_args => nil, :timestamp_build => nil, ) @namespace = namespace yield @configuration if block_given? # expand the info plist path, as it's likely to be relative and we'll be fucking # around with the cwd later on. @configuration.info_plist = File. @configuration.info_plist unless @configuration.info_plist == nil end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
10 11 12 |
# File 'lib/xcode_builder.rb', line 10 def configuration @configuration end |
Instance Method Details
#build ⇒ Object
desc “Build the beta release of the app”
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/xcode_builder.rb', line 61 def build clean unless @configuration.skip_clean # update the long version number with the date @configuration. if @configuration. print "Building Project..." success = xcodebuild @configuration.build_arguments, "build" raise "** BUILD FAILED **" unless success puts "Done" end |
#clean ⇒ Object
desc “Clean the Build”
52 53 54 55 56 57 58 |
# File 'lib/xcode_builder.rb', line 52 def clean unless @configuration.skip_clean print "Cleaning Project..." xcodebuild @configuration.build_arguments, "clean" puts "Done" end end |
#deploy ⇒ Object
110 111 112 113 |
# File 'lib/xcode_builder.rb', line 110 def deploy package @configuration.deployment_strategy.deploy end |
#package ⇒ Object
desc “Package the release as a distributable archive”
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/xcode_builder.rb', line 74 def package build print "Packaging and Signing..." if (@configuration.signing_identity != nil) then puts "" print "Signing identity: #{@configuration.signing_identity}" 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 cmd = [] cmd << "/usr/bin/xcrun" cmd << "-sdk iphoneos" cmd << "PackageApplication" cmd << "'#{@configuration.built_app_path}'" cmd << "-o '#{@configuration.ipa_path}'" cmd << "--sign '#{@configuration.signing_identity}'" unless @configuration.signing_identity == nil if @configuration.xcrun_extra_args then cmd.concat @configuration.xcrun_extra_args if @configuration.xcrun_extra_args.is_a? Array cmd << @configuration.xcrun_extra_args if @configuration.xcrun_extra_args.is_a? String end puts "Running #{cmd.join(" ")}" if @configuration.verbose cmd << "2>&1 /dev/null" cmd = cmd.join(" ") system(cmd) puts "" puts "Done." end |
#pod_dry_run ⇒ Object
runs a pod dry run before tagging
151 152 153 154 155 156 |
# File 'lib/xcode_builder.rb', line 151 def pod_dry_run print "Pod dry run..." result = system "pod lib lint #{@configuration.podspec_file} --allow-warnings" raise "** Pod dry run failed **" if !result puts "Done" end |
#pod_release ⇒ Object
desc “For CocoaPod libraries: dry run, tags SCM, pushes to cocoapod and increments build number”
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/xcode_builder.rb', line 128 def pod_release raise "CocoaPod repo is not set, aborting cocoapod_release task." unless @configuration.pod_repo != nil raise "Spec file is not set, aborting cocoapod_release task." unless @configuration.podspec_file != nil # make a dry run first pod_dry_run # tag source as needed if @configuration.release_strategy != nil then @configuration.release_strategy.tag_current_version end # and push pod pod push_pod # ask release strategy to bump the release number if @configuration.release_strategy != nil then @configuration.release_strategy.prepare_for_next_pod_release end puts "Pod successfully released" end |
#push_pod ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/xcode_builder.rb', line 158 def push_pod cmd = [] cmd << "pod repo push" cmd << @configuration.pod_repo cmd << @configuration.podspec_file cmd << "--allow-warnings" print "Pushing to CocoaPod..." result = system(cmd.join " ") raise "** Pod push failed **" if !result puts "Done." end |
#release ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/xcode_builder.rb', line 115 def release # deploy or package depending on configuration if @configuration.deployment_strategy then deploy else package end puts "" puts "App successfully released" end |
#xcodebuild(*args) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/xcode_builder.rb', line 40 def xcodebuild(*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) end |