@@ -17,64 +17,28 @@ def install_for_prebuild!(standard_sanbox)
1717 # TODO (bang): Unify to 1 sandbox to optimize and avoid inconsistency
1818 prebuild_sandbox = Pod ::PrebuildSandbox . from_standard_sandbox ( standard_sanbox )
1919 # if spec used in multiple platforms, it may return multiple paths
20- target_names = prebuild_sandbox . existed_target_names_for_pod_name ( self . name )
21-
22- def walk ( path , &action )
23- return unless path . exist?
24- path . children . each do |child |
25- result = action . call ( child , &action )
26- if child . directory?
27- walk ( child , &action ) if result
28- end
29- end
30- end
31-
32- def make_link ( source , target )
33- source = Pathname . new ( source )
34- target = Pathname . new ( target )
35- target . parent . mkpath unless target . parent . exist?
36- relative_source = source . relative_path_from ( target . parent )
37- FileUtils . ln_sf ( relative_source , target )
38- end
39-
40- def mirror_with_symlink ( source , basefolder , target_folder )
41- target = target_folder + source . relative_path_from ( basefolder )
42- make_link ( source , target )
43- end
44-
20+ target_names = prebuild_sandbox . existed_target_names_for_pod_name ( name )
4521 target_names . each do |name |
46-
47- # symbol link copy all substructure
4822 real_file_folder = prebuild_sandbox . framework_folder_path_for_target_name ( name )
4923
5024 # If have only one platform, just place int the root folder of this pod.
5125 # If have multiple paths, we use a sperated folder to store different
5226 # platform frameworks. e.g. AFNetworking/AFNetworking-iOS/AFNetworking.framework
53-
5427 target_folder = standard_sanbox . pod_dir ( self . name )
55- if target_names . count > 1
56- target_folder += real_file_folder . basename
57- end
58-
59- if !standard_sanbox . local? ( name )
60- target_folder . rmtree if target_folder . exist?
61- target_folder . mkpath
62- else
63- system "find #{ target_folder } -type l -delete" # Only clean up symlink, keep source code for local pod
64- end
28+ target_folder += real_file_folder . basename if target_names . count > 1
29+ target_folder += PodPrebuild ::Config . instance . prebuilt_path
30+ target_folder . rmtree if target_folder . exist?
31+ target_folder . mkpath
6532
6633 walk ( real_file_folder ) do |child |
6734 source = child
6835 # only make symlink to file and `.framework` folder
69- if child . directory? and [ ".framework" , ".dSYM" ] . include? child . extname
70- if child . extname == ".framework"
71- mirror_with_symlink ( source , real_file_folder , target_folder )
72- else
73- # Ignore dsym here to avoid cocoapods from adding install_dsym to buildphase-script
74- # That can cause duplicated output files error in Xcode 11 (warning in Xcode 10)
75- # We need more setup to support local debuging with prebuilt dSYM
76- end
77- next false # return false means don't go deeper
36+ if child . directory? && [ ".framework" , ".dSYM" ] . include? ( child . extname )
37+ mirror_with_symlink ( source , real_file_folder , target_folder ) if child . extname == ".framework"
38+ # Ignore dsym here to avoid cocoapods from adding install_dsym to buildphase-script
39+ # That can cause duplicated output files error in Xcode 11 (warning in Xcode 10)
40+ # We need more setup to support local debuging with prebuilt dSYM
41+ next false # Don't go deeper
7842 elsif child . file?
7943 mirror_with_symlink ( source , real_file_folder , target_folder )
8044 next true
@@ -88,8 +52,9 @@ def mirror_with_symlink(source, basefolder, target_folder)
8852 next unless metadata . static_framework?
8953
9054 metadata . resources . each do |path |
91- target_file_path = path . sub ( "${PODS_ROOT}" , sandbox . root . to_path )
92- . sub ( "${PODS_CONFIGURATION_BUILD_DIR}" , sandbox . root . to_path )
55+ target_file_path = path
56+ . sub ( "${PODS_ROOT}" , sandbox . root . to_path )
57+ . sub ( "${PODS_CONFIGURATION_BUILD_DIR}" , sandbox . root . to_path )
9358 real_file_path = real_file_folder + metadata . framework_name + File . basename ( path )
9459 case File . extname ( path )
9560 when ".xib"
@@ -107,6 +72,31 @@ def mirror_with_symlink(source, basefolder, target_folder)
10772 end
10873 end
10974 end
75+
76+ private
77+
78+ def walk ( path , &action )
79+ return unless path . exist?
80+
81+ path . children . each do |child |
82+ result = action . call ( child , &action )
83+ if child . directory?
84+ walk ( child , &action ) if result
85+ end
86+ end
87+ end
88+
89+ def make_link ( source , target )
90+ source = Pathname . new ( source )
91+ target = Pathname . new ( target )
92+ target . parent . mkpath unless target . parent . exist?
93+ relative_source = source . relative_path_from ( target . parent )
94+ FileUtils . ln_sf ( relative_source , target )
95+ end
96+
97+ def mirror_with_symlink ( source , basefolder , target_folder )
98+ make_link ( source , target_folder + source . relative_path_from ( basefolder ) )
99+ end
110100 end
111101 end
112102end
0 commit comments