Class: Pod::PodTarget

Inherits:
Target
  • Object
show all
Defined in:
lib/cocoapods-jxedt/binary/targets/pod_target.rb

Instance Attribute Summary

Attributes inherited from Target

#use_binary

Instance Method Summary collapse

Methods inherited from Target

#explicit_header_search_pod_names, #frame_header_search_paths_enable?, #reject_header_search_pod_names

Instance Method Details

#old_resource_pathsObject



3
# File 'lib/cocoapods-jxedt/binary/targets/pod_target.rb', line 3

alias_method :old_resource_paths, :resource_paths

#resource_pathsObject



4
5
6
7
8
9
10
11
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
# File 'lib/cocoapods-jxedt/binary/targets/pod_target.rb', line 4

def resource_paths
    resource_paths = old_resource_paths
    # 没有使用二进制不处理
    return resource_paths unless self.use_binary

    # 遍历所有的resources
    resource_paths.each do |name, resources|
        resources.map! {|resource_file|
            resource_extname = Pathname.new(resource_file).basename.extname
            # 如果文件不需要编译,跳过
            next resource_file unless self.class.resource_extension_compilable?(resource_extname)
            
            # 确定编译后的文件名称
            output_extname = self.class.output_extension_for_resource(resource_extname)
            output_file_name = "#{Pathname.new(resource_file).basename.sub_ext('')}#{output_extname}"
            # 从framework中查找编译后的文件
            file_accessors.each do |file_accessor|
                file_accessor.vendored_frameworks.each do |framework_file|
                    framework_name = Pathname.new(framework_file).basename.sub_ext('').to_s
                    # 只处理和当前target module_name相同的framework,否则跳过
                    next if self.product_module_name != framework_name
                    
                    # xcframework和framework文件分别处理,而且只查找.framework根目录下的文件
                    if '.xcframework' == Pathname.new(framework_file).basename.extname
                        files = Dir.glob("#{framework_file}/**/#{framework_name}.framework/#{output_file_name}")
                        next if files.size == 0 # 没有查找到文件跳过

                        if Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
                            resource_file = "${PODS_XCFRAMEWORKS_BUILD_DIR}/#{self.name}/#{framework_name}.framework/#{output_file_name}"
                        else
                            resource_file = "${PODS_CONFIGURATION_BUILD_DIR}/#{framework_name}.framework/#{output_file_name}"
                        end
                    else
                        files = Dir.glob("#{framework_file}/#{output_file_name}")
                        next if files.size == 0 # 没有查找到文件跳过

                        resource_path = Pathname.new("#{framework_file}/#{output_file_name}") # 真实路径
                        resource_file = "${PODS_ROOT}/#{resource_path.relative_path_from(self.sandbox.root)}"
                    end
                end
            end
            resource_file
        }.reject!(&:nil?)
    end
    resource_paths
end