Skip to content
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

Xcode 13 compatibility #411

Merged
merged 12 commits into from
Jun 30, 2021
Merged

Xcode 13 compatibility #411

merged 12 commits into from
Jun 30, 2021

Conversation

ZevEisenberg
Copy link
Collaborator

@ZevEisenberg ZevEisenberg commented Jun 8, 2021

Fixes #409, but does not add Xcode 13 to the CI test runners because CircleCI doesn't support Xcode 13 yet.

Comment on lines 30 to 31
let BONFontFeatureTypeIdentifierKey = UIFontDescriptor.FeatureKey.featureIdentifier
let BONFontFeatureSelectorIdentifierKey = UIFontDescriptor.FeatureKey.typeIdentifier
let BONFontFeatureTypeIdentifierKey = UIFontDescriptor.FeatureKey.type
let BONFontFeatureSelectorIdentifierKey = UIFontDescriptor.FeatureKey.selector
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These have been deprecated since iOS 8, but we somehow didn't get compile-time warnings, but in this release they must have finally removed them because we get run-time crashes due to failed dynamic symbol loading or something like that. Migrated them to the iOS 9+ variants.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is a radar for this in the release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-beta-release-notes

Apps that contain Swift code referencing featureIdentifier or typeIdentifier fail to launch on earlier OS releases. (79090498)

Seems like they might be fixing it at some point.

case body
case preferred

@available(iOS 11, tvOS 11, *)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I checked, and apparently the stuff we use for this actually goes back to iOS 10, but I don't see any point in back-porting it now.

Comment on lines -17 to +44
case control
public static var control: AdaptiveStyle {
AdaptiveStyle(behavior: .control)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Converted all these enum cases to static functions to maintain call site compatibility.

@raizlabs-oss-bot
Copy link
Collaborator

raizlabs-oss-bot commented Jun 8, 2021

1 Warning
⚠️ Big PR
2 Messages
📖 Test Results
📖 Code Coverage

Current coverage for BonMot.framework is 76.71%

Files changed - -
AdaptableTextContainer.swift 42.00% 🚫
AdaptiveStyle.swift 73.99% ⚠️
StyleableUIElement.swift 74.62% ⚠️

Powered by xcov

Generated by 🚫 Danger

@ZevEisenberg
Copy link
Collaborator Author

Hmmm, it looks like there's some weirdness with UIFontDescriptor.FeatureKey.type and UIFontDescriptor.FeatureKey.selector in terms of iOS version checking. I can't figure out what incarnation I need. I thought this would work, but it does not:

let BONFontFeatureTypeIdentifierKey: UIFontDescriptor.FeatureKey = {
    if #available(iOS 10, macCatalyst 13, tvOS 10, watchOS 2, *) {
        return .type
    }
    else {
        return .featureIdentifier
    }
}()

let BONFontFeatureSelectorIdentifierKey: UIFontDescriptor.FeatureKey = {
    if #available(iOS 10, macCatalyst 13, tvOS 10, watchOS 2, *) {
        return .selector
    }
    else {
        return .typeIdentifier
    }
}()

That builds in Xcode 13, but in Xcode 12 I get:

🛑 Type 'UIFontDescriptor.FeatureKey' has no member 'type'

@chrisballinger
Copy link
Contributor

Thanks @ZevEisenberg! Any further thoughts on why the availability check is not working as expected?

@ZevEisenberg
Copy link
Collaborator Author

Nope. Not sure if bug or what. You might want to try reproing in a sample project, and then doing a WWDC lab or at least radar if you can't figure it out.

@raven
Copy link

raven commented Jun 16, 2021

From my reading, it appears that the @available checks for enum cases with associated values was originally broken, and they have 'resolved' it in Swift 5.5

apple/swift#36327

The old behavior:
 - Stored properties could not have @available at all.
 - Enum elements with associated values could be @available without restriction.

When computing the in-memory layout of a type we require that all stored types are available at runtime, that is, not any newer than the intersection of the current deployment target and the availability context of their type.

This means that stored properties and enum elements with associated values must have the same availability checking behavior as each other, and also that both existing behaviors were wrong.

The new rule is that @available is only allowed on either kind of declaration if the OS version is not any newer than the enclosing availability context.

@chrisballinger
Copy link
Contributor

The easiest and most minimal solution might be to bump the minimum iOS version to 11.0 and remove the availability check, which I think I might prefer at this point.

@ZevEisenberg
Copy link
Collaborator Author

I'm fine with that. Maybe do an audit for any other availability checks that can be removed. It'll need to be a major version bump because of semver

@xezero
Copy link

xezero commented Jun 21, 2021

Any update on this? :)

@mihaicris-adoreme
Copy link

Hi, is there any branch for BonMot that I can test my project on Xcode 13/iOS15 ?

@chrisballinger
Copy link
Contributor

Sorry folks, looks like we are blocked on known bug in Xcode 13b2, unless y'all can come up with a workaround: #411 (comment)

@chrisballinger chrisballinger merged commit 5bae129 into master Jun 30, 2021
@chrisballinger chrisballinger deleted the xcode-13 branch June 30, 2021 17:30
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.

Compilation issue in Xcode 13 beta 1
6 participants