Skip to content

Commit

Permalink
Centralize deployment target
Browse files Browse the repository at this point in the history
- Set the deployment target at the project level instead of at the
  target level. This mimics the behavior of Xcode.
- Configure the deployment target with ProjectConfiguration.
- Use the deployment target information to populate values inside
  templates.
  • Loading branch information
gfontenot committed Mar 20, 2014
1 parent 9109e49 commit 25fcc00
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
13 changes: 8 additions & 5 deletions lib/liftoff/project.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module Liftoff
class Project
def initialize(name, company, prefix)
@name = name
set_company_name(company)
set_prefix(prefix)
def initialize(configuration)
@name = configuration.project_name
@deployment_target = configuration.deployment_target
set_company_name(configuration.company)
set_prefix(configuration.prefix)
configure_base_project_settings
end

Expand Down Expand Up @@ -35,9 +36,10 @@ def reorder_groups
end

def new_app_target
target = xcode_project.new_target(:application, @name, :ios, 7.0)
target = xcode_project.new_target(:application, @name, :ios)
target.build_configurations.each do |configuration|
configuration.build_settings.delete('OTHER_LDFLAGS')
configuration.build_settings.delete('IPHONEOS_DEPLOYMENT_TARGET')
end
target
end
Expand Down Expand Up @@ -70,6 +72,7 @@ def configure_base_project_settings
configuration.build_settings['ASSETCATALOG_COMPILER_APPICON_NAME'] = 'AppIcon'
configuration.build_settings['ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME'] = 'LaunchImage'
configuration.build_settings['SDKROOT'] = 'iphoneos'
configuration.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = @deployment_target
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/liftoff/project_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def groups_and_targets
end

def xcode_project
@xcode_project ||= Project.new(@project_configuration.project_name, @project_configuration.company, @project_configuration.prefix)
@xcode_project ||= Project.new(@project_configuration)
end

def file_manager
Expand Down
6 changes: 6 additions & 0 deletions lib/liftoff/project_configuration.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Liftoff
class ProjectConfiguration
LATEST_IOS = 7.0

attr_accessor :project_name, :company, :prefix, :configure_git, :warnings_as_errors, :install_todo_script, :enable_static_analyzer, :indentation_level, :warnings, :application_target_groups, :unit_test_target_groups, :use_cocoapods
attr_writer :author, :company_identifier

Expand All @@ -22,6 +24,10 @@ def company_identifier
@company_identifier || "com.#{normalized_company_name}"
end

def deployment_target
LATEST_IOS
end

def get_binding
binding
end
Expand Down
4 changes: 2 additions & 2 deletions templates/<%= project_name %>-Prefix.pch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import <Availability.h>

#ifndef __IPHONE_7_0
#warning "This project uses features only available in iOS SDK 7.0 and later."
#ifndef __IPHONE_<%= deployment_target.to_s.gsub('.', '_') %>
#warning "This project uses features only available in iOS SDK <%= deployment_target %> and later."
#endif

#ifdef __OBJC__
Expand Down
2 changes: 1 addition & 1 deletion templates/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
platform :ios, '7.0'
platform :ios, '<%= deployment_target %>'

target :unit_tests, :exclusive => true do
link_with 'UnitTests'
Expand Down

0 comments on commit 25fcc00

Please sign in to comment.