Skip to content

Support folder-based .xcconfig references in XCConfigIntegrator #12811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,43 +28,53 @@ def self.integrate(pod_bundle, targets)
# @!group Integration steps
#-------------------------------------------------------------------#

# Creates a file reference to the xcconfig generated by
# CocoaPods (if needed) and sets it as the base configuration of
# build configuration of the user target.
# Integrates the user target by creating or updating the base
# configuration reference to point at the CocoaPods-generated xcconfig,
# while preserving any existing custom xcconfig (including folder-based
# references via anchor + relative path).
#
# @param [Target::AggregateTarget] pod_bundle
# The Pods bundle.
# The Pods aggregate target, providing sandbox and xcconfig paths.
#
# @param [PBXNativeTarget] target
# The native target.
# The native Xcode target to configure.
#
# @param [Xcodeproj::XCBuildConfiguration] config
# The build configuration.
#
# The build configuration on which to set the base configuration.
def self.set_target_xcconfig(pod_bundle, target, config)
file_ref = create_xcconfig_ref(pod_bundle, config)
path = file_ref.path
path = file_ref.path

existing = config.base_configuration_reference
if config.base_configuration_reference
existing_path = config.base_configuration_reference.real_path
elsif config.base_configuration_reference_anchor && config.base_configuration_reference_relative_path
existing_path = Pathname.new(
File.join(
config.base_configuration_reference_anchor.path,
config.base_configuration_reference_relative_path
)
)
end

if existing && existing != file_ref
if existing.real_path.to_path.start_with?(pod_bundle.sandbox.root.to_path << '/')
if existing_path
if existing_path.to_path.start_with?(pod_bundle.sandbox.root.to_path + '/')
config.base_configuration_reference = file_ref
elsif !xcconfig_includes_target_xcconfig?(config.base_configuration_reference, path)
unless existing_config_is_identical_to_pod_config?(existing.real_path, pod_bundle.xcconfig_path(config.name))
UI.warn 'CocoaPods did not set the base configuration of your ' \
'project because your project already has a custom ' \
'config set. In order for CocoaPods integration to work at ' \
'all, please either set the base configurations of the target ' \
"`#{target.name}` to `#{path}` or include the `#{path}` in your " \
"build configuration (#{UI.path(existing.real_path)})."
end
return
end
elsif config.base_configuration_reference.nil? || file_ref.nil?

unless xcconfig_includes_target_xcconfig?(existing_path, path) ||
existing_config_is_identical_to_pod_config?(existing_path, pod_bundle.xcconfig_path(config.name))
UI.warn "Detected a custom base configuration for target `#{target.name}` " \
"(#{UI.path(existing_path)}). CocoaPods will not override it automatically. " \
"To integrate CocoaPods, either set this target’s base configuration to `#{path}` " \
"or include `#{path}` in your existing build configuration."
end
else
config.base_configuration_reference = file_ref
end
end


private

# @!group Private helpers
Expand Down