arlomedia
arlomedia

Reputation: 9071

Crash on launch with "_objc_warn_deprecated" with Xcode 16 and iOS 18

I'm trying to build and run my app with the new Xcode 16.0 to a device with iOS 18.0, but it is crashing immediately after launch with this stack trace:

0 libobjc.A.dylib`_objc_warn_deprecated
1 realizeClassWithoutSwift
2 map_images_nolock
3 map_images
4 invocation function for block in dyld4::RuntimeState::setObjCNotifiers(void (*)(char const", mach_header const*), void (*)(mach_header con...apped_info const*), void (*) (unsigned int, _dyld _objc_notify_mapped_info const*, void (unsigned int) block_pointer))::$_0::operator)( const
5 dyld4::RuntimeLocks::withLoadersReadLock
6 dyld4::RuntimeState::setObjCNotifiers
7 dyld4:: APls::_dyld_objc_register_callbacks
8_objc_init
9_os_object_init
10 libdispatch_init
11 libSystem_initializer
12 invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const
13 invocation function for block in dyld3::MachOAnalyzer::forEachinitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const
14 invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const
15 dyld3::MachOFile::forEachLoadCommand
16 dyld3::MachOFile::forEachSection
17 dyld3::MachOAnalyzer::forEachInitializer
18 dyld4::Loader::findAndRunAllinitializers
19 dyld4::JustInTimeLoader::runInitializers
20 dyld4::APIs::runAllinitializersForMain
21 dyld4:: prepare
22 dyld4::start(dyld4::KernelArgs*, void*, void*)::$_0::operatori() const
23 start

If I build and run from Xcode 16.0 to devices with iOS 15 or iOS 17, the app builds and runs successfully.

This is the only thing in the console, but my sense is that it's not related since it also appears when the app runs successfully on the other devices:

warning: (arm64) /Users/username/Library/Developer/Xcode/DerivedData/AppName-gevkjrdhpvsixnciokrsaracikam/Build/Products/Debug-iphoneos/AppName.app/AppName empty dSYM file detected, dSYM was created with an executable with no debug info.

I originally wrote my app in Objective-C, and later converted most of it to Swift. It still had the Swift and Objective-C bridging headers due to a few small Objective-C classes that still remain. But to work around a build error with PDFDocument.h in the iOS 18 SDK (I reported that to Apple, FB15106102), I commented out the #import "AppName-Swift.h" in my .pch file and cleaned the build folder to remove the Objective-C to Swift bridging. None of the remaining Objective-C code needs to reference my Swift classes, so that shouldn't be needed, and removing it allowed the app to build and run (briefly). Maybe the app is crashing because there's something else I need to do to remove that; on the other hand, it does run fine now on older iOS versions.

I found the source code for realizeClassWithoutSwift here:

https://opensource.apple.com/source/objc4/objc4-756.2/runtime/objc-runtime-new.mm.auto.html

I haven't found anything about the libobjc.A.dylib _objc_warn_deprecated message.

I have reported the crash to Apple (FB15106573) but am hoping to get some ideas here because who knows if and when Apple will respond.

UPDATE

I removed the console warning with this answer, but the same crash still occurs. However, the problem does seem related to debugging because I noticed that after the app crashes, I can stop it from Xcode then run it by clicking the app icon on the device, and it runs fine. It only crashes while running from Xcode.

UPDATE 2

The problem is unchanged with Xcode 16.1 and iOS 18.1.

Upvotes: 1

Views: 454

Answers (1)

arlomedia
arlomedia

Reputation: 9071

I finally solved this. My app had three Objective-C breakpoints. I don't remember what they're for and probably don't need them since I rewrote the app in Swift. I did find this old SO post that I had upvoted, so that's probably what prompted me to add the objc_autoreaseNoPool breakpoint.

Anyway, when I removed that breakpoint, the problem immediately disappeared. Now I can finally debug on iOS 18 and macOS 15.

Upvotes: 0

Related Questions