module Pod class Target # @since 1.5.0 class BuildSettings # missing framework header search paths def missing_framework_header_search_path(pt) return [] unless pt.frame_header_search_paths_enable? paths = [] pt.file_accessors.each do |file_accessor| # xcframeworks greater_than_or_equal_to_1_10_0 = Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0') greater_than_or_equal_to_1_11_0 = Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.11.0') file_accessor.vendored_xcframeworks.map { |path| if greater_than_or_equal_to_1_11_0 Xcode::XCFramework.new(file_accessor.spec.name, path) else Xcode::XCFramework.new(path) end }.each { |xcfwk| xcfwk.slices.each { |slice| fwk_name = slice.path.basename if greater_than_or_equal_to_1_11_0 paths.push "${PODS_XCFRAMEWORKS_BUILD_DIR}/#{xcfwk.target_name}/#{fwk_name}/Headers" elsif greater_than_or_equal_to_1_10_0 paths.push "${PODS_XCFRAMEWORKS_BUILD_DIR}/#{fwk_name.to_s.gsub(/\.framework$/, '')}/#{fwk_name}/Headers" else paths.push "${PODS_CONFIGURATION_BUILD_DIR}/#{fwk_name}/Headers" end } } # Cocoapods 1.9.x bugs if Gem::Version.new(Pod::VERSION) < Gem::Version.new('1.10.0') file_accessor.vendored_xcframeworks.each { |path| Dir.glob("#{path.to_s}/**/*.framework").each do |fwk_path| header_path = Pathname.new("#{fwk_path}/Headers") next unless header_path.exist? paths.push "${PODS_ROOT}/#{header_path.relative_path_from(pt.sandbox.root)}" end } end # frameworks (file_accessor.vendored_frameworks - file_accessor.vendored_xcframeworks).each { |framework| header_path = Pathname.new("#{framework}/Headers") next unless header_path.exist? paths.push "${PODS_ROOT}/#{header_path.relative_path_from(pt.sandbox.root)}" } end replace_xcconfig_configuration_paths(paths) paths.uniq end # replace different configuration xcconfig def replace_xcconfig_configuration_paths(paths) xcconfig_configuration_alias = Jxedt.config.xcconfig_configuration_alias support_configurations = Jxedt.config.support_configurations match_configuration = support_configurations.join('|') paths.map! { |path| if path =~ /#{xcconfig_configuration_alias}-(#{match_configuration})/ configuration = @configuration.to_s.downcase matchs = support_configurations.select {|name| name.downcase == configuration } path.gsub!(/#{xcconfig_configuration_alias}-(#{match_configuration})/, "#{xcconfig_configuration_alias}-#{matchs.first}") if matchs.count == 1 end path } paths end # A subclass that generates build settings for a `PodTarget` class AggregateTargetSettings # @return [Array] alias_method :old_raw_header_search_paths, :_raw_header_search_paths def _raw_header_search_paths header_search_paths = old_raw_header_search_paths header_search_paths.concat pod_targets.flat_map { |pt| missing_framework_header_search_path(pt) } header_search_paths.uniq end end # A subclass that generates build settings for a {PodTarget} class PodTargetSettings # @return [Array] alias_method :old_raw_header_search_paths, :_raw_header_search_paths def _raw_header_search_paths header_search_paths = old_raw_header_search_paths header_search_paths.concat dependent_targets.flat_map { |pt| missing_framework_header_search_path(pt) } if target.should_build? header_search_paths.uniq end # 按照规则替换framework_search_paths,兼容不同的configuration # 从编译上来说,仅仅替换了framework_search_paths的路径就够了 # @return [Array] alias_method :old_raw_framework_search_paths, :_raw_framework_search_paths def _raw_framework_search_paths framework_search_paths = old_raw_framework_search_paths replace_xcconfig_configuration_paths(framework_search_paths) framework_search_paths end end end end end