-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
base: master
Are you sure you want to change the base?
Support folder-based .xcconfig references in XCConfigIntegrator #12811
Conversation
Wow. I just ran into this today. |
@zrajnai-shapr3d |
My fix is very similar: def self.set_target_xcconfig(pod_bundle, target, config)
file_ref = create_xcconfig_ref(pod_bundle, config)
path = file_ref.path
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_path && existing_path != file_ref.real_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?(existing_path, path)
unless existing_config_is_identical_to_pod_config?(existing_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_path)})."
end
end
elsif config.base_configuration_reference.nil? || file_ref.nil?
config.base_configuration_reference = file_ref
end
end I also had to change |
The code looks clean. I think it would be better to use UI.warn as a single statement. I'll take this into account and make the changes accordingly. However, I still find it challenging to properly handle the path for xcconfig, especially when calculating the relative path. |
8a98a88
to
00a18ca
Compare
00a18ca
to
667c201
Compare
@segiddins |
@orta |
Merge, please? |
Hi @javierjosefernandes , Thanks for your patience! |
Support folder-based .xcconfig references in XCConfigIntegrator
Problem
When an Xcode project uses a folder reference (blue folder) for its
.xcconfig
files, CocoaPods’XCConfigIntegrator
only checks thebaseConfigurationReference
and ignores thebase_configuration_reference_anchor
andbase_configuration_reference_relative_path
. As a result, runningpod install
will overwrite the user’s custom.xcconfig
file withPods-*.xcconfig
, breaking custom build configurations.Related Properties
base_configuration_reference_anchor
:PBXFileSystemSynchronizedRootGroup
, representing a special attribute for folder references.XCConfigIntegrator
.base_configuration_reference_relative_path
:String
, representing the relative path of the.xcconfig
file within the folder reference.Solution
We updated the
set_target_xcconfig
method inXCConfigIntegrator
to properly handle folder-based.xcconfig
files.Improvements
Handling folder-based
.xcconfig
files:base_configuration_reference_anchor
andbase_configuration_reference_relative_path
to handle folder-based configuration files.Improved warning messages:
UI.warn
to include folder reference and relative path information, making the issue clearer.Benefits
.xcconfig
through folder references can retain their custom configurations..xcconfig
behavior remains unaffected.Known Issue
Currently, the
#{path}
displayed inUI.warn
does not accurately represent the intended relative path. Calculating the relative path correctly for display purposes remains a challenge, requiring further improvements.Testing
.xcconfig
setups.pod install
preserves the correct base configuration in all scenarios.References
#12806