Skip to content
Browse files

Much improved Xcode 4 archive support.

Archives are now stored in the correct location for Xcode 4, and include an Info.plist
just like the ones generated by Xcode itself. Your release notes will also be added
and will appear as a comment in Xcode organiser.
  • Loading branch information...
1 parent cc4eacb commit 5c205ee75b6dfaace307458c52ede05231c7322e @lukeredpath committed Jul 22, 2011
View
2 betabuilder.gemspec
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.date = %q{2011-07-22}
s.email = %q{luke@lukeredpath.co.uk}
s.extra_rdoc_files = ["README.md", "LICENSE", "CHANGES.md"]
- s.files = ["CHANGES.md", "LICENSE", "README.md", "lib/beta_builder", "lib/beta_builder/archived_build.rb", "lib/beta_builder/deployment_strategies", "lib/beta_builder/deployment_strategies/testflight.rb", "lib/beta_builder/deployment_strategies/web.rb", "lib/beta_builder/deployment_strategies.rb", "lib/beta_builder.rb", "lib/betabuilder.rb"]
+ s.files = ["CHANGES.md", "LICENSE", "README.md", "lib/beta_builder/archived_build.rb", "lib/beta_builder/deployment_strategies/testflight.rb", "lib/beta_builder/deployment_strategies/web.rb", "lib/beta_builder/deployment_strategies.rb", "lib/beta_builder.rb", "lib/betabuilder.rb"]
s.homepage = %q{http://github.com/lukeredpath/betabuilder}
s.rdoc_options = ["--main", "README.md"]
s.require_paths = ["lib"]
View
10 lib/beta_builder.rb
@@ -12,7 +12,7 @@ def initialize(namespace = :beta, &block)
:configuration => "Adhoc",
:build_dir => "build",
:auto_archive => false,
- :archive_path => File.expand_path("~/Library/Application Support/Developer/Shared/Archived Applications"),
+ :archive_path => File.expand_path("~/Library/Developer/Xcode/Archives"),
:xcodebuild_path => "xcodebuild",
:project_file_path => nil,
:workspace_path => nil,
@@ -43,6 +43,10 @@ def build_arguments
end
end
+ def archive_name
+ app_name || target
+ end
+
def app_file_name
if app_name
"#{app_name}.app"
@@ -149,8 +153,10 @@ def define
desc "Build and archive the app"
task :archive => :build do
+ puts "Archiving build..."
archive = BetaBuilder.archive(@configuration)
- archive.save_to(@configuration.archive_path)
+ output_path = archive.save_to(@configuration.archive_path)
+ puts "Archive saved to #{output_path}."
end
end
end
View
71 lib/beta_builder/archived_build.rb
@@ -1,5 +1,6 @@
require 'uuid'
require 'fileutils'
+require 'CFPropertyList'
module BetaBuilder
def self.archive(configuration)
@@ -21,6 +22,7 @@ def save_to(path)
FileUtils.mkdir(archive_path)
FileUtils.cp_r(@configuration.built_app_path, archive_path)
FileUtils.cp_r(@configuration.built_app_dsym_path, archive_path)
+ archive_path
end
end
@@ -29,13 +31,70 @@ def initialize(configuration)
@configuration = configuration
end
+ def archive_file_name
+ "#{@configuration.archive_name} #{Time.now.strftime('%Y-%m-%d %H.%M')}.xcarchive"
+ end
+
+ def archive_path_within(path)
+ File.join(path, "#{Time.now.strftime('%Y-%m-%d')}", archive_file_name)
+ end
+
+ def applications_path
+ File.join("Products", "Applications")
+ end
+
+ def dsyms_path
+ "dSYMs"
+ end
+
+ def plist_info_path
+ File.join(@configuration.built_app_path, "Info.plist")
+ end
+
def save_to(path)
- date_path = File.join(path, "#{Time.now.strftime('%Y-%m-%d')}")
- FileUtils.mkdir_p(date_path)
- archive_path = File.join(date_path, "#{@configuration.target}.xcarchive")
- FileUtils.mkdir(archive_path)
- FileUtils.cp_r(@configuration.built_app_path, archive_path)
- FileUtils.cp_r(@configuration.built_app_dsym_path, archive_path)
+ archive_path = archive_path_within(path)
+ FileUtils.mkdir_p(archive_path)
+
+ application_path = File.join(archive_path, applications_path)
+ FileUtils.mkdir_p(application_path)
+ FileUtils.cp_r(@configuration.built_app_path, application_path)
+
+ dsym_path = File.join(archive_path, dsyms_path)
+ FileUtils.mkdir_p(dsym_path)
+ FileUtils.cp_r(@configuration.built_app_dsym_path, dsym_path)
+
+ write_plist_to(archive_path)
+ archive_path
+ end
+
+ private
+
+ def write_plist_to(path)
+ plist = {
+ "ApplicationProperties" => {
+ "ApplicationPath" => File.join("Applications", "#{@configuration.app_file_name}.app"),
+ "CFBundleIdentifier" => metadata["CFBundleIdentifier"],
+ "CFBundleShortVersionString" => metadata["CFBundleShortVersionString"],
+ "IconPaths" => metadata["CFBundleIconFiles"].map { |file| File.join("Applications", @configuration.app_file_name, file) }
+ },
+ "ArchiveVersion" => 1.0,
+ "Comment" => @configuration.release_notes,
+ "CreationDate" => Time.now,
+ "Name" => @configuration.archive_name,
+ "SchemeName" => @configuration.scheme
+ }
+ File.open(File.join(path, "Info.plist"), "w") do |io|
+ io.write plist.to_plist
+ end
+ end
+
+ def metadata
+ @metadata ||= load_property_list(plist_info_path)
+ end
+
+ def load_property_list(path)
+ plist = CFPropertyList::List.new(:file => path)
+ CFPropertyList.native_types(plist.value)
end
end
end
View
4 lib/beta_builder/deployment_strategies/testflight.rb
@@ -53,15 +53,15 @@ def get_notes_using_editor
begin
filepath = "#{dir}/release_notes"
system("#{editor} #{filepath}")
- notes = File.read(filepath)
+ @configuration.release_notes = File.read(filepath)
ensure
rm_rf(dir)
end
end
def get_notes_using_prompt
puts "Enter the release notes for this build (hit enter twice when done):\n"
- gets_until_match(/\n{2}$/).strip
+ @configuration.release_notes = gets_until_match(/\n{2}$/).strip
end
def gets_until_match(pattern, string = "")

0 comments on commit 5c205ee

Please sign in to comment.
Something went wrong with that request. Please try again.