Non-public API usage
in App Store Connect技术 with 0 comment

Non-public API usage

in App Store Connect技术 with 0 comment

记录一个很奇怪的问题。在 Xcode 发布包到 AppStore 后,很快就收到苹果发送的邮件,说我使用了私有 API。

环境

Apple M1
MacOS 12.2.1 (21D62)
Xcode Version 13.2.1 (13C100)

Non-public API

_UIFontFeatureSelectorIdentifierKey_ForNewSwiftAPI
_UIFontFeatureTypeIdentifierKey_ForNewSwiftAPI

代码

let fontDesc = font.fontDescriptor
if #available(iOS 15, *) {
    let fractionFontDesc = fontDesc.addingAttributes(
        [
            UIFontDescriptor.AttributeName.featureSettings: [
                [
                    UIFontDescriptor.FeatureKey.type: kFractionsType,
                    UIFontDescriptor.FeatureKey.selector: kDiagonalFractionsSelector
                ]
            ]
        ]
    )
    return UIFont(descriptor: fractionFontDesc, size: font.pointSize)
} else {
    let fractionFontDesc = fontDesc.addingAttributes(
        [
            UIFontDescriptor.AttributeName.featureSettings: [
                [
                    UIFontDescriptor.FeatureKey.featureIdentifier: kFractionsType,
                    UIFontDescriptor.FeatureKey.typeIdentifier: kDiagonalFractionsSelector
                ]
            ]
        ]
    )
}

这段代码的作用是为了显示分数表达,比如 ½,⅓ 这样的排版。
经过揣摩上述 API 的描述,确认是 UIFontDescriptor.FeatureKey.typeUIFontDescriptor.FeatureKey.selector 的问题。但是官方 API 文档至今任然显示是可用的。

解决

只能继续使用 iOS15 之前的两个 API UIFontDescriptor.FeatureKey.featureIdentifierUIFontDescriptor.FeatureKey.typeIdentifier 替代,经测试发现任然可以正常使用。

原因

暂时没有找到具体原因,因为这段代码之前提交是没问题的。

Responses