xcodebuilder 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md ADDED
@@ -0,0 +1,82 @@
1
+ ## 0.7.5
2
+ * Allows automation of version/build number setting
3
+ * Adds full paths to xcodebuild and xcrun; they are override-able in the config
4
+ * Adds ability to add arguments to package command
5
+ * Refactors commands and argument code
6
+ * Makes build and signing output optional (use config.verbose to trigger)
7
+ * Adds simplified output
8
+ * Allows custom SCP ports (@smtlaissezfaire)
9
+ * Fixes Archive task failure (@rennarda)
10
+ * Uses Apple's Packager to produce valid IPAs (@dts)
11
+ * Fixes cases where CFPropertyList could fail to load (@svelix)
12
+ * Uses relative paths for requires (@smtlaissezfaire)
13
+ * Raises an exception if the build fails (@epall)
14
+
15
+
16
+ ## 0.7.4.1
17
+ * Allow auto-archiving from other Rake namespaces (@victor)
18
+ * Fixed bug with Xcode archive sharing (@victor)
19
+ * Fall back on CFBundleVersion if CFBundleVersionShortString is not set (@subdigital)
20
+ * Added verbose and dry run options to the TestFlight deployment strategy (@subdigital)
21
+ * Defer dynamic release note generation until runtime (@subdigital)
22
+ * Allow architectures to be configured (@subdigital)
23
+ * Fix detection of build directories containing spaces
24
+
25
+ # 0.7.4
26
+ * YANKED
27
+
28
+ ## 0.7.3
29
+ * Made the Xcode derived data directory more robust by grepping for the Validate line in the log.
30
+
31
+ ## 0.7.2
32
+ * Handle missing values in Xcode archive plist.
33
+
34
+ ## 0.7.1
35
+ * Fixed a problem with detecting the Xcode 4 derived data directory.
36
+
37
+ ## 0.7.0
38
+ * Much improved Xcode 4 support.
39
+ * Generate Xcode 4 style archives using the :xcode4_archive_mode
40
+ * Xcode 4 style archives appear in Xcode organiser complete with your release notes.
41
+ * Added a :skip_clean option to skip cleaning when building
42
+ * Allow the app name to be explicitly set using :app_name
43
+ * WARNING: Xcode 3 support is officially deprecated as of this release!
44
+
45
+ ## 0.6.0
46
+ * Support Xcode 4 workspaces and schemes.
47
+
48
+ ## 0.5.0
49
+ * Support configurable path to xcodebuild executable
50
+ * Support configurable path to Xcode project file
51
+
52
+ ## 0.4
53
+ * If the user has set the EDITOR environment variable, use it to obtain the TestFlight release notes.
54
+ * Bugfix: TestFlight API now returns a 201 Created response when successful.
55
+ * Bugfix: Handle spaces in build artefacts.
56
+ * Updated the default archived build location to match the newest Xcode archived build location.
57
+
58
+ ## 0.3.2
59
+ * Fixed bug #2 (task fails when no testflight distribution list set)
60
+
61
+ ## 0.3.1
62
+ * Separate the :deploy task into :prepare and :deploy tasks.
63
+
64
+ ## 0.3
65
+ * Added support for distribution lists to the TestFlight deployment strategy
66
+
67
+ ## 0.2.1
68
+ * Allow the namespace of generated tasks to be customised
69
+
70
+ ## 0.2
71
+ * Introduced deployment strategies, allowing custom deployment methods
72
+ * Added support for deploying beta releases to TestFlightApp.com
73
+
74
+ ## 0.1.2
75
+
76
+ * Allow custom hosts when using the SCP deployment task (simonjefford)
77
+
78
+ ## 0.1.1
79
+ * Fixed missing dependency
80
+
81
+ ## 0.1
82
+ * Initial Release
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Luke Redpath
2
+ Copyright (c) 2013 Kra Larivain
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,248 @@
1
+ # BetaBuilder, a gem for managing iOS ad-hoc builds
2
+
3
+ BetaBuilder is a simple collection of Rake tasks and utilities for managing and publishing Adhoc builds of your iOS apps.
4
+
5
+ If you're looking for the OSX BetaBuilder app -- to which this gem owes most of the credit -- you can find it [here on Github](http://github.com/HunterHillegas/iOS-BetaBuilder).
6
+
7
+ **Note: As of release 0.7, support for Xcode 3 is deprecated. Xcode 4 has been out for a year, has got much more stable as of 4.1 on Lion (or 4.2 if you've been using the betas) and it's time to move on. Generating Xcode 4 friendly archives and builds in this release still needs a bit of configuration but will become much smoother in 0.8 once Xcode 3 support is removed.**
8
+
9
+ ## Motivation
10
+
11
+ The problem with using a GUI app to create the beta packages is that it is yet another manual step in the process of producing an ad-hoc build for your beta testers. It simplifies some steps but it still requires running Build and Archive in Xcode, saving the resulting build as an IPA package, running the Beta Builder app, locating the IPA, filling in the rest of the fields and generating the deployment files. Then you need to upload those files somewhere.
12
+
13
+ As a Ruby developer, I use Rake in most of my projects to run repetitive, often build or test-related tasks and it's equally as useful for non-Ruby projects as it is for Ruby ones.
14
+
15
+ This simple task library allows you to configure once and then build, package and distribute your ad-hoc releases with a single command.
16
+
17
+ ## Usage
18
+
19
+ To get started, if you don't already have a Rakefile in the root of your project, create one. If you aren't familiar with Rake, it might be worth [going over some of the basics](http://rake.rubyforge.org/) but it's fairly straightforward.
20
+
21
+ You can install the BetaBuilder gem from your terminal (OSX 10.6 ships with a perfectly useful Ruby installation):
22
+
23
+ $ gem install betabuilder
24
+
25
+ At the top of your Rakefile, you'll need to require `rubygems` and the `betabuilder` gem (obviously).
26
+
27
+ require 'rubygems'
28
+ require 'betabuilder'
29
+
30
+ Because BetaBuilder is a Rake task library, you do not need to define any tasks yourself. You simply need to configure BetaBuilder with some basic information about your project and it will generate the tasks for you. A sample configuration might look something like this:
31
+
32
+ BetaBuilder::Tasks.new do |config|
33
+ # your Xcode target name
34
+ config.target = "MyGreatApp"
35
+
36
+ # the Xcode configuration profile
37
+ config.configuration = "Adhoc"
38
+ end
39
+
40
+ Now, if you run `rake -T` in Terminal.app in the root of your project, the available tasks will be printed with a brief description of each one:
41
+
42
+ rake beta:build # Build the beta release of the app
43
+ rake beta:package # Package the beta release as an IPA file
44
+
45
+ If you use a custom Xcode build directory, rather than the default `${SRCROOT}/build` location, you can configure that too:
46
+
47
+ BetaBuilder::Tasks.new do |config|
48
+ ...
49
+ config.build_dir = "/path/to/custom/build/dir"
50
+ end
51
+
52
+ To deploy your beta to your testers, some additional configuration is needed (see the next section).
53
+
54
+ Most of the time, you'll not need to run the `beta:build` task directly; it will be run automatically as a dependency of `beta:package`. Upon running this task, your ad-hoc build will be packaged into an IPA file and will be saved in `${PROJECT_ROOT}/pkg/dist`, along with a HTML index file and the manifest file needed for over-the-air installation.
55
+
56
+ If you are not using the automatic deployment task, you will need to upload the contents of the pkg/dist directory to your server.
57
+
58
+ To use a namespace other than "beta" for the generated tasks, simply pass in your chosen namespace to BetaBuilder::Tasks.new:
59
+
60
+ BetaBuilder::Tasks.new(:my_custom_namespace) do |config|
61
+ end
62
+
63
+ This lets you set up different sets of BetaBuilder tasks for different configurations in the same Rakefile (e.g. a production and staging build).
64
+
65
+ ## Configuration
66
+ A full list of configuration options and their details
67
+
68
+ `configuration` - (String) The Xcode Configuration to use (Defined on the Info tab of the Project)
69
+
70
+ `build_dir` - (File Path) The directory the build output will be. (`:derived` for Xcode 4 for versions < 0.8)
71
+
72
+ `auto_archive` - (true/**false**) Automatically archive when packaging
73
+
74
+ `archive_path` - (File Path) Path to the Archives
75
+
76
+ `xcodebuild_path` - (File Path) Path to xcodebuild, if its non-standard
77
+
78
+ `xcodeargs` - (Arguments) Arguments passed to `xcodebuild` when it runs
79
+
80
+ `project_file_path` - (File Path) Path to the `.xcodeproj` file
81
+
82
+ `workspace_path` - (File Path) Path to the `.xcworkspace` file
83
+
84
+ `ipa_destination_path` - (File Path) Path to output Packaged IPA to
85
+
86
+ `scheme` - (String) What Scheme to use when building
87
+
88
+ `app_name` - (String) The name of the app being built (should match the file name, less the `.app` extension)
89
+
90
+ `arch` - (String) The architecture to build for, if different from project settings
91
+
92
+ `xcode4_archive_mode` - (true/**false**) Use Xcode4's Archive mode
93
+
94
+ `skip_clean` - (true/**false**) Skip the clean step when building
95
+
96
+ `verbose` - (true/**false**) Increased output for debugging
97
+
98
+ `dry_run` - (true/**false**) Don't upload to Distribution Strategy, just act like it
99
+
100
+ `set_version_number` - (true/**false**) Attempts to set a version number, see below
101
+
102
+ ### Configuration (Testflight)
103
+ Testflight presents its own set of options that can be configured
104
+
105
+ `api_token` - (String) Can be your API key, but its recommended to use an `ENV[""]` variable
106
+
107
+ `team_token` - (String) Your Team's Testflight API token
108
+
109
+ `distribution_lists` - (Array) A Ruby array (`[1,2]` or `%w{1 2}`) of distribution list names for Testflight
110
+
111
+ `notify` - (true/**false**) Notify the distribution list of this build
112
+
113
+ `replace` - (true/**false**) Replace if an existing build exists with the same ID and version
114
+
115
+ ### Configuration (Web)
116
+ Pushing to a web server has the following options.
117
+
118
+ SSH keys will simplify authentication and make this process seamless
119
+
120
+ `remote_host` - (String) Hostname for the server the build will be pushed to
121
+
122
+ `remote_port` - (String) Port Number to use for SCP/SFTP
123
+
124
+ `remote_installation_path` - (String) Remote Path
125
+
126
+ ### Configuration (RunTime)
127
+ Certain configuration options are availabe at the command line, so that you can temporarily set them for a single run without modifying your configuration.
128
+
129
+ Pass any of these in as environment variables:
130
+
131
+ `DRY` - (true/**false**) Enable Dry Run
132
+ `VERBOSE` - (true/**false**) Turn on all output; lets you see the clean, build, and signing output
133
+ `SKIPCLEAN` - (true/**false**) Skips the clean step and goes right to Build.
134
+
135
+ ####Examples
136
+
137
+ `rake staging:deploy DRY=true`
138
+
139
+ `rake staging:redeploy VERBOSE=true SKIPCLEAN=true`
140
+
141
+ ## Xcode 4 support
142
+
143
+ Betabuilder works with Xcode 4, but you may need to tweak your task configuration slightly. The most important change you will need to make is the build directory location, unless you have configured Xcode 4 to use the "build" directory relative to your project, as in Xcode 3.
144
+
145
+ If you are using the Xcode derived data directory for your builds, then you will need to specify this. Betabuilder will then scan your build log to determine the path to the automatically generated build directory that Xcode is using for your project.
146
+
147
+ config.build_dir = :derived
148
+
149
+ This will become the default in 0.8.
150
+
151
+ If you wish to generate archives for your Xcode 4 project, you will need to enable this. This will become the default in future once Xcode 3 support is dropped (deprecated in 0.7):
152
+
153
+ config.xcode4_archive_mode = true
154
+
155
+ If you are working with an Xcode 4 workspace instead of a project file, you will need to configure this too:
156
+
157
+ config.workspace_path = "MyWorkspace.xcworkspace"
158
+ config.scheme = "My App Scheme"
159
+ config.app_name = "MyApp"
160
+ set_version_number
161
+ If you are using a workspace, then you must specify the scheme. You can still specify the build configuration (e.g. Release).
162
+
163
+ ## Automatic deployment with deployment strategies
164
+
165
+ BetaBuilder allows you to deploy your built package using it's extensible deployment strategy system; the gem currently comes with support for simple web-based deployment or uploading to [TestFlightApp.com](http://www.testflightapp.com). Eventually, you will be able to write your own custom deployment strategies if neither of these are suitable for your needs.
166
+
167
+ ## Setting version numbers automatically
168
+
169
+ You can use betabuilder to set a build number using Git's `describe` system. In order for that to work, at least one `tag` must exist somewhere in the git hierarchy for the branch being built from.
170
+
171
+ Also, you are required to set your `CFBundleVersion` to `${VERSION_LONG}` inside your `Info.plist`. To accomodate manual builds, add a `VERSION_LONG` Build Setting to your app's Project, and treat it as you normally would your `Info.plist` version number.
172
+
173
+ Once a tag is created and your App is configured, simply add this to your BetaBuilder config and it will use Git to generate the
174
+
175
+ config.set_version_number = true
176
+
177
+ It will generate a version number like: `1.0-15-g6b3c1bb`.
178
+
179
+ * *1.0* is the most recent tag
180
+ * *15* is the number of commits since the tag was generated
181
+ * *g6b3c1bb* is the beginning of the hash of the last commit.
182
+
183
+ ### Deploying your app with TestFlight
184
+
185
+ By far the easiest way to get your beta release into the hands of your testers is using the excellent [TestFlight service](http://testflightapp.com/), although at the time of writing it is still in private beta. You can use TestFlight to manage your beta testers and notify them of new releases instantly.
186
+
187
+ TestFlight provides an upload API and betabuilder uses that to provide a `:testflight` upload strategy. This strategy requires two pieces of information: your TestFlight API token and your team token:
188
+
189
+ config.deploy_using(:testflight) do |tf|
190
+ tf.api_token = "YOUR_API_TOKEN"
191
+ tf.team_token = "YOUR_TEAM_TOKEN"
192
+ end
193
+
194
+ Now, instead of using the `beta:package` task, you can run the `beta:deploy` task instead. This task will run the package task as a dependency and upload the generated IPA file to TestFlight.
195
+
196
+ You will be prompted to enter the release notes for the build; TestFlight requires these to inform your testers of what has changed in this build. Alternatively, if you have a way of generating the release notes automatically (for instance, using a CHANGELOG file or a git log command), you can specify a block that will be called at runtime - you can do whatever you want in this block, as long as you return a string which will be used as the release notes, e.g.
197
+
198
+ config.deploy_using(:testflight) do |tf|
199
+ ...
200
+ tf.generate_release_notes do
201
+ # return release notes here
202
+ end
203
+ end
204
+
205
+ Finally, you can also specify an array of distribution lists that you want to allow access to the build:
206
+
207
+ config.deploy_using(:testflight) do |tf|
208
+ ...
209
+ tf.distribution_lists = %w{Testers Internal}
210
+ end
211
+
212
+ ### Deploying to your own server
213
+
214
+ BetaBuilder also comes with a rather rudimentary web-based deployment task that uses SCP, so you will need SSH access to your server and appropriate permissions to use it. This works in the same way as the original iOS-BetaBuilder GUI app by generating a HTML template and manifest file that can be uploaded to a directly on your server. It includes links to install the app automatically on the device or download the IPA file.
215
+
216
+ You will to configure betabuilder to use the `web` deployment strategy with some additional configuration:
217
+
218
+ config.deploy_using(:web) do |web|
219
+ web.deploy_to = "http://beta.myserver.co.uk/myapp"
220
+ web.remote_host = "myserver.com"
221
+ web.remote_directory = "/remote/path/to/deployment/directory"
222
+ end
223
+
224
+ The `deploy_to` setting specifies the URL that your app will be published to. The `remote_host` setting is the SSH host that will be used to copy the files to your server using SCP. Finally, the `remote_directory` setting is the path to the location to your server that files will be uploaded to. You will need to configure any virtual hosts on your server to make this work.
225
+
226
+ ## License
227
+
228
+ This code is licensed under the MIT license.
229
+
230
+ Copyright (c) 2010 Luke Redpath
231
+
232
+ Permission is hereby granted, free of charge, to any person obtaining a copy
233
+ of this software and associated documentation files (the "Software"), to deal
234
+ in the Software without restriction, including without limitation the rights
235
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
236
+ copies of the Software, and to permit persons to whom the Software is
237
+ furnished to do so, subject to the following conditions:
238
+
239
+ The above copyright notice and this permission notice shall be included in
240
+ all copies or substantial portions of the Software.
241
+
242
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
243
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
244
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
245
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
246
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
247
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
248
+ THE SOFTWARE.
@@ -0,0 +1,299 @@
1
+ require 'rake/tasklib'
2
+ require 'ostruct'
3
+ require 'fileutils'
4
+ require 'cfpropertylist'
5
+ require File.dirname(__FILE__) + '/xcode_builder/configuration'
6
+ require File.dirname(__FILE__) + '/xcode_builder/build_output_parser'
7
+
8
+ module XcodeBuilder
9
+ class XcodeBuilder
10
+ attr_reader :configuration
11
+
12
+ def initialize(namespace = :xcbuild, &block)
13
+ @configuration = Configuration.new(
14
+ :configuration => "Adhoc",
15
+ :build_dir => "build",
16
+ :xcodebuild_extra_args => nil,
17
+ :xcrun_extra_args => nil,
18
+ :project_file_path => nil,
19
+ :workspace_file_path => nil,
20
+ :sdk => "iphoneos",
21
+ :scheme => nil,
22
+ :app_name => nil,
23
+ :app_extension => "app",
24
+ :package_destination_path => "./pkg",
25
+ :skip_dsym => false,
26
+ :arch => nil,
27
+ :skip_clean => ENV.fetch('SKIPCLEAN', false),
28
+ :verbose => ENV.fetch('VERBOSE', false),
29
+ :info_plist => nil,
30
+ :scm => nil,
31
+ :tag_vcs => false,
32
+ :increment_plist_version => false,
33
+ :podspec_file => nil
34
+ )
35
+ @namespace = namespace
36
+ yield @configuration if block_given?
37
+ end
38
+
39
+ def xcodebuild(*args)
40
+ # we're using tee as we still want to see our build output on screen
41
+ cmd = []
42
+ cmd << "/usr/bin/xcodebuild"
43
+ cmd.concat args
44
+ puts "Running: #{cmd.join(" ")}" if @configuration.verbose
45
+ cmd << "2>&1 %s build.output" % (@configuration.verbose ? '| tee' : '>')
46
+ cmd = cmd.join(" ")
47
+ system(cmd)
48
+ end
49
+
50
+ # # desc "Clean the Build"
51
+ def clean
52
+ unless @configuration.skip_clean
53
+ print "Cleaning Project..."
54
+ xcodebuild @configuration.build_arguments, "clean"
55
+ puts "Done"
56
+ end
57
+ end
58
+
59
+ # # desc "Build the beta release of the app"
60
+ def build
61
+ clean unless @configuration.skip_clean
62
+
63
+ print "Building Project..."
64
+ xcodebuild @configuration.build_arguments, "build"
65
+ raise "** BUILD FAILED **" if BuildOutputParser.new(File.read("build.output")).failed?
66
+ puts "Done"
67
+ end
68
+
69
+ # # desc "Package the release as a distributable archive"
70
+ def package
71
+ build
72
+ # there is no need for IPA or dSYM unless we have a device/macosx build,
73
+ # so do that part only on iphoneos/macosx SDKs
74
+ #
75
+ if(@configuration.sdk.eql? "iphoneos") then
76
+ package_ios_ipa
77
+ package_dsym
78
+ package_artifact
79
+ elsif (@configuration.sdk.eql? "macosx") then
80
+ package_macos_app
81
+ package_dsym
82
+ package_artifact
83
+ else
84
+ package_simulator_app
85
+ end
86
+ end
87
+
88
+ # # desc "Builds an IPA from the built .app"
89
+ def package_ios_app
90
+ print "Packaging and Signing..."
91
+ raise "** PACKAGE FAILED ** No Signing Identity Found" unless @configuration.signing_identity
92
+ # trash and create the dist IPA path if needed
93
+ FileUtils.rm_rf @configuration.package_destination_path unless !File.exists? @configuration.package_destination_path
94
+ FileUtils.mkdir_p @configuration.package_destination_path
95
+
96
+ # Construct the IPA and Sign it
97
+ cmd = []
98
+ cmd << "/usr/bin/xcrun"
99
+ cmd << "-sdk #{@configuration.sdk}"
100
+ cmd << "PackageApplication"
101
+ cmd << "-v '#{@configuration.built_app_path}'"
102
+ cmd << "-o '#{@configuration.ipa_path}'"
103
+ cmd << "--sign '#{@configuration.signing_identity}'"
104
+ cmd << "--embed '#{@configuration.provisioning_profile}'" unless @configuration.signing_identity == nil
105
+ if @configuration.xcrun_extra_args then
106
+ cmd.concat @configuration.xcrun_extra_args if @configuration.xcrun_extra_args.is_a? Array
107
+ cmd << @configuration.xcrun_extra_args if @configuration.xcrun_extra_args.is_a? String
108
+ end
109
+ puts "Running #{cmd.join(" ")}" if @configuration.verbose
110
+ cmd << "2>&1 %s build.output" % (@configuration.verbose ? '| tee' : '>')
111
+ cmd = cmd.join(" ")
112
+ system(cmd)
113
+
114
+ # zip the dSYM over to the dist folder
115
+ puts "Done"
116
+ end
117
+
118
+ def package_macos_app
119
+ # clean the pkg folder: create it if it doesn't exist yet
120
+ FileUtils.mkdir_p @configuration.package_destination_path unless File.exists? @configuration.package_destination_path
121
+ # and remove an existing app_bundle_path if it exists
122
+ FileUtils.rm_rf @configuration.app_bundle_path unless !File.exists? @configuration.app_bundle_path
123
+
124
+ # now we can properly copy the app bundle path over.
125
+ FileUtils.cp_r @configuration.built_app_path, "#{@configuration.package_destination_path}"
126
+ end
127
+
128
+ def package_simulator_app
129
+ # clean the pkg folder: create it if it doesn't exist yet
130
+ FileUtils.mkdir_p @configuration.package_destination_path unless File.exists? @configuration.package_destination_path
131
+ # and remove an existing app_bundle_path if it exists
132
+ FileUtils.rm_rf @configuration.app_bundle_path unless !File.exists? @configuration.app_bundle_path
133
+
134
+ # now we can properly copy the app bundle path over.
135
+ FileUtils.cp_r @configuration.built_app_path, "#{@configuration.package_destination_path}"
136
+ end
137
+
138
+ # desc "Zips the dSYM to the package folder"
139
+ def package_dsym
140
+ if @configuration.skip_dsym then
141
+ return
142
+ end
143
+ print "Packaging dSYM..."
144
+
145
+ # copy the dSYM to the pkg destination
146
+ FileUtils.cp_r @configuration.built_dsym_path, @configuration.package_destination_path
147
+
148
+ # the version is pulled from a path relative location, so fetch BEFORE
149
+ # we Dir.chdir
150
+ dsym_name = @configuration.dsym_name
151
+ dsym_target_path = @configuration.dsym_path
152
+
153
+ # move to pkg destination and zip the dSYM
154
+ current_dir = Dir.pwd
155
+ Dir.chdir @configuration.package_destination_path
156
+
157
+ cmd = []
158
+ cmd << "zip"
159
+ cmd << "-r"
160
+ cmd << dsym_target_path
161
+ cmd << "#{@configuration.app_name}.#{@configuration.app_extension}.dSYM"
162
+
163
+ puts "Running #{cmd.join(" ")}" if @configuration.verbose
164
+ cmd << "2>&1 %s ../build.output" % (@configuration.verbose ? '| tee' : '>')
165
+ cmd = cmd.join(" ")
166
+ system(cmd)
167
+ # back to working directory
168
+ Dir.chdir current_dir
169
+ end
170
+
171
+ # desc "Packages the final artifact (IPA + dSYM)"
172
+ def package_artifact
173
+ # keep track of current working dir
174
+ current_dir = Dir.pwd
175
+ Dir.chdir @configuration.package_destination_path
176
+
177
+ # zip final package
178
+ cmd = []
179
+ cmd << "zip"
180
+ cmd << @configuration.zipped_package_name
181
+ cmd << @configuration.dsym_name unless @configuration.skip_dsym
182
+ cmd << @configuration.ipa_name unless !@configuration.sdk.eql? "iphoneos"
183
+ cmd << "#{@configuration.app_name}.#{@configuration.app_extension}" unless !@configuration.sdk.eql? "macosx"
184
+ cmd << "2>&1 %s ../build.output" % (@configuration.verbose ? '| tee' : '>')
185
+ system cmd.join " "
186
+
187
+ # delete all the artifacts but the .app. which will be needed by the automation builds
188
+ File.delete @configuration.dsym_name unless !File.exists? @configuration.dsym_name
189
+ FileUtils.rm_rf "#{@configuration.app_name}.#{@configuration.app_extension}.dSYM" unless !File.exists? "#{@configuration.app_name}.#{@configuration.app_extension}.dSYM"
190
+
191
+ # back to working directory
192
+ Dir.chdir current_dir
193
+
194
+ puts "Done"
195
+ puts "ZIP package: #{@configuration.zipped_package_name}"
196
+ end
197
+
198
+ # desc "For CocoaPod libraries: Tags SCM, pushes to cocoapod and increments build number"
199
+ def pod_release
200
+ build
201
+ raise "CocoaPod repo is not set, aborting cocoapod_release task." unless @configuration.pod_repo != nil
202
+ raise "Spec file is not set, aborting cocoapod_release task." unless @configuration.podspec_file != nil
203
+
204
+ # tag and push current pod
205
+ @configuration.release_strategy.tag_current_version
206
+ push_pod
207
+
208
+ # increment version numbers
209
+ if increment_pod_and_plist_number then
210
+ # and push appropriately
211
+ @configuration.release_strategy.prepare_for_next_pod_release
212
+ end
213
+ end
214
+
215
+ def push_pod
216
+ cmd = []
217
+ cmd << "pod"
218
+ cmd << "push"
219
+ cmd << @configuration.pod_repo
220
+ # cmd << "--local-only"
221
+ cmd << "--allow-warnings"
222
+
223
+ print "Pushing to CocoaPod..."
224
+ system (cmd.join " ")
225
+ puts "Done."
226
+ end
227
+
228
+ def increment_pod_and_plist_number
229
+ old_build_number = @configuration.build_number
230
+ if !prepare_for_next_release then
231
+ return false
232
+ end
233
+
234
+ # bump the spec version and save it
235
+ spec_content = File.open(@configuration.podspec_file, "r").read
236
+ old_version = "version = '#{old_build_number}'"
237
+ new_version = "version = '#{@configuration.build_number}'"
238
+
239
+ spec_content = spec_content.sub old_version, new_version
240
+
241
+ File.open(@configuration.podspec_file, "w") {|f|
242
+ f.write spec_content
243
+ }
244
+
245
+ true
246
+ end
247
+
248
+ def deploy
249
+ package
250
+ # deploy first
251
+ @configuration.deployment_strategy.deploy
252
+ end
253
+
254
+ def release
255
+ # deploy or package depending on configuration
256
+ if @configuration.deployment_strategy then
257
+ deploy
258
+ else
259
+ package
260
+ end
261
+
262
+ # tag first, then prepare for next release and
263
+ # commit the updated plist
264
+ if @configuration.tag_vcs then
265
+ @configuration.release_strategy.tag_current_version
266
+ end
267
+
268
+ if prepare_for_next_release then
269
+ @configuration.release_strategy.prepare_for_next_release
270
+ end
271
+ end
272
+
273
+ def prepare_for_next_release
274
+ if !@configuration.increment_plist_version then
275
+ return false
276
+ end
277
+
278
+ next_build_number = @configuration.next_build_number
279
+ if next_build_number == nil then
280
+ return false
281
+ end
282
+
283
+ print "Updating #{@configuration.info_plist} to version #{next_build_number}"
284
+
285
+ # read the plist and extract data
286
+ plist = CFPropertyList::List.new(:file => @configuration.info_plist_path)
287
+ data = CFPropertyList.native_types(plist.value)
288
+
289
+ # re inject new version number into the data
290
+ data["CFBundleVersion"] = next_build_number
291
+
292
+ # recreate the plist and save it
293
+ plist.value = CFPropertyList.guess(data)
294
+ plist.save(@configuration.info_plist_path, CFPropertyList::List::FORMAT_XML)
295
+ puts "Done"
296
+ return true
297
+ end
298
+ end
299
+ end