Skip to content

Commit 671ebdd

Browse files
committed
fix resource_bundle bugs when static framework
fix leavez#29
1 parent 5962d88 commit 671ebdd

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/cocoapods-binary/Integration.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,19 @@ def remove_target_files_if_needed
167167
spec.attributes_hash["vendored_frameworks"] = original_vendored_frameworks
168168
spec.attributes_hash["source_files"] = []
169169

170+
# to remove the resurce bundle target.
171+
# When specify the "resource_bundles" in podspec, xcode will generate a bundle
172+
# target after pod install. But the bundle have already built when the prebuit
173+
# phase and saved in the framework folder. We will treat it as a normal resource
174+
# file.
175+
# https://github.com/leavez/cocoapods-binary/issues/29
176+
if spec.attributes_hash["resource_bundles"]
177+
bundle_names = spec.attributes_hash["resource_bundles"].keys
178+
spec.attributes_hash["resource_bundles"] = nil
179+
spec.attributes_hash["resources"] ||= []
180+
spec.attributes_hash["resources"] += bundle_names.map{|n| n+".bundle"}
181+
end
182+
170183
# to avoid the warning of missing license
171184
spec.attributes_hash["license"] = {}
172185
end

lib/cocoapods-binary/Prebuild.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@ def prebuild_frameworks!
126126
if target.static_framework? and !target.resource_paths.empty?
127127
framework_path = output_path + target.framework_name
128128
standard_sandbox_path = sandbox.standard_sanbox_path
129-
path_objects = target.resource_paths.select{|f| f.start_with? "${PODS_ROOT}"}.map do |path|
129+
path_objects = target.resource_paths.map do |path|
130130
object = Prebuild::Passer::ResourcePath.new
131131
object.real_file_path = framework_path + File.basename(path)
132-
object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s)
132+
object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s) if path.start_with? '${PODS_ROOT}'
133+
object.target_file_path = path.gsub("${PODS_CONFIGURATION_BUILD_DIR}", standard_sandbox_path.to_s) if path.start_with? "${PODS_CONFIGURATION_BUILD_DIR}"
133134
object
134135
end
135136
Prebuild::Passer.resources_to_copy_for_static_framework[target.name] = path_objects

0 commit comments

Comments
 (0)