From 4499b18b4ee7d468fef9ec72496e77f4e4533f3a Mon Sep 17 00:00:00 2001 From: Shan Ul Haq Date: Tue, 6 Jan 2015 23:30:58 +1100 Subject: [PATCH 01/13] fixed if any value in build settings contains in the values --- lib/xcode/configuration.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/xcode/configuration.rb b/lib/xcode/configuration.rb index 036256e..3a70dcf 100644 --- a/lib/xcode/configuration.rb +++ b/lib/xcode/configuration.rb @@ -442,6 +442,8 @@ def substitute(value) case match when "$(TARGET_NAME)" @target.name + when "$(SRCROOT)" + else raise "Unknown substitution variable #{match}" end From de740a0310bf078a03d50274b1bd30b51808ff28 Mon Sep 17 00:00:00 2001 From: Shan Ul Haq Date: Wed, 7 Jan 2015 02:52:53 +1100 Subject: [PATCH 02/13] hockeyapp deployer --- lib/xcode/deploy/hockeyapp.rb | 77 +++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 lib/xcode/deploy/hockeyapp.rb diff --git a/lib/xcode/deploy/hockeyapp.rb b/lib/xcode/deploy/hockeyapp.rb new file mode 100644 index 0000000..0fcafb4 --- /dev/null +++ b/lib/xcode/deploy/hockeyapp.rb @@ -0,0 +1,77 @@ +require 'rest-client' + +module Xcode + module Deploy + class Hockeyapp + attr_accessor :app_id, :hockeyapp_token, :status, :notify, :proxy, :notes, :notes_type, :lists, :builder, :tags, :teams, :users + @@defaults = {} + + def self.defaults(defaults={}) + @@defaults = defaults + end + + def initialize(builder, options={}) + @builder = builder + @api_token = options[:app_id]||@@defaults[:app_id] + @team_token = options[:hockeyapp_token]||@@defaults[:hockeyapp_token] + @status = options[:status] + @notify = options[:notify] + @notes = options[:notes] + @notes_type = options[:notes_type] + @tags = options[:tags]||[] + @teams = options[:teams]||[] + @users = options[:users]||[] + @proxy = ENV['http_proxy'] || ENV['HTTP_PROXY'] + end + + def deploy + puts "Uploading to HockeyApp..." + + # RestClient.proxy = @proxy || ENV['http_proxy'] || ENV['HTTP_PROXY'] + # RestClient.log = '/tmp/restclient.log' + # + # response = RestClient.post('http://testflightapp.com/api/builds.json', + # :file => File.new(builder.ipa_path), + # :dsym => File.new(builder.dsym_zip_path), + # :api_token => @api_token, + # :team_token => @team_token, + # :notes => @notes, + # :notify => @notify ? 'True' : 'False', + # :distribution_lists => @lists.join(',') + # ) + # + # json = JSON.parse(response) + # puts " + Done, got: #{json.inspect}" + # json + + + curl \ + -F "status=2" \ + -F "notify=1" \ + -F "notes=Some new features and fixed bugs." \ + -F "notes_type=0" \ + -F "ipa=@hockeyapp.ipa" \ + -F "dsym=@hockeyapp.dSYM.zip" \ + -H "X-HockeyAppToken: 4567abcd8901ef234567abcd8901ef23" \ + + + cmd = Xcode::Shell::Command.new 'curl' + cmd << "--proxy #{@proxy}" unless @proxy.nil? or @proxy=='' + cmd << "-X POST https://rink.hockeyapp.net/api/2/apps/#{@app_id}/app_versions/upload" + cmd << "-F ipa=@\"#{@builder.ipa_path}\"" + cmd << "-F dsym=@\"#{@builder.dsym_zip_path}\"" unless @builder.dsym_zip_path.nil? + cmd << "-F notes=\"#{@notes}\"" unless @notes.nil? + cmd << "-F distribution_lists='#{@lists.join(',')}'" unless @lists.count==0 + + response = cmd.execute + + json = MultiJson.load(response.join('')) + puts " + Done, got: #{json.inspect}" + + yield(json) if block_given? + + json + end + end + end +end From 5ba5b4385b2a640101d4dd02bc869c89ad6aac06 Mon Sep 17 00:00:00 2001 From: Shan Ul Haq Date: Thu, 8 Jan 2015 13:51:42 +1100 Subject: [PATCH 03/13] removed the no longer maintained --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index c8189da..bc0095c 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,5 @@ # XCoder -## No Longer Maintained - -Unfortuantely, I just don't have the time to maintain Xcoder, and given there are so many other tools that do bits and peices of what xcoder does, it doesnt feel as needed any more. - -Perhaps parts of xcoder (keychain, profile management) could be extracted into stand-along tools - take a more unix-y approach to managing tools. - -If anyone wants to more actively maintain Xcoder, please contact me. - ## Description Taking the pain out of scripting and automating xcode builds. From ef4f831b29ba6b347b6aed39b6e0196a604fc30b Mon Sep 17 00:00:00 2001 From: Shan Ul Haq Date: Thu, 8 Jan 2015 14:59:51 +1100 Subject: [PATCH 04/13] added hockeyapp.rb --- lib/xcode/deploy/hockeyapp.rb | 23 +++++++-------- xcoder.iml | 53 +++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 xcoder.iml diff --git a/lib/xcode/deploy/hockeyapp.rb b/lib/xcode/deploy/hockeyapp.rb index 0fcafb4..5ff95c4 100644 --- a/lib/xcode/deploy/hockeyapp.rb +++ b/lib/xcode/deploy/hockeyapp.rb @@ -3,7 +3,7 @@ module Xcode module Deploy class Hockeyapp - attr_accessor :app_id, :hockeyapp_token, :status, :notify, :proxy, :notes, :notes_type, :lists, :builder, :tags, :teams, :users + attr_accessor :app_id, :hockeyapp_token, :status, :notify, :proxy, :notes, :notes_type, :builder, :tags, :teams, :users @@defaults = {} def self.defaults(defaults={}) @@ -12,8 +12,8 @@ def self.defaults(defaults={}) def initialize(builder, options={}) @builder = builder - @api_token = options[:app_id]||@@defaults[:app_id] - @team_token = options[:hockeyapp_token]||@@defaults[:hockeyapp_token] + @app_id = options[:app_id]||@@defaults[:app_id] + @hockeyapp_token = options[:hockeyapp_token]||@@defaults[:hockeyapp_token] @status = options[:status] @notify = options[:notify] @notes = options[:notes] @@ -45,15 +45,6 @@ def deploy # json - curl \ - -F "status=2" \ - -F "notify=1" \ - -F "notes=Some new features and fixed bugs." \ - -F "notes_type=0" \ - -F "ipa=@hockeyapp.ipa" \ - -F "dsym=@hockeyapp.dSYM.zip" \ - -H "X-HockeyAppToken: 4567abcd8901ef234567abcd8901ef23" \ - cmd = Xcode::Shell::Command.new 'curl' cmd << "--proxy #{@proxy}" unless @proxy.nil? or @proxy=='' @@ -61,7 +52,13 @@ def deploy cmd << "-F ipa=@\"#{@builder.ipa_path}\"" cmd << "-F dsym=@\"#{@builder.dsym_zip_path}\"" unless @builder.dsym_zip_path.nil? cmd << "-F notes=\"#{@notes}\"" unless @notes.nil? - cmd << "-F distribution_lists='#{@lists.join(',')}'" unless @lists.count==0 + cmd << "-F notify=\"#{@notify}\"" unless @notify.nil? + cmd << "-F status=\"#{@status}\"" unless @status.nil? + cmd << "-F notes_type=\"#{@notes_type}\"" unless @notes_type.nil? + cmd << "-F tags='#{@tags.join(',')}'" unless @tags.count==0 + cmd << "-F teams='#{@teams.join(',')}'" unless @teams.count==0 + cmd << "-F users='#{@users.join(',')}'" unless @users.count==0 + cmd << "-H \"X-HockeyAppToken: #{@hockeyapp_token}\"" response = cmd.execute diff --git a/xcoder.iml b/xcoder.iml new file mode 100644 index 0000000..6f25e7d --- /dev/null +++ b/xcoder.iml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 4a2bf2c5809ec6ba1f71768bcab4df6f35ffedbd Mon Sep 17 00:00:00 2001 From: Shan Ul Haq Date: Thu, 8 Jan 2015 15:00:55 +1100 Subject: [PATCH 05/13] bump to 0.1.20 --- lib/xcode/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/xcode/version.rb b/lib/xcode/version.rb index f4766ec..1ad093e 100644 --- a/lib/xcode/version.rb +++ b/lib/xcode/version.rb @@ -1,3 +1,3 @@ module Xcode - VERSION = "0.1.19" + VERSION = "0.1.20" end From 152e2f7f66b2bc0bc3a09864d7efe9765aea7944 Mon Sep 17 00:00:00 2001 From: Shan Ul Haq Date: Wed, 20 May 2015 13:29:16 +1000 Subject: [PATCH 06/13] updated rake script to add xcpretty --- Gemfile | 1 + lib/xcode/builder/base_builder.rb | 5 ++++- lib/xcode/version.rb | 2 +- lib/xcoder.rb | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 7280bb8..faa75ed 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,7 @@ gem 'builder' gem 'multi_json' gem 'plist' gem 'rest-client' +gem 'xcpretty' # Documentation gem 'yard' diff --git a/lib/xcode/builder/base_builder.rb b/lib/xcode/builder/base_builder.rb index 4bf75e1..67ccf62 100644 --- a/lib/xcode/builder/base_builder.rb +++ b/lib/xcode/builder/base_builder.rb @@ -52,7 +52,7 @@ def dependencies end end - def prepare_xcodebuild sdk=@sdk #:yield: Xcode::Shell::Command + def prepare_xcodebuild sdk=@sdk, is_test #:yield: Xcode::Shell::Command with_command 'xcodebuild' do |cmd| cmd.log_to_file = true @@ -79,6 +79,9 @@ def prepare_xcodebuild sdk=@sdk #:yield: Xcode::Shell::Command cmd << "-sdk #{sdk}" unless sdk.nil? + #include xcpretty + cmd << " | xcpretty" + yield cmd if block_given? end end diff --git a/lib/xcode/version.rb b/lib/xcode/version.rb index 1ad093e..624e80a 100644 --- a/lib/xcode/version.rb +++ b/lib/xcode/version.rb @@ -1,3 +1,3 @@ module Xcode - VERSION = "0.1.20" + VERSION = "0.1.21" end diff --git a/lib/xcoder.rb b/lib/xcoder.rb index 97d90da..c80ad9b 100644 --- a/lib/xcoder.rb +++ b/lib/xcoder.rb @@ -10,6 +10,7 @@ require 'xcode/workspace' require 'xcode/platform' require 'multi_json' +require 'xcpretty' module Xcode From 4991f0425a5a9fe13c8dd2eb27e98bf04c606a8c Mon Sep 17 00:00:00 2001 From: Shan Ul Haq Date: Wed, 20 May 2015 13:39:27 +1000 Subject: [PATCH 07/13] added xcpretty --- lib/xcode/builder/base_builder.rb | 3 --- lib/xcode/builder/scheme_builder.rb | 3 +++ lib/xcode/version.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/xcode/builder/base_builder.rb b/lib/xcode/builder/base_builder.rb index 67ccf62..8f2cce9 100644 --- a/lib/xcode/builder/base_builder.rb +++ b/lib/xcode/builder/base_builder.rb @@ -79,9 +79,6 @@ def prepare_xcodebuild sdk=@sdk, is_test #:yield: Xcode::Shell::Command cmd << "-sdk #{sdk}" unless sdk.nil? - #include xcpretty - cmd << " | xcpretty" - yield cmd if block_given? end end diff --git a/lib/xcode/builder/scheme_builder.rb b/lib/xcode/builder/scheme_builder.rb index 7e5320c..1b7ca54 100644 --- a/lib/xcode/builder/scheme_builder.rb +++ b/lib/xcode/builder/scheme_builder.rb @@ -26,6 +26,9 @@ def prepare_xcodebuild sdk=@sdk cmd << @scheme.parent.to_xcodebuild_option cmd << "-scheme \"#{@scheme.name}\"" cmd << "-configuration \"#{@scheme.archive_config}\"" + #include xcpretty + cmd << " | xcpretty" + cmd end diff --git a/lib/xcode/version.rb b/lib/xcode/version.rb index 624e80a..a622649 100644 --- a/lib/xcode/version.rb +++ b/lib/xcode/version.rb @@ -1,3 +1,3 @@ module Xcode - VERSION = "0.1.21" + VERSION = "0.1.22" end From faf33c76bfc588656ee9abee7b74a03386a402b9 Mon Sep 17 00:00:00 2001 From: Shan Ul Haq Date: Wed, 20 May 2015 14:06:36 +1000 Subject: [PATCH 08/13] revert bacj --- lib/xcode/builder/base_builder.rb | 2 +- lib/xcode/builder/scheme_builder.rb | 3 --- lib/xcode/version.rb | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/xcode/builder/base_builder.rb b/lib/xcode/builder/base_builder.rb index 8f2cce9..4bf75e1 100644 --- a/lib/xcode/builder/base_builder.rb +++ b/lib/xcode/builder/base_builder.rb @@ -52,7 +52,7 @@ def dependencies end end - def prepare_xcodebuild sdk=@sdk, is_test #:yield: Xcode::Shell::Command + def prepare_xcodebuild sdk=@sdk #:yield: Xcode::Shell::Command with_command 'xcodebuild' do |cmd| cmd.log_to_file = true diff --git a/lib/xcode/builder/scheme_builder.rb b/lib/xcode/builder/scheme_builder.rb index 1b7ca54..7e5320c 100644 --- a/lib/xcode/builder/scheme_builder.rb +++ b/lib/xcode/builder/scheme_builder.rb @@ -26,9 +26,6 @@ def prepare_xcodebuild sdk=@sdk cmd << @scheme.parent.to_xcodebuild_option cmd << "-scheme \"#{@scheme.name}\"" cmd << "-configuration \"#{@scheme.archive_config}\"" - #include xcpretty - cmd << " | xcpretty" - cmd end diff --git a/lib/xcode/version.rb b/lib/xcode/version.rb index a622649..dbca93e 100644 --- a/lib/xcode/version.rb +++ b/lib/xcode/version.rb @@ -1,3 +1,3 @@ module Xcode - VERSION = "0.1.22" + VERSION = "0.1.23" end From 709628a25f7962004d1babb59b80cd972acbb715 Mon Sep 17 00:00:00 2001 From: "Son.Nguyen" Date: Wed, 15 Jul 2015 14:51:29 +1000 Subject: [PATCH 09/13] Copy over the swift files into a folder called SwiftSupport --- lib/xcode/builder/base_builder.rb | 40 +++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/lib/xcode/builder/base_builder.rb b/lib/xcode/builder/base_builder.rb index 4bf75e1..928a3e6 100644 --- a/lib/xcode/builder/base_builder.rb +++ b/lib/xcode/builder/base_builder.rb @@ -26,7 +26,7 @@ def profile= (value) @profile = ProvisioningProfile.new(value) end end - + def cocoapods_installed? system("which pod > /dev/null 2>&1") end @@ -43,7 +43,7 @@ def dependencies if has_dependencies? and cocoapods_installed? print_task :builder, "Fetch depencies", :notice podfile = File.join(File.dirname(@target.project.path), "Podfile") - + print_task :cocoapods, "pod setup", :info with_command('pod setup').execute @@ -57,10 +57,10 @@ def prepare_xcodebuild sdk=@sdk #:yield: Xcode::Shell::Command cmd.log_to_file = true cmd.attach Xcode::Builder::XcodebuildParser.new - + cmd.env["OBJROOT"] = "\"#{objroot}/\"" cmd.env["SYMROOT"] = "\"#{symroot}/\"" - + unless profile.nil? profile.install print_task "builder", "Using profile #{profile.install_path}", :debug @@ -81,8 +81,8 @@ def prepare_xcodebuild sdk=@sdk #:yield: Xcode::Shell::Command yield cmd if block_given? end - end - + end + def with_command command_line cmd = Xcode::Shell::Command.new command_line cmd.output_dir = objroot @@ -124,6 +124,31 @@ def prepare_package_command end end + def copy_swift_packages + swift_frameworks = Dir["#{app_path}/Frameworks/libswift*"] + + unless swift_frameworks.empty? + Dir.mktmpdir do | tmpdir | + swift_support_path = File.join(tmpdir, "SwiftSupport") + + Dir.mkdir(swift_support_path) + + swift_frameworks.each do | path | + FileUtils.cp(path, swift_support_path, :verbose => true) + end + + command = with_command 'zip' do |zip| + zip << "--recurse-paths \"#{ipa_path}\" \"SwiftSupport\"" + end + + #have to change the directory so we can just zip in the SwiftSupport folder + Dir.chdir(tmpdir) do + command.execute + end + end + end + end + def prepare_dsym_command # package dSYM with_command 'zip' do |cmd| @@ -246,6 +271,7 @@ def package options = {}, &block print_task :package, "generating IPA: #{ipa_path}", :info with_keychain do prepare_package_command.execute + copy_swift_packages end print_task :package, "creating dSYM zip: #{dsym_zip_path}", :info @@ -308,7 +334,7 @@ def objroot @objroot ||= build_path end - def symroot + def symroot @symroot ||= File.join(build_path, 'Products') end From 80f2a04c45776d1da8dff03204746eef0874cc21 Mon Sep 17 00:00:00 2001 From: "Son.Nguyen" Date: Thu, 16 Jul 2015 10:45:33 +1000 Subject: [PATCH 10/13] Copied over the toolchain libraries instead of the one in the build folder --- lib/xcode/builder/base_builder.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/xcode/builder/base_builder.rb b/lib/xcode/builder/base_builder.rb index 928a3e6..3c8bcad 100644 --- a/lib/xcode/builder/base_builder.rb +++ b/lib/xcode/builder/base_builder.rb @@ -133,8 +133,13 @@ def copy_swift_packages Dir.mkdir(swift_support_path) + swift_frameworks.each do | path | - FileUtils.cp(path, swift_support_path, :verbose => true) + filename = File.basename(path) + xcode_path = `xcode-select --print-path` + toolchain_version = "#{xcode_path.strip}/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/#{@sdk}/#{filename}" + + FileUtils.cp(toolchain_version, swift_support_path, :verbose => true) end command = with_command 'zip' do |zip| From 3fc171051a2bce990f86e7f878424195d351e823 Mon Sep 17 00:00:00 2001 From: "Son.Nguyen" Date: Thu, 16 Jul 2015 10:57:00 +1000 Subject: [PATCH 11/13] xcode path can be called once --- lib/xcode/builder/base_builder.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/xcode/builder/base_builder.rb b/lib/xcode/builder/base_builder.rb index 3c8bcad..0beecde 100644 --- a/lib/xcode/builder/base_builder.rb +++ b/lib/xcode/builder/base_builder.rb @@ -124,20 +124,20 @@ def prepare_package_command end end + # Packaging doesn't come with SwiftSupport folder, so we need to copy them over. def copy_swift_packages swift_frameworks = Dir["#{app_path}/Frameworks/libswift*"] unless swift_frameworks.empty? Dir.mktmpdir do | tmpdir | swift_support_path = File.join(tmpdir, "SwiftSupport") - Dir.mkdir(swift_support_path) + xcode_path = `xcode-select --print-path`.strip swift_frameworks.each do | path | filename = File.basename(path) - xcode_path = `xcode-select --print-path` - toolchain_version = "#{xcode_path.strip}/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/#{@sdk}/#{filename}" + toolchain_version = "#{xcode_path}/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/#{@sdk}/#{filename}" FileUtils.cp(toolchain_version, swift_support_path, :verbose => true) end From 8ceb9fb4570c4e4d0e3445e69618fc837118887b Mon Sep 17 00:00:00 2001 From: "Son.Nguyen" Date: Fri, 17 Jul 2015 14:43:34 +1000 Subject: [PATCH 12/13] Insert dsyms into the ipa --- lib/xcode/builder/base_builder.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/xcode/builder/base_builder.rb b/lib/xcode/builder/base_builder.rb index 0beecde..c3912b8 100644 --- a/lib/xcode/builder/base_builder.rb +++ b/lib/xcode/builder/base_builder.rb @@ -154,6 +154,29 @@ def copy_swift_packages end end + # Credits to https://github.com/drewcrawford/cavejohnson for reverse-engineering the process + def prepare_dsym_itunesconnect + Dir.mktmpdir do | tmpdir | + symbol_path = File.join(tmpdir, "Symbols") + Dir.mkdir(symbol_path) + + xcode_path = `xcode-select --print-path`.strip + + appbinary = File.join(app_path, "#{product_name}") + toolchain_symbol_path = File.join(xcode_path, "/usr/bin/symbols") + + system "#{toolchain_symbol_path} -noTextInSOD -noDaemon -arch all -symbolsPackageDir \"#{symbol_path}\" \"#{appbinary}\"" + + zip_cmd = with_command 'zip' do |zip| + zip << "--recurse-paths \"#{ipa_path}\" \"Symbols\"" + end + + Dir.chdir(tmpdir) do + zip_cmd.execute + end + end + end + def prepare_dsym_command # package dSYM with_command 'zip' do |cmd| @@ -277,6 +300,7 @@ def package options = {}, &block with_keychain do prepare_package_command.execute copy_swift_packages + prepare_dsym_itunesconnect end print_task :package, "creating dSYM zip: #{dsym_zip_path}", :info From 9c66a018148959b56d0078ce50d1e1e12c250651 Mon Sep 17 00:00:00 2001 From: Shan Ul Haq Date: Fri, 17 Jul 2015 15:24:40 +1000 Subject: [PATCH 13/13] updated the gem version to 0.1.24 updated the gem version to 0.1.24 after pulling the SwiftSupport and Symbols fix from sonng --- lib/xcode/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/xcode/version.rb b/lib/xcode/version.rb index dbca93e..fc841e2 100644 --- a/lib/xcode/version.rb +++ b/lib/xcode/version.rb @@ -1,3 +1,3 @@ module Xcode - VERSION = "0.1.23" + VERSION = "0.1.24" end