Skip to content

Conversation

@eerie444
Copy link
Contributor

Fixes #345 using the improved interaction between switch and #if in Swift 4.1+.

I believe this requires removing support for Swift 4.0. Let me know if that assumption is incorrect.

Erik Strottmann added 2 commits October 30, 2019 17:44
https://bugs.swift.org/browse/SR-2 was resolved in Swift 4.1. Removing
support for Swift 4.0 is necessary to fix #345.
https://bugs.swift.org/browse/SR-2 was resolved in Swift 4.1. That
allows simplifying the switch statement in StringStyle.update(part:)
to remove nested switches, defaults, and fatal errors. Fixes #345.
@ZevEisenberg
Copy link
Collaborator

I belieeeeve that’s correct, but I’d feel better if I could see a Swift bug # saying when it was changed. As for this update, it looks great, but I’m not sure I’m comfortable dropping Swift 4.0 support just yet. Xcode 11 won’t be required for App Store submissions until April of 2020, and even then, people may be using this for apps that are not in the App Store. The code is gross, yes, and your cleanup is really nice, but since the code itself is working and (mostly) well-tested, I see this as an ain’t-broke-don’t-fix-it scenario.

If any of our assumptions about Xcode versions are wrong, or just given enough time, I think we could reconsider.

@ZevEisenberg
Copy link
Collaborator

Oh, and thanks for this contribution! The code itself looks really nice. It’s just complicated by some unfortunate historical/technical context.

@eerie444
Copy link
Contributor Author

I should have linked directly to SR-2—it was closed with a comment that it was implemented in Swift 4.1.

This was interesting to me, since swiftlang/swift#9457 was merged into master on 2017-06-28, while swift-4.0-RELEASE was tagged later than that on 2017-09-19 and swift-4.1-RELEASE wasn’t tagged until 2018-03-29. So I confirmed via Git history that the swift-4.0-RELEASE commit does not have the SR-2 commit as an ancestor, but the swift-4.1-RELEASE commit does.

Instead of increasing the Swift version requirement from 4.0 to 4.2, it would be possible to also support 4.1, which is included with Xcode 9.3. I can’t find the current minimum Xcode version for App Store submissions, but presumably it’s already Xcode 10. Still, you’re right that apps that aren’t on the App Store might be using BonMot with Xcode < 9.3.

I also noticed that the readme badge mentions support for Swift 4.2 + 5.0. Should that include 4.0 too?

@ZevEisenberg
Copy link
Collaborator

Good call on the badge. I’m not sure if it’s helping or hurting more. 4.2 and 5.0 are the versions we’re testing with on CircleCI (see .circleci/config.yml if you want the details), so in that sense, they’re all that’s currently supported. But that doesn’t mean it doesn’t work in older versions; just that we’re not currently guaranteeing compatibility. No one has complained yet, so maybe we’re good? ¯\_(ツ)_/¯

@eerie444
Copy link
Contributor Author

Hey there! Happy one year since opening this PR. (And what a year.) I wanted to check in and see what your thoughts are on getting this ready to merge. No pressure either way, but I figure at this point we should either merge or close this PR.

@ZevEisenberg
Copy link
Collaborator

Hi! Yes, let's get this merged. Some stuff has changed on the build side of these things, so maybe you could rebase on latest upstream? That would kick off new builds. And I agree that the readme should be explicit about Swift 4.1+ or 4.2+ or whatever you deem appropriate based on the changes.

case let .hyphenationFactor(hyphenationFactor):
self.hyphenationFactor = hyphenationFactor
#if os(iOS) || os(tvOS) || os(watchOS)
case let .speaksPunctuation(speaksPunctuation):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I'd prefer to keep everything indented inside the #if blocks to make it easier to visually chunk this into its constituent parts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I changed it. I originally removed that indentation because the default Xcode indentation (highlight code, then control+I) doesn’t add extra indentation within #if blocks.

@eerie444 eerie444 closed this Nov 22, 2020
@eerie444 eerie444 deleted the issue-345 branch November 22, 2020 00:26
@eerie444 eerie444 restored the issue-345 branch November 22, 2020 00:26
@eerie444
Copy link
Contributor Author

Oops, accidentally closed the PR. Reopened now.

I rebased on master and made the changes you requested.

I think it’s best to remove Swift 4.0 support and increase the minimum version to Swift 4.2, rather than adding new support for Swift 4.1.

@eerie444
Copy link
Contributor Author

GitHub won’t let me reopen the PR because I force-pushed while it was closed. Huh.

Let’s continue in #396.

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.

Use Swift 4.1's ability to wrap directives around switch cases

2 participants