lib/cocoapods-util/binary/targets/pod_target.rb in cocoapods-util-0.0.16 vs lib/cocoapods-util/binary/targets/pod_target.rb in cocoapods-util-0.2.0

- old
+ new

@@ -2,11 +2,11 @@ class Target # @since 1.5.0 class BuildSettings # missing framework header search paths def missing_framework_header_search_path(pt) - return [] unless BinaryPrebuild.config.enable_targets.include? pt.name + 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') @@ -45,13 +45,31 @@ 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_replace_path = BinaryPrebuild.config.xcconfig_replace_path + paths.map! { |path| + if path =~ /#{xcconfig_replace_path}-(Debug|Release)/ + configuration = @configuration.to_s.downcase + if configuration == 'debug' + path.gsub!(/#{xcconfig_replace_path}-(Debug|Release)/, "#{xcconfig_replace_path}-Debug") + elsif configuration == 'release' + path.gsub!(/#{xcconfig_replace_path}-(Debug|Release)/, "#{xcconfig_replace_path}-Release") + end + end + path + } + paths + end + # A subclass that generates build settings for a `PodTarget` class AggregateTargetSettings # @return [Array<String>] alias_method :old_raw_header_search_paths, :_raw_header_search_paths def _raw_header_search_paths @@ -67,9 +85,19 @@ 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<String>] + 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 \ No newline at end of file