0

I have CustomClass: UIApplication

in main.m

retVal = UIApplicationMain(argc, argv, NSStringFromClass([CustomClass class]), NSStringFromClass([AppDelegate class]));

When I launch in iOS 11.2.2 It's Ok. If I launch in iOS 11.3 beta application crashed with reason:

+[CustomClass registerAsSystemApp]: unrecognized selector sent to class 0x1b4ff8648

    Call stack: (
    0   CoreFoundation                      0x00000001836bc250 <redacted> + 252
    1   libobjc.A.dylib                     0x00000001828845ec objc_exception_throw + 56
    2   CoreFoundation                      0x00000001836c9488 <redacted> + 0
    3   CoreFoundation                      0x00000001836c1a74 <redacted> + 1380
    4   CoreFoundation                      0x00000001835a7b0c _CF_forwarding_prep_0 + 92
    5   UIKit                               0x000000018dbcb744 <redacted> + 852
    6   UIKit                               0x000000018d9cc1e8 UIApplicationMain + 184
    7   company.product                   0x0000000100ceb264 main + 176
    8   libdyld.dylib                       0x0000000183021fc0 <redacted> + 4
)   libc++abi.dylib: terminate_handler unexpectedly threw an exception

I can't understand why?

UPD in Simulator iOS 11.3 work great...but from device I get crash

UPD2 CustomClass

.h

@interface CustomClass : UIApplication {
    TCBIdleService *_idleService;
    LocationManager *_locationManager;
    TCBUserSession *_userSession;
}

+ (CustomClass *)sharedApp;
+ (NSString *)pushNotificationTokenKey;

- (void)loginWithUserInfo:(UserInfoMto *)userInfo;
- (void)logout;
- (void)registerPushNotifications;

.m

@interface CustomClass ()<TCBIdleServiceObserving, UIAlertViewDelegate, QCSSendListener>

SIGABRT

redisky
  • 97
  • 2
  • 11
  • Can you show your `CustomClass`? – lee Jan 29 '18 at 10:18
  • @lee This class has 325 rows. What specifically need to show? The only thing that has time to call from Custom Class it: ```+ (void)load { // Installing handler in app's delegate do not allow to intercept uncaught exceptions thrown by init method. InstallUncaughtExceptionHandler(); }``` – redisky Jan 29 '18 at 11:37
  • Assuming you're the one calling `registerAsSystemApp`, check first to see whether the class responds to that selector. – Phillip Mills Jan 29 '18 at 14:50
  • @PhillipMills, like this? breakpoint in body ```- (void) load``` ```(lldb) po [CustomClass registerAsSystemApp] false``` – redisky Jan 29 '18 at 14:59
  • 1
    I was thinking of a runtime check like: `if ([[CustomClass class] respondsToSelector:@selector(registerAsSystemApp)]) {}`. – Phillip Mills Jan 29 '18 at 15:06
  • @PhillipMills, this return true – redisky Jan 29 '18 at 15:09
  • 1
    So, you're saying that `if ([[CustomClass class] respondsToSelector:@selector(registerAsSystemApp)]) { [CustomClass registerAsSystemApp]; }` crashes in the same way? That sounds like a bug even for a private API. – Phillip Mills Jan 29 '18 at 18:47
  • Show your `registerAsSystemApp` body method. If every thing just work as @PhillipMills mentioned above, so I think you need to report bug to Apple. – lee Jan 30 '18 at 03:05
  • @PhillipMills Stop, If ```[CustomClass registerAsSystemApp];``` is called in the body of the loop, then the application will not even be compiled. ```No known class method for selector 'registerAsSystemApp'``` – redisky Jan 30 '18 at 07:32
  • @lee The ```CustomClass``` does't implement the method ```registerAsSystemApp```. – redisky Jan 30 '18 at 07:34
  • I thought that the method should be called from the parent class. I do not understand why this method is generally called, it is also private. – redisky Jan 30 '18 at 07:35

1 Answers1

0

The problem was that my class in the project was named MBApp(this is CustomClass), it turns out that this name intersects with a class from a MobileBackup.framework that already has this class. Therefore, the method registerAsSystemApp was called from the MobileBackup.framework and naturally did not find it there. That is, the solution for me was to change the name of my MBApp class. The only puzzle is why it did not happen before, since the library with the class exists with iOS 5. Thanks for all the help and sorry that I did not write the original class name, because this is confendential information.

redisky
  • 97
  • 2
  • 11