Skip to content

Emit warnings when conflicts detected in Info.plist key values #369

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 3 commits into
base: main
Choose a base branch
from

Conversation

theSalted
Copy link

When a building setting is set from an info.plist key, if the same key is set from another source. The previous one will be silently overwritten. This pull request added detectConflict() to detects if two PropertyListItem values are in conflict and emits an appropriate warning message if they are.

Note

#5 and #364 was accidentally closed, after a bot used to automatically sync fork matches my fork to main. This pr re-introduce those changes along with a test case.

Resolves #5

@theSalted
Copy link
Author

@owenv I have re-opened #364 and added a test-case. Thanks for your patience.

@owenv
Copy link
Collaborator

owenv commented Apr 1, 2025

@swift-ci test

@owenv
Copy link
Collaborator

owenv commented Apr 1, 2025

It looks like one of the existing tests might have exposed an issue here:

✘ Test diagnostics() recorded an issue at InfoPlistProcessorTaskTests.swift:157:13: Expectation failed: (outputDelegate.messages → ["warning: Type conflict for Info.plist key \'Integer\': integer from Info.plist will be replaced with array from additional content file \'/tmp/bad.plist\'", "error: tried to merge array value for key \'Integer\' onto integer value"]) == (errors.map { "error: \($0)" } → ["error: tried to merge array value for key \'Integer\' onto integer value"])
± inserted ["warning: Type conflict for Info.plist key \'Integer\': integer from Info.plist will be replaced with array from additional content file \'/tmp/bad.plist\'"]
↳ outputDelegate.messages: Swift.Array<Swift.String> → ["warning: Type conflict for Info.plist key \'Integer\': integer from Info.plist will be replaced with array from additional content file \'/tmp/bad.plist\'", "error: tried to merge array value for key \'Integer\' onto integer value"]
↳ errors.map { "error: \($0)" }: Swift.Array<Swift.String> → ["error: tried to merge array value for key \'Integer\' onto integer value"]
✘ Test diagnostics() recorded an issue at InfoPlistProcessorTaskTests.swift:157:13: Expectation failed: (outputDelegate.messages → ["warning: Type conflict for Info.plist key \'Array\': array from Info.plist will be replaced with string from additional content file \'/tmp/bad.plist\'", "error: tried to merge string value for key \'Array\' onto array value"]) == (errors.map { "error: \($0)" } → ["error: tried to merge string value for key \'Array\' onto array value"])
± inserted ["warning: Type conflict for Info.plist key \'Array\': array from Info.plist will be replaced with string from additional content file \'/tmp/bad.plist\'"]

from https://ci.swift.org/job/pr-swift-build-macos/554/

@theSalted
Copy link
Author

✘ Test diagnostics() recorded an issue at InfoPlistProcessorTaskTests.swift:157:13: Expectation failed: (outputDelegate.messages → ["warning: Type conflict for Info.plist key 'Integer': integer from Info.plist will be replaced with array from additional content file '/tmp/bad.plist'", "error: tried to merge array value for key 'Integer' onto integer value"]) == (errors.map { "error: ($0)" } → ["error: tried to merge array value for key 'Integer' onto integer value"])
± inserted ["warning: Type conflict for Info.plist key 'Integer': integer from Info.plist will be replaced with array from additional content file '/tmp/bad.plist'"]
↳ outputDelegate.messages: Swift.Array<Swift.String> → ["warning: Type conflict for Info.plist key 'Integer': integer from Info.plist will be replaced with array from additional content file '/tmp/bad.plist'", "error: tried to merge array value for key 'Integer' onto integer value"]
↳ errors.map { "error: ($0)" }: Swift.Array<Swift.String> → ["error: tried to merge array value for key 'Integer' onto integer value"]
✘ Test diagnostics() recorded an issue at InfoPlistProcessorTaskTests.swift:157:13: Expectation failed: (outputDelegate.messages → ["warning: Type conflict for Info.plist key 'Array': array from Info.plist will be replaced with string from additional content file '/tmp/bad.plist'", "error: tried to merge string value for key 'Array' onto array value"]) == (errors.map { "error: ($0)" } → ["error: tried to merge string value for key 'Array' onto array value"])
± inserted ["warning: Type conflict for Info.plist key 'Array': array from Info.plist will be replaced with string from additional content file '/tmp/bad.plist'"]

Thanks, it seems like diagnostics was expecting only error messages, but my implementation is adding warning messages about type conflicts in addition to the existing error messages. This is fixed now.

@owenv
Copy link
Collaborator

owenv commented Apr 1, 2025

@swift-ci test

@owenv
Copy link
Collaborator

owenv commented Apr 1, 2025

@swift-ci test macOS

@owenv
Copy link
Collaborator

owenv commented Apr 1, 2025

@swift-ci test linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emit warnings when Info.plist key values from different user-supplied sources conflict
2 participants