@@ -26,7 +26,19 @@ def alter_specs_for_prebuilt_pods
26
26
27
27
private
28
28
29
+ def metadata_of_target ( name )
30
+ @metadata_by_target ||= { }
31
+ metadata = @metadata_by_target [ name ]
32
+ return metadata unless metadata . nil?
33
+
34
+ framework_path = sandbox . prebuild_sandbox . framework_folder_path_for_target_name ( name )
35
+ metadata = PodPrebuild ::Metadata . in_dir ( framework_path )
36
+ @metadata_by_target [ name ] = metadata
37
+ metadata
38
+ end
39
+
29
40
def alter_spec ( spec , alterations , cache )
41
+ metadata = metadata_of_target ( spec . root . name )
30
42
targets = Pod . fast_get_targets_for_pod_name ( spec . root . name , pod_targets , cache )
31
43
platforms = targets . map { |target | target . platform . name . to_s } . uniq
32
44
@@ -43,11 +55,31 @@ def alter_spec(spec, alterations, cache)
43
55
end
44
56
45
57
empty_source_files ( spec , platforms ) if alterations [ :source_files ]
46
- tweak_resources_for_xib ( spec , platforms ) if alterations [ :resources ]
47
- tweak_resources_for_resource_bundles ( spec , platforms ) if alterations [ :resources ]
58
+ if alterations [ :resources ]
59
+ if metadata . static_framework?
60
+ tweak_resources_for_xib ( spec , platforms )
61
+ tweak_resources_for_resource_bundles ( spec , platforms )
62
+ else
63
+ # For dynamic frameworks, resources & resource bundles are already bundled inside the framework.
64
+ # We need to empty resources & resource bundles. Otherwise, there will be duplications
65
+ # (resources locating in both app bundle and framework bundle)
66
+ empty_resources ( spec , platforms )
67
+ end
68
+ end
48
69
empty_liscence ( spec ) if alterations [ :license ]
49
70
end
50
71
72
+ def empty_resources ( spec , platforms )
73
+ spec . attributes_hash [ "resources" ] = nil
74
+ spec . attributes_hash [ "resource_bundles" ] = nil
75
+ platforms . each do |platform |
76
+ next if spec . attributes_hash [ platform ] . nil?
77
+
78
+ spec . attributes_hash [ platform ] [ "resources" ] = nil
79
+ spec . attributes_hash [ platform ] [ "resource_bundles" ] = nil
80
+ end
81
+ end
82
+
51
83
def tweak_resources_for_xib ( spec , platforms )
52
84
# This is a workaround for prebuilt static framework that has `*.xib` files in the resources
53
85
# (declared by `spec.resources = ...`)
0 commit comments