ios – Be aware: XCode 15.1 does not properly check backward compatibility of runtime casts with iOS15 and you can run into dyld:Symbol Not Found


We have recently run into a situation where our builds did not run on iOS15 any more. We were getting completly unrelated crash dumps with dyld issues and Symbol not found.

The error looks like this:

dyld[8011]: Symbol not found: _swift_getExtendedExistentialTypeMetadata
  Referenced from: /Users/jonas/Library/Developer/CoreSimulator/Devices/04C9C2EC-A371-4523-9E71-3A5A0A3BBD02/data/Containers/Bundle/Application/799DE0D8-FDC1-4378-BC4C-AE4157CED3B0/SwiftPackageIssue.app/SwiftPackageIssue
  Expected in: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftCore.dylib

or in a crashdump like this:

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: DYLD 4 Symbol missing
Symbol not found: _$s7SwiftUI28BorderedProminentButtonStyleVAA09PrimitiveeF0AAMc
Referenced from: /private/var/containers/Bundle/Application/53FB853D-69A1-4EDF-A118-A5C56839968D/myApp.app/myApp
Expected in: /System/Library/Frameworks/SwiftUI.framework/SwiftUI

Triggered by Thread:  0


Thread 0 Crashed:
0   dyld                            0x0000000101d04be8 __abort_with_payload + 8
1   dyld                            0x0000000101cde498 abort_with_payload_wrapper_internal + 104 (terminate_with_reason.c:102)
2   dyld                            0x0000000101d0958c abort_with_payload + 16 (terminate_with_reason.c:124)
3   dyld                            0x0000000101cedba4 dyld4::halt(char const*) + 328 (DyldProcessConfig.cpp:2004)
4   dyld                            0x0000000101cc7a00 dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 3520 (dyldMain.cpp:0)
5   dyld                            0x0000000101cdb6fc start + 488 (dyldMain.cpp:879)

The error messages are unfortunately not helpful at all. The real reason for the crash was that XCode 15.1 did not properly check for iOS15 compatibility issues related to runtime casts. Initially we thought that this would be a swift package issue, but it turns out it is partly a general issue.

The following code compiles, with minimum deployment target set to iOS15, but crashes when run on a simulator or on a device with iOS15.5. The section that is commented out actually generates a compile issue in a project, but does not in a swift package that is configured to be .iOS14.

ContentView.swift:

import Combine

struct ContentView: View {
    var body: some View {
        
        let foo = Foo<Int,Never>(subject:PassthroughSubject<Int,Never>())
        
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundStyle(.tint)
            Text("Hello, world!")
        }
        .padding()
    }
    
    
}

struct Foo<Output,Failure:Error> {
    let subject:any Subject<Output,Failure>
    
    // Compiles but should not.
    func shouldNotCompile() {
        if let subject = subject as? PassthroughSubject<Output,Failure> {
            print("Oops.")
        }
    }
    
    // Generates compiler error in project, but not in swift package.
//    func shouldAlsoNotCompile(subject:PassthroughSubject<Output,Failure>) -> (any Subject<Output,Failure>)? {
//        return subject as? any Subject<Output,Failure>
//    }
    
}

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img