From d363a7867b1b211b6f1b9a8c08f27fb208518f76 Mon Sep 17 00:00:00 2001 From: Yao Fan <5057962+fysteven@users.noreply.github.com> Date: Mon, 14 Oct 2024 03:03:29 -0700 Subject: [PATCH] fix: App crashes on launch and SwiftUI preview when built with Xcode 16 due to unregistered Parse subclasses (#1811) --- .../Subclassing/PFObjectSubclassingController.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Parse/Parse/Internal/Object/Subclassing/PFObjectSubclassingController.m b/Parse/Parse/Internal/Object/Subclassing/PFObjectSubclassingController.m index 07f6adba3..affbaec9a 100644 --- a/Parse/Parse/Internal/Object/Subclassing/PFObjectSubclassingController.m +++ b/Parse/Parse/Internal/Object/Subclassing/PFObjectSubclassingController.m @@ -357,7 +357,18 @@ - (void)_registerSubclassesInLoadedBundle:(NSBundle *)bundle { - (void)_registerSubclassesInBundle:(NSBundle *)bundle { PFConsistencyAssert(bundle.loaded, @"Cannot register subclasses in an unloaded bundle: %@", bundle); - const char *executablePath = bundle.executablePath.UTF8String; + [self _registerSubclassesInExecutablePath:bundle.executablePath]; + +#if defined(DEBUG) && DEBUG + if (bundle == [NSBundle mainBundle]) { + NSString *executablePath = [NSString stringWithFormat:@"%@.debug.dylib", bundle.executablePath]; + [self _registerSubclassesInExecutablePath:executablePath]; + } +#endif +} + +- (void)_registerSubclassesInExecutablePath:(NSString *)exePath { + const char *executablePath = exePath.UTF8String; if (executablePath == NULL) { return; }