Skip to content

Add more context for validation errors for target properties. #8612

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

Merged
merged 3 commits into from
May 9, 2025

Conversation

yyvch
Copy link
Contributor

@yyvch yyvch commented May 2, 2025

Add more context for validation errors for target properties.

Motivation:

I came across a post https://forums.swift.org/t/getting-error-on-package-resolve/75419 which reports the error message to be not clear. I thought I could clarify the message.

error: 'xerr': target 'Penny' contains a value for disallowed property 'settings'

Modifications:

I've updated the message for the error, so it includes more details to narrow down what is the culprit:

  • highlight that the property depends on the target type
  • show the value of the property, so that there's a hint what line in the Package.swift lead to the error (for example, linkerSettings or cxxSettings)

Result:

Before:

error: 'xerr': target 'Penny' contains a value for disallowed property 'settings'

After:

error: 'xerr': target 'Penny' is assigned a property 'settings' which is not accepted for
the binary target type. The current value of the property has the following representation: 
[PackageModel.TargetBuildSettingDescription.Setting(
tool: PackageModel.TargetBuildSettingDescription.Tool.linker,
kind: PackageModel.TargetBuildSettingDescription.Kind.linkedFramework("AVFoundation"),
condition: nil)].

@yyvch
Copy link
Contributor Author

yyvch commented May 2, 2025

@swift-ci please test

yyvch added 2 commits May 7, 2025 15:40
Target model validation throws two errors specific errors. This commit
adds new tests for previously uncovered code paths.
@yyvch
Copy link
Contributor Author

yyvch commented May 8, 2025

@swift-ci please test

@yyvch yyvch requested a review from bkhouri May 8, 2025 06:43
@bkhouri
Copy link
Contributor

bkhouri commented May 8, 2025

@swift-ci test windows

@bkhouri bkhouri merged commit 9051756 into swiftlang:main May 9, 2025
6 checks passed
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.

3 participants