Skip to content

Refactor: Modernize platform-specific configurations in Package.swift #1000

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

Conversation

SyedaAnshrahGillani
Copy link

Description
This pull request refactors the Package.swift file to modernize platform-specific configuration handling and improve code clarity.


What’s Changed

  • Replaced all legacy #if os(...) preprocessor directives with the modern .when(platforms: [...]) syntax.
  • Consolidated platform-specific linker settings for system libraries (e.g., ncurses, sqlite3, etc.) into a unified, cleaner format.

Why It Matters

  • Improved Readability: The .when(platforms: [...]) approach is more declarative and concise, reducing clutter from scattered #if blocks.
  • Enhanced Maintainability: Centralizing platform-specific configurations simplifies future updates for OS support and reduces the chance of inconsistencies.
  • Best Practices Compliance: Aligns with modern Swift Package Manager recommendations, promoting cleaner and more idiomatic build manifest files.

Note
This is a non-functional update. It does not change runtime behavior but significantly improves the internal structure and maintainability of the build configuration.

#else
return [.linkedLibrary("ncurses", .when(platforms: [.linux, .macOS]))]
#endif
return [.linkedLibrary("ncurses", .when(platforms: [.linux, .macOS, .freeBSD, .openBSD]))]
Copy link
Contributor

Choose a reason for hiding this comment

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

The FreeBSD platform condition isn't supported in tools-version:5.3, so this needs to continue using preprocessor conditionals as a workaround

Copy link
Contributor

Choose a reason for hiding this comment

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

More specifically, "custom" isn't supported until 5.6 either.

@@ -277,47 +273,6 @@ if !isStaticBuild {
]
}

if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this section deleted?

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