Class: Pod::Installer::Xcode::PodsProjectGenerator::TargetInstaller
- Inherits:
-
Object
- Object
- Pod::Installer::Xcode::PodsProjectGenerator::TargetInstaller
- Includes:
- TargetInstallerHelper
- Defined in:
- lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb
Overview
Controller class responsible of creating and configuring the static library target in Pods project. It also creates the support file needed by the target.
Direct Known Subclasses
Private helpers. collapse
-
#support_files_group ⇒ PBXGroup
readonly
private
The group where the file references to the support files should be stored.
Instance Attribute Summary collapse
-
#project ⇒ Pod::Project
readonly
The project to install the target into.
-
#sandbox ⇒ Sandbox
readonly
Sandbox The sandbox where the support files should be generated.
-
#target ⇒ Target
readonly
Target The library whose target needs to be generated.
Installation steps collapse
-
#add_target ⇒ PBXNativeTarget
private
Adds the target for the library to the Pods project with the appropriate build configurations.
-
#clean_support_files_temp_dir ⇒ Object
private
Remove temp file whose store .prefix/config/dummy file.
-
#create_dummy_source(native_target) ⇒ void
private
Generates a dummy source file for each target so libraries that contain only categories build.
-
#create_info_plist_file(path, native_target, version, platform, bundle_package_type = :fmwk, additional_entries: {}) ⇒ void
private
Creates the Info.plist file which sets public framework attributes.
-
#create_module_map(native_target) ⇒ void
private
Creates the module map file which ensures that the umbrella header is recognized with a customized path.
-
#create_support_files_dir ⇒ Object
private
Creates the directory where to store the support files of the target.
-
#create_umbrella_header(native_target) ⇒ void
private
Generates a header which ensures that all header files are exported in the module map.
-
#custom_build_settings ⇒ Hash{String => String}
private
Returns the customized build settings which are overridden in the build settings of the user target.
-
#deployment_target ⇒ String
private
The deployment target.
-
#support_files_temp_dir ⇒ String
private
The temp file path to store temporary files.
Private helpers. collapse
-
#add_file_to_support_group(path) ⇒ PBXFileReference
private
Adds a reference to the given file in the support group of this target.
Instance Method Summary collapse
-
#initialize(sandbox, project, target) ⇒ TargetInstaller
constructor
Initialize a new instance.
Methods included from TargetInstallerHelper
create_info_plist_file_with_sandbox, #create_info_plist_file_with_sandbox, #create_prefix_header, create_prefix_header, update_changed_file, #update_changed_file
Constructor Details
#initialize(sandbox, project, target) ⇒ TargetInstaller
Initialize a new instance
35 36 37 38 39 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 35 def initialize(sandbox, project, target) @sandbox = sandbox @project = project @target = target end |
Instance Attribute Details
#project ⇒ Pod::Project (readonly)
Returns The project to install the target into.
22 23 24 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 22 def project @project end |
#sandbox ⇒ Sandbox (readonly)
Returns sandbox The sandbox where the support files should be generated.
17 18 19 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 17 def sandbox @sandbox end |
#support_files_group ⇒ PBXGroup (readonly, private)
Returns the group where the file references to the support files should be stored.
242 243 244 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 242 def support_files_group @support_files_group end |
#target ⇒ Target (readonly)
Returns target The library whose target needs to be generated.
27 28 29 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 27 def target @target end |
Instance Method Details
#add_file_to_support_group(path) ⇒ PBXFileReference (private)
Adds a reference to the given file in the support group of this target.
251 252 253 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 251 def add_file_to_support_group(path) support_files_group.new_file(path) end |
#add_target ⇒ PBXNativeTarget (private)
The PODS_HEADERS_SEARCH_PATHS
overrides the xcconfig.
Adds the target for the library to the Pods project with the appropriate build configurations.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 54 def add_target product_type = target.product_type name = target.label platform = target.platform.name language = target.uses_swift? ? :swift : :objc native_target = project.new_target(product_type, name, platform, deployment_target, nil, language) product_name = target.product_name product = native_target.product_reference product.name = product_name target.user_build_configurations.each do |bc_name, type| native_target.add_build_configuration(bc_name, type) end native_target.build_configurations.each do |configuration| configuration.build_settings.merge!(custom_build_settings) end native_target end |
#clean_support_files_temp_dir ⇒ Object (private)
Remove temp file whose store .prefix/config/dummy file.
111 112 113 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 111 def clean_support_files_temp_dir support_files_temp_dir.rmtree if support_files_temp_dir.exist? end |
#create_dummy_source(native_target) ⇒ void (private)
This method returns an undefined value.
Generates a dummy source file for each target so libraries that contain only categories build.
223 224 225 226 227 228 229 230 231 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 223 def create_dummy_source(native_target) path = target.dummy_source_path UI. "- Generating dummy source at #{UI.path(path)}" do generator = Generator::DummySource.new(target.label) update_changed_file(generator, path) file_reference = add_file_to_support_group(path) native_target.source_build_phase.add_file_reference(file_reference) end end |
#create_info_plist_file(path, native_target, version, platform, bundle_package_type = :fmwk, additional_entries: {}) ⇒ void (private)
This method returns an undefined value.
Creates the Info.plist file which sets public framework attributes
143 144 145 146 147 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 143 def create_info_plist_file(path, native_target, version, platform, bundle_package_type = :fmwk, additional_entries: {}) create_info_plist_file_with_sandbox(@sandbox, path, native_target, version, platform, bundle_package_type, :additional_entries => additional_entries) add_file_to_support_group(path) end |
#create_module_map(native_target) ⇒ void (private)
This method returns an undefined value.
Creates the module map file which ensures that the umbrella header is recognized with a customized path
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 157 def create_module_map(native_target) path = target.module_map_path_to_write UI. "- Generating module map file at #{UI.path(path)}" do generator = Generator::ModuleMap.new(target) yield generator if block_given? update_changed_file(generator, path) add_file_to_support_group(path) linked_path = target.module_map_path if path != linked_path linked_path.dirname.mkpath source = path.relative_path_from(linked_path.dirname) FileUtils.ln_sf(source, linked_path) end relative_path_string = target.module_map_path.relative_path_from(sandbox.root).to_s native_target.build_configurations.each do |c| c.build_settings['MODULEMAP_FILE'] = relative_path_string end end end |
#create_support_files_dir ⇒ Object (private)
Creates the directory where to store the support files of the target.
105 106 107 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 105 def create_support_files_dir target.support_files_dir.mkpath end |
#create_umbrella_header(native_target) ⇒ void (private)
This method returns an undefined value.
Generates a header which ensures that all header files are exported in the module map
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 190 def create_umbrella_header(native_target) path = target.umbrella_header_path_to_write UI. "- Generating umbrella header at #{UI.path(path)}" do generator = Generator::UmbrellaHeader.new(target) yield generator if block_given? update_changed_file(generator, path) # Add the file to the support group and the native target, # so it will been added to the header build phase file_ref = add_file_to_support_group(path) build_file = native_target.headers_build_phase.add_file_reference(file_ref) linked_path = target.umbrella_header_path if path != linked_path linked_path.dirname.mkpath source = path.relative_path_from(linked_path.dirname) FileUtils.ln_sf(source, linked_path) end acl = target.build_as_framework? ? 'Public' : 'Project' build_file.settings ||= {} build_file.settings['ATTRIBUTES'] = [acl] end end |
#custom_build_settings ⇒ Hash{String => String} (private)
Returns the customized build settings which are overridden in the build settings of the user target.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 87 def custom_build_settings settings = {} unless target.archs.empty? settings['ARCHS'] = target.archs end if target.build_as_static_framework? settings['MACH_O_TYPE'] = 'staticlib' elsif target.build_as_static_library? settings.merge!('OTHER_LDFLAGS' => '', 'OTHER_LIBTOOLFLAGS' => '') end settings end |
#deployment_target ⇒ String (private)
Returns The deployment target.
78 79 80 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 78 def deployment_target target.platform.deployment_target.to_s end |
#support_files_temp_dir ⇒ String (private)
Returns The temp file path to store temporary files.
117 118 119 |
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb', line 117 def support_files_temp_dir sandbox.target_support_files_dir('generated_files_tmp') end |