Module: Pod::Installer::Xcode::PodsProjectGenerator::TargetInstallerHelper

Included in:
AppHostInstaller, TargetInstaller
Defined in:
lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb

Class Method Summary collapse

Class Method Details

.create_info_plist_file_with_sandbox(sandbox, path, native_target, version, platform, bundle_package_type = :fmwk, additional_entries: {}, build_setting_value: nil) ⇒ void

This method returns an undefined value.

Creates the Info.plist file which sets public framework attributes

@param [Hash] additional_entries
       any additional entries to include in this Info.plist file.


58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb', line 58

def create_info_plist_file_with_sandbox(sandbox, path, native_target, version, platform,
                                        bundle_package_type = :fmwk, additional_entries: {},
                                        build_setting_value: nil)
  UI.message "- Generating Info.plist file at #{UI.path(path)}" do
    generator = Generator::InfoPlistFile.new(version, platform, bundle_package_type, additional_entries)
    update_changed_file(generator, path)

    build_setting_value ||= path.relative_path_from(sandbox.root).to_s
    native_target.build_configurations.each do |c|
      c.build_settings['INFOPLIST_FILE'] = build_setting_value
    end
  end
end

.create_prefix_header(path, file_accessors, platform, native_target, project_directory) ⇒ void

This method returns an undefined value.

Creates a prefix header file which imports ‘UIKit` or `Cocoa` according to the platform of the target. This file also include any prefix header content reported by the specification of the pods.



93
94
95
96
97
98
99
100
101
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb', line 93

def create_prefix_header(path, file_accessors, platform, native_target, project_directory)
  generator = Generator::PrefixHeader.new(file_accessors, platform)
  update_changed_file(generator, path)

  relative_path = path.relative_path_from(project_directory).to_s
  native_target.build_configurations.each do |c|
    c.build_settings['GCC_PREFIX_HEADER'] = relative_path
  end
end

.update_changed_file(generator, path) ⇒ Object

Saves the content the provided path unless the path exists and the contents are exactly the same.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb', line 14

def update_changed_file(generator, path)
  if path.exist?
    contents = generator.generate.to_s
    content_stream = StringIO.new(contents)
    identical = File.open(path, 'rb') { |f| FileUtils.compare_stream(f, content_stream) }
    return if identical

    File.open(path, 'w') { |f| f.write(contents) }
  else
    path.dirname.mkpath
    generator.save_as(path)
  end
end