Remove swiftSettings that cause errors when building as a dependency in Xcode#110
Remove swiftSettings that cause errors when building as a dependency in Xcode#110rgoldberg wants to merge 1 commit intorarestype:masterfrom
Conversation
…in Xcode. Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the compatibility of the Swift package by removing problematic Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request removes swiftSettings from Package.swift to resolve build errors when this package is used as a dependency. My review includes a suggestion to conditionally apply these settings. This would preserve the strict checks for local development while still fixing the issue for consumers of the package.
I am having trouble creating individual review comments. Click here to see my feedback.
Package.swift (88-104)
While removing these Swift settings fixes the build errors for consumers of this package, it also removes valuable checks for the development of the package itself. These settings help enforce modern Swift practices and prevent certain types of warnings.
A better approach could be to apply these settings conditionally, so they are used during local development and CI, but not when the package is used as a dependency. This can be achieved using an environment variable.
For example, you could modify your Package.swift like this:
// At the top of Package.swift
import PackageDescription
import Foundation
// Check for a development environment variable
let isDevelopment = ProcessInfo.processInfo.environment["DEVELOPMENT"] != nil
let swiftSettings: [SwiftSetting] = isDevelopment ? [
.enableUpcomingFeature("ExistentialAny"),
.treatWarning("ExistentialAny", as: .error),
.treatWarning("MutableGlobalVariable", as: .error),
] : []
// Then, for each relevant target:
.target(
name: "SomeTarget",
dependencies: [...],
swiftSettings: swiftSettings
),This way, you can run DEVELOPMENT=1 swift build to build with the strict settings, while regular users of your package won't be affected. This would allow you to keep the benefits of these checks without impacting downstream users.
|
superseded by #112 |
Remove swiftSettings that cause errors when building as a dependency in Xcode.
Resolve #108