Module: Pod::Installer::Xcode::PodsProjectGenerator::TargetInstallerHelper
- Defined in:
- lib/cocoapods-kz/native/target_installer_helper.rb
Instance Method Summary collapse
- #add_repair_modulemap(xcconfig, repair_modulemap_paths, uses_swift = false) ⇒ Object
- #check_default_xcode_version_for_ld64 ⇒ Object
- #kz_clean_xcconfig(xcconfig) ⇒ Object
- #kz_update_xcconfig_file(xcconfig, path) ⇒ Object
- #origin_update_changed_file ⇒ Object
- #update_changed_file(generator, path) ⇒ Object
Instance Method Details
#add_repair_modulemap(xcconfig, repair_modulemap_paths, uses_swift = false) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/cocoapods-kz/native/target_installer_helper.rb', line 61 def add_repair_modulemap(xcconfig, repair_modulemap_paths, uses_swift = false) if repair_modulemap_paths.count > 0 repair_modulemap_paths.each do |repair_modulemap_path| fmodule_map = ' -fmodule-map-file=' + KZ.deal_path_for_xcconfig(repair_modulemap_path, true) unless xcconfig.attributes['OTHER_CFLAGS'].include?(fmodule_map) xcconfig.attributes['OTHER_CFLAGS'] += fmodule_map end if uses_swift xfmodule_map = ' -Xcc -fmodule-map-file=' + KZ.deal_path_for_xcconfig(repair_modulemap_path, true) unless xcconfig.attributes['OTHER_SWIFT_FLAGS'].include?(xfmodule_map) xcconfig.attributes['OTHER_SWIFT_FLAGS'] += xfmodule_map end end end end end |
#check_default_xcode_version_for_ld64 ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/cocoapods-kz/native/target_installer_helper.rb', line 110 def check_default_xcode_version_for_ld64 default_xcode_path = Pathname.new('/Applications/Xcode.app') return false unless default_xcode_path.exist? xcode_info_plist = default_xcode_path + 'Contents/Info.plist' _xcode_info_plist = KZ::KZ_POD_CONFIG_ROOT + 'Xcode_Info.plist' FileUtils.cp(xcode_info_plist, _xcode_info_plist) system "plutil -convert xml1 #{_xcode_info_plist.to_s} #{_xcode_info_plist.to_s}" plist_hash = Xcodeproj::Plist.read_from_path(_xcode_info_plist) FileUtils.rm(_xcode_info_plist) plist_hash['CFBundleShortVersionString'] == '15.0' end |
#kz_clean_xcconfig(xcconfig) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/cocoapods-kz/native/target_installer_helper.rb', line 92 def kz_clean_xcconfig(xcconfig) other_cflags = xcconfig.attributes['OTHER_CFLAGS'] flags = other_cflags.split(' ') new_flags = [] appear_delete_tag = false flags.each do |flag| if flag.include?('isystem') || flag.include?('iframework') appear_delete_tag = true else unless appear_delete_tag || new_flags.include?(flag) new_flags << flag end appear_delete_tag = false end end xcconfig.attributes['OTHER_CFLAGS'] = new_flags.join(' ') end |
#kz_update_xcconfig_file(xcconfig, path) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/cocoapods-kz/native/target_installer_helper.rb', line 78 def kz_update_xcconfig_file(xcconfig, path) if path.exist? contents = xcconfig.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 xcconfig.save_as(path) end end |
#origin_update_changed_file ⇒ Object
11 |
# File 'lib/cocoapods-kz/native/target_installer_helper.rb', line 11 alias_method :origin_update_changed_file, :update_changed_file |
#update_changed_file(generator, path) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/cocoapods-kz/native/target_installer_helper.rb', line 12 def update_changed_file(generator, path) unless KZ::KZGlobalHelper.instance.kz_pod_enable origin_update_changed_file(generator, path) return end if generator.is_a?(Pod::Target::BuildSettings::AggregateTargetSettings) unless self.target.application_extension_api_only xcconfig = generator.xcconfig kz_clean_xcconfig(xcconfig) main_hamp_search_path = '"' + KZ::KZ_POD_CONFIG_ROOT_STR + "/#{self.target.user_project.root_object.display_name}.hmap" + '"' pod_targets = self.target.pod_targets_for_build_configuration(generator.configuration_name) pod_targets.each do |native_pod_target| kz_pod_target = native_pod_target.weakRef_kz_pod_target if kz_pod_target if kz_pod_target.repair_header_search_path main_hamp_search_path += (' ' + KZ.deal_path_for_xcconfig(kz_pod_target.repair_header_search_path, true)) end add_repair_modulemap(xcconfig, kz_pod_target.all_repair_modulemap_paths, self.target.uses_swift?) end end xcconfig.attributes['HEADER_SEARCH_PATHS'] = main_hamp_search_path xcconfig.attributes['USE_HEADERMAP'] = 'NO' if generator.configuration_name == 'Debug' && check_default_xcode_version_for_ld64 other_linker_flags = xcconfig.other_linker_flags[:simple] other_linker_flags << '-ld64' end kz_update_xcconfig_file(xcconfig, path) return end elsif generator.is_a?(Pod::Target::BuildSettings::PodTargetSettings) kz_pod_target = self.target.weakRef_kz_pod_target if kz_pod_target xcconfig = generator.xcconfig xcconfig.attributes['HEADER_SEARCH_PATHS'] = kz_pod_target.header_search_paths xcconfig.attributes['USE_HEADERMAP'] = 'NO' framework_cache_path = KZ.deal_path_for_xcconfig(kz_pod_target.pod_config_cache_path(true)) xcconfig.attributes['KZ_FRAMEWORK_CACHE_PATH'] = framework_cache_path xcconfig.attributes['KZ_MERGE_SWIFT_H_PATH'] = KZ::KZGlobalHelper.instance.kz_merge_swift_h_path add_repair_modulemap(xcconfig, kz_pod_target.all_repair_modulemap_paths, kz_pod_target.uses_swift?) kz_update_xcconfig_file(xcconfig, path) return end end origin_update_changed_file(generator, path) end |