class Xcodeproj::Project::Object::PBXNativeTarget
def self.new_static_library(project, platform, name)
def self.new_static_library(project, platform, name) project.add_system_framework(platform == :ios ? 'Foundation' : 'Cocoa') target = new(project, nil, 'productType' => STATIC_LIBRARY, 'productName' => name) target.product.path = "lib#{name}.a" target.build_configurations.each do |config| config.build_settings.merge!(XCBuildConfiguration::COMMON_BUILD_SETTINGS[platform]) # E.g. [:ios, :release] extra_settings_key = [platform, config.name.downcase.to_sym] if extra_settings = XCBuildConfiguration::COMMON_BUILD_SETTINGS[extra_settings_key] config.build_settings.merge!(extra_settings) end end target end
def add_source_files(source_file_descriptions)
-
(Array-)
Parameters:
-
source_file_descriptions(Array) -- The
Other tags:
- Note: -
def add_source_files(source_file_descriptions) # Cache the files for performance. files = @project.files.to_a new_files = [] source_file_descriptions.each do |source_file_description| path = source_file_description.path copy_header_phase = source_file_description.copy_header_phase compiler_flags = source_file_description.compiler_flags file = (files + new_files).find { |file| file.path == path.to_s } || @project.files.new('path' => path.to_s) build_file = file.build_files.new if path.extname == '.h' build_file.settings = { 'ATTRIBUTES' => ["Public"] } # Working around a bug in Xcode 4.2 betas, remove this once the Xcode bug is fixed: # https://github.com/alloy/cocoapods/issues/13 #phase = copy_header_phase || headers_build_phases.first phase = copy_header_phase || copy_files_build_phases.first phase.build_files << build_file else build_file.settings = { 'COMPILER_FLAGS' => compiler_flags } if compiler_flags && !compiler_flags.empty? source_build_phases.first.build_files << build_file end new_files << file end new_files end
def build_configurations
def build_configurations build_configuration_list.build_configurations end
def build_settings(build_configuration_name)
def build_settings(build_configuration_name) build_configuration_list.build_settings(build_configuration_name) end
def copy_files_build_phases
def copy_files_build_phases build_phases.list_by_class(PBXCopyFilesBuildPhase) end
def frameworks_build_phases
def frameworks_build_phases build_phases.list_by_class(PBXFrameworksBuildPhase) end
def initialize(project, *)
You need to specify a product. For a static library you can use
def initialize(project, *) super self.name ||= product_name self.build_rule_references ||= [] self.dependency_references ||= [] unless build_phase_references self.build_phase_references = [] source_build_phases.new copy_files_build_phases.new #shell_script_build_phases.new phase = frameworks_build_phases.new if frameworks_group = @project.groups.where(:name => 'Frameworks') frameworks_group.files.each { |framework| phase << framework } end end unless build_configuration_list self.build_configuration_list = project.objects.add(XCConfigurationList, { 'defaultConfigurationIsVisible' => '0', 'defaultConfigurationName' => 'Release', }) # TODO or should this happen in buildConfigurationList? build_configuration_list.build_configurations.new_debug build_configuration_list.build_configurations.new_release end unless product self.product = @project.files.new_static_library(product_name) end end
def product=(product)
def product=(product) self._product = product @project.products << product end
def shell_script_build_phases
def shell_script_build_phases build_phases.list_by_class(PBXShellScriptBuildPhase) end
def source_build_phases
def source_build_phases build_phases.list_by_class(PBXSourcesBuildPhase) end