Skip to content

Commit

Permalink
Addressing PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Furtak committed Apr 22, 2016
1 parent 05a08dd commit 0e5fe4f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions gym/lib/gym/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def run
FileUtils.mkdir_p(Gym.config[:output_directory])

if Gym.project.ios? || Gym.project.tvos?
fix_archive
fix_generic_archive # See https://github.com/fastlane/fastlane/pull/4325
package_app
fix_package
compress_and_move_dsym
Expand Down Expand Up @@ -73,7 +73,7 @@ def clear_old_files
end
end

def fix_archive
def fix_generic_archive
return if ENV["GYM_USE_GENERIC_ARCHIVE_FIX"].nil?
Gym::XcodebuildFixes.generic_archive_fix
end
Expand Down
7 changes: 4 additions & 3 deletions gym/lib/gym/xcodebuild_fixes/generic_archive_fix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ def generic_archive_fix
UI.verbose "Looking For Orphaned WatchKit2 Applications"

Dir.glob("#{BuildCommandGenerator.archive_path}/Products/Applications/*.app").each do |app_path|
if is_watchkit_ipa?("#{app_path}/Info.plist")
if is_watchkit_app?(app_path)
UI.verbose "Removing Orphaned WatchKit2 Application #{app_path}"
FileUtils.rm_rf(app_path)
end
end
end

# Does this application have a WatchKit target
def is_watchkit_ipa?(plist_path)
`/usr/libexec/PlistBuddy -c 'Print DTSDKName' #{plist_path.shellescape} 2>&1`.match(/^\s*watchos2\.\d+\s*$/) != nil
def is_watchkit_app?(app_path)
plist_path = "#{app_path}/Info.plist"
`/usr/libexec/PlistBuddy -c 'Print :DTSDKName' #{plist_path.shellescape} 2>&1`.match(/^\s*watchos2\.\d+\s*$/) != nil
end
end
end
Expand Down
Binary file not shown.
Binary file modified gym/spec/fixtures/xcodebuild_fixes/ios_app.app/Info.plist
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DTSDKName</key>
<string>watchos2.1</string>
</dict>
</plist>
10 changes: 4 additions & 6 deletions gym/spec/xcodebuild_fixes/generic_archive_fix_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
require 'gym/xcodebuild_fixes/generic_archive_fix'

describe Gym do
describe Gym::XcodebuildFixes do
let (:watch_ipa) { 'spec/fixtures/xcodebuild_fixes/ios watch_app.app/Info.plist' }
let (:ios_ipa) { 'spec/fixtures/xcodebuild_fixes/ios_app.app/Info.plist' }
let (:watch_app) { 'spec/fixtures/xcodebuild_fixes/ios_watch_app.app' }
let (:ios_app) { 'spec/fixtures/xcodebuild_fixes/ios_app.app' }

it "can detect watch application" do
expect(Gym::XcodebuildFixes.is_watchkit_ipa?(watch_ipa)).to eq(true)
expect(Gym::XcodebuildFixes.is_watchkit_app?(watch_app)).to eq(true)
end

it "doesn't detect iOS application" do
expect(Gym::XcodebuildFixes.is_watchkit_ipa?(ios_ipa)).to eq(false)
expect(Gym::XcodebuildFixes.is_watchkit_app?(ios_app)).to eq(false)
end
end
end

0 comments on commit 0e5fe4f

Please sign in to comment.