-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Enable Xcode 16 plugin to use versioned release build #109
Conversation
// Distributed under the MIT License | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops. this header should always have been here
5b45ac0
to
c2dd6c5
Compare
Diagnostics.error(""" | ||
\(context.safediFolder.path()) exists, but there is no SafeDITool binary for this release present. | ||
|
||
To download the current release SafeDITool binary, run: | ||
\tswift package --package-path \(context.package.directoryURL.path()) --allow-network-connections all --allow-writing-to-package-directory safedi-release-install | ||
|
||
To use a debug SafeDITool binary instead, remove the `.safedi` directory by running: | ||
\trm -rf \(context.safediFolder.path()) | ||
""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a .safedi/
directory at the package root, I'm taking that to mean that the user intended to be using a release version of SafeDITool
. Users will likely enter this state after installing SafeDITool
, then bumping the SafeDI
version they are using.
Diagnostics.warning(""" | ||
Using a debug SafeDITool binary, which is 15x slower than a release SafeDITool binary. | ||
|
||
To download the current release SafeDITool binary, run: | ||
\tswift package --package-path \(context.package.directoryURL.path()) --allow-network-connections all --allow-writing-to-package-directory safedi-release-install | ||
""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
switch safeDIOrigin { | ||
case let .repository(url, displayVersion, _): | ||
// As of Xcode 16.0 Beta 6, the display version is of the form "Optional(version)". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apple... why...
Using displayVersion
is clearly brittle, but it does work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch them add a space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seemed like an oversight. We'll see swiftlang/swift-package-manager#7934
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this ever fully breaks we can do what Apollo does and hardcode the current release version. I'd prefer to trust SPM rather than have to keep this in-sync myself, so we're starting out with this approach.
// As of Xcode 16.0 Beta 6, the display version is of the form "Optional(version)". | ||
// This regular expression is duplicated by SafeDIGenerateDependencyTree since plugins can not share code. | ||
guard let versionMatch = try /Optional\((.*?)\)|^(.*?)$/.firstMatch(in: displayVersion), | ||
let versionSubstring = versionMatch.output.1 ?? versionMatch.output.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why checking .1
as well as .2
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto in the copied code in the other plugin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm falling back to a version with no surrounding Optional(...)
in case this gets fixed. .1
gets us the optional match. .2
gets us the match without the optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question but LGTM
Xcode 16 allows for plugins to determine their own display version, which enables us to:
SafeDITool
from GithubThis PR does both of these things. Note that we do not touch the Swift 5.10 & Xcode 15 code-path, which still looks for an unversioned 😭 release installed via Homebrew.