Skip to content

Commit 667c201

Browse files
author
Jaehyun Park
committed
Support folder-based xcconfig references in CocoaPods integration
1 parent 8a39907 commit 667c201

File tree

1 file changed

+31
-21
lines changed

1 file changed

+31
-21
lines changed

lib/cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,43 +28,53 @@ def self.integrate(pod_bundle, targets)
2828
# @!group Integration steps
2929
#-------------------------------------------------------------------#
3030

31-
# Creates a file reference to the xcconfig generated by
32-
# CocoaPods (if needed) and sets it as the base configuration of
33-
# build configuration of the user target.
31+
# Integrates the user target by creating or updating the base
32+
# configuration reference to point at the CocoaPods-generated xcconfig,
33+
# while preserving any existing custom xcconfig (including folder-based
34+
# references via anchor + relative path).
3435
#
3536
# @param [Target::AggregateTarget] pod_bundle
36-
# The Pods bundle.
37+
# The Pods aggregate target, providing sandbox and xcconfig paths.
3738
#
3839
# @param [PBXNativeTarget] target
39-
# The native target.
40+
# The native Xcode target to configure.
4041
#
4142
# @param [Xcodeproj::XCBuildConfiguration] config
42-
# The build configuration.
43-
#
43+
# The build configuration on which to set the base configuration.
4444
def self.set_target_xcconfig(pod_bundle, target, config)
4545
file_ref = create_xcconfig_ref(pod_bundle, config)
46-
path = file_ref.path
46+
path = file_ref.path
4747

48-
existing = config.base_configuration_reference
48+
if config.base_configuration_reference
49+
existing_path = config.base_configuration_reference.real_path
50+
elsif config.base_configuration_reference_anchor && config.base_configuration_reference_relative_path
51+
existing_path = Pathname.new(
52+
File.join(
53+
config.base_configuration_reference_anchor.path,
54+
config.base_configuration_reference_relative_path
55+
)
56+
)
57+
end
4958

50-
if existing && existing != file_ref
51-
if existing.real_path.to_path.start_with?(pod_bundle.sandbox.root.to_path << '/')
59+
if existing_path
60+
if existing_path.to_path.start_with?(pod_bundle.sandbox.root.to_path + '/')
5261
config.base_configuration_reference = file_ref
53-
elsif !xcconfig_includes_target_xcconfig?(config.base_configuration_reference, path)
54-
unless existing_config_is_identical_to_pod_config?(existing.real_path, pod_bundle.xcconfig_path(config.name))
55-
UI.warn 'CocoaPods did not set the base configuration of your ' \
56-
'project because your project already has a custom ' \
57-
'config set. In order for CocoaPods integration to work at ' \
58-
'all, please either set the base configurations of the target ' \
59-
"`#{target.name}` to `#{path}` or include the `#{path}` in your " \
60-
"build configuration (#{UI.path(existing.real_path)})."
61-
end
62+
return
6263
end
63-
elsif config.base_configuration_reference.nil? || file_ref.nil?
64+
65+
unless xcconfig_includes_target_xcconfig?(existing_path, path) ||
66+
existing_config_is_identical_to_pod_config?(existing_path, pod_bundle.xcconfig_path(config.name))
67+
UI.warn "Detected a custom base configuration for target `#{target.name}` " \
68+
"(#{UI.path(existing_path)}). CocoaPods will not override it automatically. " \
69+
"To integrate CocoaPods, either set this target’s base configuration to `#{path}` " \
70+
"or include `#{path}` in your existing build configuration."
71+
end
72+
else
6473
config.base_configuration_reference = file_ref
6574
end
6675
end
6776

77+
6878
private
6979

7080
# @!group Private helpers

0 commit comments

Comments
 (0)