Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add add_legacy_target method to ProjectHelper #491

Merged
merged 1 commit into from
Jun 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

##### Enhancements

* Add add_legacy_target method to ProjectHelper
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#491](https://github.com/CocoaPods/Xcodeproj/pull/491)

* Use `test_target_type?` when adding testable reference
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#487](https://github.com/CocoaPods/Xcodeproj/pull/487)
Expand Down
37 changes: 37 additions & 0 deletions lib/xcodeproj/project/project_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,43 @@ def self.new_aggregate_target(project, name)
target
end

# Creates a new legacy target and adds it to the project.
#
# The target is configured for the given platform.
#
# @param [Project] project
# the project to which the target should be added.
#
# @param [String] name
# the name of the aggregate target.
#
# @param [String] build_tool_path
# the build tool path to use for this target.
#
# @param [String] build_arguments_string
# the build arguments string to use for this target.
#
# @param [String] build_working_directory
# the build working directory to use for this target.
#
# @param [String] pass_build_settings_in_environment
# whether to pass build settings in the environment during execution of this target.
#
# @return [PBXLegacyTarget] the target.
#
def self.new_legacy_target(project, name, build_tool_path = '/usr/bin/make', build_arguments_string = '$(ACTION)',
build_working_directory = nil, pass_build_settings_in_environment = '1')
target = project.new(PBXLegacyTarget)
project.targets << target
target.name = name
target.build_configuration_list = configuration_list(project)
target.build_tool_path = build_tool_path
target.build_arguments_string = build_arguments_string
target.build_working_directory = build_working_directory
target.pass_build_settings_in_environment = pass_build_settings_in_environment
target
end

# @!group Private Helpers

#-----------------------------------------------------------------------#
Expand Down
17 changes: 17 additions & 0 deletions spec/project/project_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,23 @@ module ProjectSpecs

target.build_phases.count.should == 0
end

it 'creates a new legacy target' do
target = @helper.new_legacy_target(@project, 'Pods')
target.name.should == 'Pods'
target.build_tool_path.should == '/usr/bin/make'
target.build_arguments_string.should == '$(ACTION)'
target.build_working_directory.should.be.nil
target.pass_build_settings_in_environment.should == '1'

target.build_configuration_list.should.not.be.nil
configurations = target.build_configuration_list.build_configurations
configurations.map(&:name).sort.should == %w(Debug Release)

@project.targets.should.include target

target.build_phases.count.should == 0
end
end

#-------------------------------------------------------------------------#
Expand Down