Skip to content

Commit c022957

Browse files
committed
fix: resources is missing when using static framework
1 parent e5f55ac commit c022957

File tree

4 files changed

+51
-6
lines changed

4 files changed

+51
-6
lines changed

lib/cocoapods-binary/Integration.rb

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def install_for_prebuild!(standard_sanbox)
2424

2525
# make a symlink to target folder
2626
prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sanbox)
27-
folder = prebuild_sandbox.framework_folder_path_for_pod_name(self.name)
27+
real_file_folder = prebuild_sandbox.framework_folder_path_for_pod_name(self.name)
2828

2929
target_folder = standard_sanbox.pod_dir(self.name)
3030
target_folder.rmtree if target_folder.exist?
@@ -39,26 +39,41 @@ def walk(path, &action)
3939
end
4040
end
4141
end
42-
def make_link(source, basefolder, target_folder)
43-
target = target_folder + source.relative_path_from(basefolder)
42+
def make_link(source, target)
43+
source = Pathname.new(source)
44+
target = Pathname.new(target)
4445
target.parent.mkpath unless target.parent.exist?
4546
relative_source = source.relative_path_from(target.parent)
4647
FileUtils.ln_sf(relative_source, target)
4748
end
49+
def mirror_with_symlink(source, basefolder, target_folder)
50+
target = target_folder + source.relative_path_from(basefolder)
51+
make_link(source, target)
52+
end
4853

49-
walk(folder) do |child|
54+
# symbol link copy all substructure
55+
walk(real_file_folder) do |child|
5056
source = child
5157
# only make symlink to file and `.framework` folder
5258
if child.directory? and child.extname == ".framework"
53-
make_link(source, folder, target_folder)
59+
mirror_with_symlink(source, real_file_folder, target_folder)
5460
next false # return false means don't go deeper
5561
elsif child.file?
56-
make_link(source, folder, target_folder)
62+
mirror_with_symlink(source, real_file_folder, target_folder)
5763
next true
5864
else
5965
next true
6066
end
6167
end
68+
69+
# symbol link copy resource for static framework
70+
hash = Prebuild::Passer.resources_to_copy_for_static_framework
71+
path_objects = hash[self.name]
72+
if path_objects != nil
73+
path_objects.each do |object|
74+
make_link(object.real_file_path, object.target_file_path)
75+
end
76+
end
6277
end
6378

6479
end

lib/cocoapods-binary/Prebuild.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,24 @@ def prebuild_frameworks!
128128
Pod::Prebuild.remove_build_dir(sandbox_path)
129129
targets.each do |target|
130130
next unless target.should_build?
131+
131132
output_path = sandbox.framework_folder_path_for_pod_name(target.name)
132133
output_path.mkpath unless output_path.exist?
133134
Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled)
135+
136+
# save the resource paths for later installing
137+
if target.static_framework? and !target.resource_paths.empty?
138+
framework_path = output_path + target.framework_name
139+
standard_sandbox_path = sandbox.standard_sanbox_path
140+
path_objects = target.resource_paths.select{|f| f.start_with? "${PODS_ROOT}"}.map do |path|
141+
object = Prebuild::Passer::ResourcePath.new
142+
object.real_file_path = framework_path + File.basename(path)
143+
object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s)
144+
object
145+
end
146+
Prebuild::Passer.resources_to_copy_for_static_framework ||= {}
147+
Prebuild::Passer.resources_to_copy_for_static_framework[target.name] = path_objects
148+
end
134149
end
135150
Pod::Prebuild.remove_build_dir(sandbox_path)
136151

lib/cocoapods-binary/helper/passer.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ class Passer
1515
#
1616
class_attr_accessor :prebuild_pods_changes
1717

18+
19+
# represent the path of resurces to copy
20+
class ResourcePath
21+
attr_accessor :real_file_path
22+
attr_accessor :target_file_path
23+
end
24+
# Save the resoures for static framework, and used when installing the prebuild framework
25+
# static framework needs copy the resurces mannully
26+
#
27+
# @return [Hash<String, [Passer::ResourcePath]>]
28+
class_attr_accessor :resources_to_copy_for_static_framework
1829
end
1930
end
2031
end

lib/cocoapods-binary/helper/prebuild_sandbox.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ def self.from_standard_sanbox_path(path)
1010
def self.from_standard_sandbox(sandbox)
1111
self.from_standard_sanbox_path(sandbox.root)
1212
end
13+
14+
def standard_sanbox_path
15+
self.root.parent
16+
end
1317

1418
def generate_framework_path
1519
self.root + "GeneratedFrameworks"

0 commit comments

Comments
 (0)