Notification Service Extension crashes in production within Foundation framework

Hello.


Our Notification Service Extension modifies notification content to add an image. It is written in Objective-C.

It works great in Release builds signed with Ad-Hoc provision profiles but crashes every time in production (App Store) builds.


The console output is:

default 19:41:36.587398 +0300 NotificationServiceExtension [39CF104A-D069-4876-B2C3-7623AB38759D] Service extension context initialized
default 19:41:36.587485 +0300 NotificationServiceExtension *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: 39CF104A-D069-4876-B2C3-7623AB38759D)'
*** First throw call stack:
(0x182eedd04 0x18213c528 0x182e86bd4 0x182dbbe6c 0x18386c13c 0x18386b6b4 0x182871088 0x182871048 0x18287ae48 0x18287b7d8 0x18287c200 0x1828844a0 0x182b16fd0 0x182b16c20)


And crash log is:

Incident Identifier: E51264CC-6236-4A55-B940-DC2A1C5C67D5
CrashReporter Key:   77993c81795151c2bc4bceb8ed48cb58242337c1
Hardware Model:      iPhone9,4
Process:             NotificationServiceExtension [1267]
Path:                /private/var/containers/Bundle/Application/17B5B8A9-7E10-4D79-A16B-7C424F56448A/Tribez3-AppStore.app/PlugIns/NotificationServiceExtension.appex/NotificationServiceExtension
Identifier:          com.gameinsight.tribez3.notifications
Version:             819 (2.1)
Code Type:           ARM-64 (Native)
Role:                Unspecified
Parent Process:      launchd [1]
Coalition:           com.gameinsight.tribez3.notifications [930]




Date/Time:           2018-07-30 19:53:38.0808 +0300
Launch Time:         2018-07-30 19:53:37.9989 +0300
OS Version:          iPhone OS 11.1 (15B5086a)
Baseband Version:    2.01.03
Report Version:      104


Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  2


Application Specific Information:
abort() called


Filtered syslog:
None found


Last Exception Backtrace:
0   CoreFoundation                0x182eedd04 __exceptionPreprocess + 124
1   libobjc.A.dylib                0x18213c528 objc_exception_throw + 55
2   CoreFoundation                0x182e86bd4 _CFThrowFormattedException + 111
3   CoreFoundation                0x182dbbe6c -[__NSDictionaryM setObject:forKey:] + 931
4   Foundation                    0x18386c13c -[_NSExtensionContextVendor _setPrincipalObject:forUUID:] + 99
5   Foundation                    0x18386b6b4 __105-[_NSExtensionContextVendor _beginRequestWithExtensionItems:listenerEndpoint:withContextUUID:completion:]_block_invoke + 699
6   libdispatch.dylib              0x182871088 _dispatch_call_block_and_release + 23
7   libdispatch.dylib              0x182871048 _dispatch_client_callout + 15
8   libdispatch.dylib              0x18287ae48 _dispatch_queue_serial_drain$VARIANT$mp + 527
9   libdispatch.dylib              0x18287b7d8 _dispatch_queue_invoke$VARIANT$mp + 339
10  libdispatch.dylib              0x18287c200 _dispatch_root_queue_drain_deferred_wlh$VARIANT$mp + 399
11  libdispatch.dylib              0x1828844a0 _dispatch_workloop_worker_thread$VARIANT$mp + 643
12  libsystem_pthread.dylib        0x182b16fd0 _pthread_wqthread + 931
13  libsystem_pthread.dylib        0x182b16c20 start_wqthread + 3


Could you please some how help me?


UPDATE:


My extension class is `NotificationService` and exactly the same name is mentioned in the Info.plist entry `NSExtensionPrincipalClass`.

Answered by Anton Petrov in 324323022

NotificationService class was stripped away by compiler because it had no implementation (implementation was taken from the base class of third-party framework). In fact the class looked like this:


//NotificationService.h
#import  <ThirdPartyFramework.h>

@interface NotificationService : ThirdPartyNotificationServiceExtension
@end

//NotificationService.m
#import "NotificationService.h"

@interface NotificationService ()
@end


It is fixed by adding following lines to the NotificationService.m file.


@implementation NotificationService
@end
Accepted Answer

NotificationService class was stripped away by compiler because it had no implementation (implementation was taken from the base class of third-party framework). In fact the class looked like this:


//NotificationService.h
#import  <ThirdPartyFramework.h>

@interface NotificationService : ThirdPartyNotificationServiceExtension
@end

//NotificationService.m
#import "NotificationService.h"

@interface NotificationService ()
@end


It is fixed by adding following lines to the NotificationService.m file.


@implementation NotificationService
@end
Notification Service Extension crashes in production within Foundation framework
 
 
Q