Skip to content

Commit

Permalink
showBuildSettings does not require to call clean on Xcode >= 8.3 (#8921)
Browse files Browse the repository at this point in the history
  • Loading branch information
punty authored and hjanuschka committed Apr 21, 2017
1 parent a37b025 commit 18322ef
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
7 changes: 7 additions & 0 deletions fastlane_core/lib/fastlane_core/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ def self.keychain_path(name)
keychain_path
end

# @return true if XCode version is higher than 8.3
def self.xcode_at_least?(version)
FastlaneCore::UI.user_error!("Unable to locate Xcode. Please make sure to have Xcode installed on your machine") if xcode_version.nil?
v = xcode_version
Gem::Version.new(v) >= Gem::Version.new(version)
end

# @return the full path to the iTMSTransporter executable
def self.itms_path
return ENV["FASTLANE_ITUNES_TRANSPORTER_PATH"] if FastlaneCore::Env.truthy?("FASTLANE_ITUNES_TRANSPORTER_PATH")
Expand Down
9 changes: 7 additions & 2 deletions fastlane_core/lib/fastlane_core/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,14 @@ def xcodebuild_parameters
def build_xcodebuild_showbuildsettings_command
# We also need to pass the workspace and scheme to this command.
#
# The 'clean' portion of this command is a workaround for an xcodebuild bug with Core Data projects.
# The 'clean' portion of this command was a workaround for an xcodebuild bug with Core Data projects.
# This xcodebuild bug is fixed in Xcode 8.3 so 'clean' it's not necessary anymore
# See: https://github.com/fastlane/fastlane/pull/5626
command = "xcodebuild clean -showBuildSettings #{xcodebuild_parameters.join(' ')}"
if FastlaneCore::Helper.xcode_at_least?('8.3')
command = "xcodebuild -showBuildSettings #{xcodebuild_parameters.join(' ')}"
else
command = "xcodebuild clean -showBuildSettings #{xcodebuild_parameters.join(' ')}"
end
command += " 2> /dev/null" if xcodebuild_suppress_stderr
command
end
Expand Down
15 changes: 13 additions & 2 deletions fastlane_core/spec/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,21 @@ def within_a_temp_dir
end

describe "build_settings() can handle empty lines" do
it "SUPPORTED_PLATFORMS should be iphonesimulator iphoneos" do
it "SUPPORTED_PLATFORMS should be iphonesimulator iphoneos on Xcode >= 8.3" do
options = { project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj" }
@project = FastlaneCore::Project.new(options, xcodebuild_list_silent: true, xcodebuild_suppress_stderr: true)
expect(FastlaneCore::Project).to receive(:run_command).with("xcodebuild clean -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj 2> /dev/null", { timeout: 10, retries: 3, print: false }).and_return(File.read("./fastlane_core/spec/fixtures/projects/build_settings_with_toolchains"))
expect(FastlaneCore::Helper).to receive(:xcode_at_least?).and_return(true)
command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj 2> /dev/null"
expect(FastlaneCore::Project).to receive(:run_command).with(command.to_s, { timeout: 10, retries: 3, print: false }).and_return(File.read("./fastlane_core/spec/fixtures/projects/build_settings_with_toolchains"))
expect(@project.build_settings(key: "SUPPORTED_PLATFORMS")).to eq("iphonesimulator iphoneos")
end

it "SUPPORTED_PLATFORMS should be iphonesimulator iphoneos on Xcode < 8.3" do
options = { project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj" }
@project = FastlaneCore::Project.new(options, xcodebuild_list_silent: true, xcodebuild_suppress_stderr: true)
expect(FastlaneCore::Helper).to receive(:xcode_at_least?).and_return(false)
command = "xcodebuild clean -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj 2> /dev/null"
expect(FastlaneCore::Project).to receive(:run_command).with(command.to_s, { timeout: 10, retries: 3, print: false }).and_return(File.read("./fastlane_core/spec/fixtures/projects/build_settings_with_toolchains"))
expect(@project.build_settings(key: "SUPPORTED_PLATFORMS")).to eq("iphonesimulator iphoneos")
end
end
Expand Down
4 changes: 1 addition & 3 deletions gym/lib/gym/xcode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ def pre_7?
end

def legacy_api_deprecated?
UI.user_error!("Unable to locate Xcode. Please make sure to have Xcode installed on your machine") if xcode_version.nil?
v = xcode_version
Gem::Version.new(v) >= Gem::Version.new('8.3.0')
FastlaneCore::Helper.xcode_at_least?('8.3')
end
end
end
Expand Down

0 comments on commit 18322ef

Please sign in to comment.