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
- #add_repair_swift_include_path(xcconfig, repair_swift_include_paths, uses_swift) ⇒ Object
- #kz_add_force_load_tag(xcconfig, kz_pod_target) ⇒ 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
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/cocoapods-kz/native/target_installer_helper.rb', line 76 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 |
#add_repair_swift_include_path(xcconfig, repair_swift_include_paths, uses_swift) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/cocoapods-kz/native/target_installer_helper.rb', line 93 def add_repair_swift_include_path(xcconfig, repair_swift_include_paths, uses_swift) # 只有当前pod支持swift,才需要所依赖的pod提供的swiftmodule if repair_swift_include_paths.count > 0 && uses_swift repair_swift_include_paths.each do |repair_swift_include_path| swift_include_path = ' ' + KZ.deal_path_for_xcconfig(repair_swift_include_path, true) unless xcconfig.attributes['SWIFT_INCLUDE_PATHS'].include?(swift_include_path) xcconfig.attributes['SWIFT_INCLUDE_PATHS'] += swift_include_path end end end end |
#kz_add_force_load_tag(xcconfig, kz_pod_target) ⇒ Object
137 138 139 140 141 142 143 144 |
# File 'lib/cocoapods-kz/native/target_installer_helper.rb', line 137 def kz_add_force_load_tag(xcconfig, kz_pod_target) other_linker_flags = xcconfig.other_linker_flags frameworks_flags = other_linker_flags[:frameworks] force_flags = other_linker_flags[:force_load] frameworks_flags.delete(kz_pod_target.product_basename) force_flags.add(KZ.deal_path_for_xcconfig(kz_pod_target.force_load_info, true)) end |
#kz_clean_xcconfig(xcconfig) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/cocoapods-kz/native/target_installer_helper.rb', line 119 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
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/cocoapods-kz/native/target_installer_helper.rb', line 105 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# 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?) add_repair_swift_include_path(xcconfig, kz_pod_target.all_repair_swift_include_paths, self.target.uses_swift?) if kz_pod_target.force_load kz_add_force_load_tag(xcconfig, kz_pod_target) end end end xcconfig.attributes['HEADER_SEARCH_PATHS'] = main_hamp_search_path xcconfig.attributes['USE_HEADERMAP'] = 'NO' if KZ::KZGlobalHelper.instance.arm64_simulator xcconfig.attributes.delete("EXCLUDED_ARCHS[sdk=iphonesimulator*]") xcconfig.attributes['VALID_ARCHS'] = 'arm64 arm64_32 x86_64' 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 pod_custom_header_search_paths = generator.pod_target_xcconfig_values_by_consumer_by_key["HEADER_SEARCH_PATHS"] pod_custom_header_search_paths = pod_custom_header_search_paths.values if pod_custom_header_search_paths xcconfig = generator.xcconfig xcconfig.attributes['HEADER_SEARCH_PATHS'] = kz_pod_target.header_search_paths(pod_custom_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 if kz_pod_target.force_load xcconfig.attributes['KZ_FIX_FORCE_LOAD_EXE_FOLDER'] = kz_pod_target.configuration_build_dir(true) end if KZ::KZGlobalHelper.instance.arm64_simulator xcconfig.attributes.delete("EXCLUDED_ARCHS[sdk=iphonesimulator*]") xcconfig.attributes['VALID_ARCHS'] = 'arm64 arm64_32 x86_64' end add_repair_modulemap(xcconfig, kz_pod_target.all_repair_modulemap_paths, kz_pod_target.current_uses_swift?) add_repair_swift_include_path(xcconfig, kz_pod_target.all_repair_swift_include_paths, kz_pod_target.current_uses_swift?) kz_update_xcconfig_file(xcconfig, path) return end end origin_update_changed_file(generator, path) end |