Skip to content

Add a warning for TARGET_OS_* compilation conditions #2810

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
Aug 20, 2024
Merged

Conversation

j-f1
Copy link
Contributor

@j-f1 j-f1 commented Aug 19, 2024

This helps people avoid silent mistakes when migrating from Objective-C:

#if TARGET_OS_IOS
//  ^ warning: 'TARGET_OS_*' preprocessor macros are not available in Swift; use 'os(iOS)' instead
//  ^ fix-it: replace with 'os(iOS)'
print("I will never be executed, even on iOS!")
#endif

@j-f1 j-f1 requested a review from DougGregor August 19, 2024 16:47
@j-f1 j-f1 requested review from ahoppen and bnbarham as code owners August 19, 2024 16:47
@j-f1
Copy link
Contributor Author

j-f1 commented Aug 19, 2024

@swift-ci please test

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@ahoppen ahoppen enabled auto-merge August 19, 2024 22:54
@ahoppen
Copy link
Member

ahoppen commented Aug 20, 2024

Could you run swift-format on the changes? https://github.com/swiftlang/swift-syntax/blob/main/CONTRIBUTING.md#formatting

@j-f1
Copy link
Contributor Author

j-f1 commented Aug 20, 2024

@swift-ci please test

@ahoppen
Copy link
Member

ahoppen commented Aug 20, 2024

@swift-ci Please test Windows

@ahoppen ahoppen merged commit 5de21b3 into main Aug 20, 2024
3 checks passed
@ahoppen ahoppen deleted the jed/target-os branch August 20, 2024 18:58
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.

2 participants