>
new_target
new_resources_bundle
add_system_framework
configuration_list
common_build_settings
new_target(project, type, name, platform, deployment_target, product_group) #=> PBXNativeTarget 
Project  project
The project to which the target should be added.
Symbol  type
The type of target. Can be :application, :dynamic_library or
:static_library.
String  name
The name of the static library product.
Symbol  platform
The platform of the static library. Can be :ios or :osx.
String  deployment_target
The deployment target for the platform.
PBXNativeTarget The target.
38 def self.new_target(project, type, name, platform, deployment_target, product_group)
39 
40   # Target
41   target = project.new(PBXNativeTarget)
42   project.targets << target
43   target.name = name
44   target.product_name = name
45   target.product_type = Constants::PRODUCT_TYPE_UTI[type]
46   target.build_configuration_list = configuration_list(project, platform, deployment_target)
47 
48   # Product
49   product = product_group.new_static_library(name)
50   target.product_reference = product
51 
52   # Frameworks
53   framework_name = (platform == :ios) ? 'Foundation' : 'Cocoa'
54   framework_ref = project.add_system_framework(framework_name, target)
55 
56   # Build phases
57   target.build_phases << project.new(PBXSourcesBuildPhase)
58   frameworks_phase = project.new(PBXFrameworksBuildPhase)
59   frameworks_phase.add_file_reference(framework_ref)
60   target.build_phases << frameworks_phase
61 
62   target
63 end
new_resources_bundle(project, name, platform, product_group) #=> PBXNativeTarget 
Project  project
The project to which the target should be added.
String  name
The name of the resources bundle.
Symbol  platform
The platform of the resources bundle. Can be :ios or :osx.
PBXNativeTarget The target.
 83 def self.new_resources_bundle(project, name, platform, product_group)
 84   # Target
 85   target = project.new(PBXNativeTarget)
 86   project.targets << target
 87   target.name = name
 88   target.product_name = name
 89   target.product_type = Constants::PRODUCT_TYPE_UTI[:bundle]
 90 
 91   # Configuration List
 92   build_settings = {
 93     'PRODUCT_NAME' => '$(TARGET_NAME)',
 94     'WRAPPER_EXTENSION' => 'bundle',
 95     'SKIP_INSTALL' => 'YES'
 96   }
 97 
 98   if platform == :osx
 99     build_settings['COMBINE_HIDPI_IMAGES'] = 'YES'
100     build_settings['SDKROOT'] = 'macosx'
101   else
102     build_settings['SDKROOT'] = 'iphoneos'
103   end
104 
105   cl = project.new(XCConfigurationList)
106   cl.default_configuration_is_visible = '0'
107   cl.default_configuration_name = 'Release'
108   release_conf = project.new(XCBuildConfiguration)
109   release_conf.name = 'Release'
110   release_conf.build_settings = build_settings
111   debug_conf = project.new(XCBuildConfiguration)
112   debug_conf.name = 'Debug'
113   debug_conf.build_settings = build_settings
114   cl.build_configurations << release_conf
115   cl.build_configurations << debug_conf
116   cl
117   target.build_configuration_list = cl
118 
119   # Product
120   product = product_group.new_bundle(name)
121   target.product_reference = product
122 
123   # Build phases
124   target.build_phases << project.new(PBXSourcesBuildPhase)
125   target.build_phases << project.new(PBXFrameworksBuildPhase)
126   target.build_phases << project.new(PBXResourcesBuildPhase)
127 
128   target
129 end
add_system_framework(project, name, target) #=> PBXFileReference 
Project  project
The project to which the configuration list should be added.
String  name
The name of a framework.
PBXNativeTarget  target
The target for which to add the framework.
PBXFileReference The generated file reference.
154 def self.add_system_framework(project, name, target)
155   sdk = target.sdk
156   raise "Unable to find and SDK for the target `#{target.name}`" unless sdk
157   if sdk.include?('iphoneos')
158     if sdk == 'iphoneos'
159       version = XcodebuildHelper.instance.last_ios_sdk || Constants::LAST_KNOWN_IOS_SDK
160       base_dir = "Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS#{version}.sdk/"
161     else
162       base_dir = "Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS#{sdk.gsub('iphoneos', '')}.sdk/"
163     end
164   elsif sdk.include?('macosx')
165     if sdk == 'macosx'
166       version = XcodebuildHelper.instance.last_osx_sdk || Constants::LAST_KNOWN_OSX_SDK
167       base_dir = "Platforms/MacOSX.platform/Developer/SDKs/MacOSX#{version}.sdk/"
168     else
169       base_dir = "Platforms/MacOSX.platform/Developer/SDKs/MacOSX#{sdk.gsub('macosx', '')}.sdk/"
170     end
171   end
172 
173   path = base_dir + "System/Library/Frameworks/#{name}.framework"
174   if ref = project.frameworks_group.files.find { |f| f.path == path }
175     ref
176   else
177     ref = project.frameworks_group.new_file(path)
178     ref.source_tree = 'DEVELOPER_DIR'
179     ref
180   end
181 end
configuration_list(project, platform, deployment_target = nil) #=> XCConfigurationList 
Project  project
The project to which the configuration list should be added.
Symbol  platform
The platform for the configuration list, can be :ios or :osx.
String  deployment_target
The deployment target for the platform.
XCConfigurationList The generated configuration list.
201 def self.configuration_list(project, platform, deployment_target = nil)
202   cl = project.new(XCConfigurationList)
203   cl.default_configuration_is_visible = '0'
204   cl.default_configuration_name = 'Release'
205 
206   release_conf = project.new(XCBuildConfiguration)
207   release_conf.name = 'Release'
208   release_conf.build_settings = common_build_settings(:release, platform, deployment_target)
209 
210   debug_conf = project.new(XCBuildConfiguration)
211   debug_conf.name = 'Debug'
212   debug_conf.build_settings = common_build_settings(:debug, platform, deployment_target)
213 
214   cl.build_configurations << release_conf
215   cl.build_configurations << debug_conf
216   cl
217 end
common_build_settings(type, platform, deployment_target = nil) #=> Hash 
Symbol  type
The type of the build configuration, can be :release or
:debug.
Symbol  platform
The platform for the build settings, can be :ios or :osx.
String  deployment_target
The deployment target for the platform.
Hash The common build settings
234 def self.common_build_settings(type, platform, deployment_target = nil)
235   common_settings = Constants::COMMON_BUILD_SETTINGS
236   settings = common_settings[:all].dup
237   settings.merge!(common_settings[type])
238   settings.merge!(common_settings[platform])
239   settings.merge!(common_settings[[platform, type]])
240   if deployment_target
241     if platform == :ios
242       settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
243     elsif platform == :osx
244       settings['MACOSX_DEPLOYMENT_TARGET'] = deployment_target
245     end
246   end
247   settings
248 end