4

I made a compatibility version of .contentTransition like this:

public struct ContentTransitionNumericText: ViewModifier {
    public func body(content: Content) -> some View {
        if #available(iOS 16.0, watchOS 9.0, tvOS 16.0, macCatalyst 16.0, macOS 13.0, *) {
            content
                .contentTransition(.numericText())
        } else {
            content
        }
    }
}

public extension View {
    func contentTransitionNumericText() -> some View {
        modifier(ContentTransitionNumericText())
    }
}

However, running this on iOS 15 (with Xcode 14 beta) causes the app to crash with Symbol not found: _$s7SwiftUI17ContentTransitionVMn error. It seems that the availability check is completely ignored.

Is there a known solution to this?

EDIT: Seems like a Xcode/Swift bug, reported as FB11143522

EDIT2: The workaround from https://swiftui-lab.com/bug-os-check/ doesn't help inside ViewModifier, still crashes.

Tomáš Kafka
  • 4,405
  • 6
  • 39
  • 52
  • 1
    This looks to be an Apple issue, you should open a [feedback](https://feedbackassistant.apple.com/) for it – Andrew Aug 08 '22 at 14:37
  • @Andrew It would seems so, thank you. I opened a radar. All workarounds I have seen involve duplicating view code and the availability conditions at all call sites, which is absolute madness. – Tomáš Kafka Aug 08 '22 at 14:55
  • The only one that I have seen working consistently is the compiler check that pointfree.co use in the composable architecture https://github.com/pointfreeco/swift-composable-architecture/pull/931/files – Andrew Aug 08 '22 at 14:59

1 Answers1

1

I found similar case in xcode 14's release note https://developer.apple.com/documentation/xcode-release-notes/xcode-14-release-notes

search for "Link Binary With Libraries"

Workaround: For each target using a StoreKit API listed above, navigate to the “Build Phases” tab in the project editor with the target selected and add StoreKit.framework under “Link Binary With Libraries” if it isn’t already present. Set the “Status” column to “Optional.”

and for ContentTransition just add SwiftUI.framework

I tried and worked.

zcw159357
  • 11
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 19 '22 at 22:05