I'm running into a curious problem when trying to load a custom packet tunnel extension (not precisely based on the DTS sample because our code is all C-based rather than Swift, but it was modeled off of that sample as much as possible). When the extension tries to load, I see this:
Jul 13 17:49:28 iPad nesessionmanager(NetworkExtension)[169] <Notice>: NESMVPNSession[Test VPN:CA508B27-7498-4CFC-97DA-4F6723E44F59]: Received a start command from test[516]
Jul 13 17:49:28 iPad nesessionmanager(NetworkExtension)[169] <Notice>: NESMVPNSession[Test VPN:CA508B27-7498-4CFC-97DA-4F6723E44F59]: status changed to connecting
Jul 13 17:49:28 iPad neagent(libextension.dylib)[170] <Notice>: calling plugIn beginUsing:
Jul 13 17:49:28 iPad pkd[124] <Notice>: assigning plug-in <CFString 0x16e85a10 [0x37dbece8]>{contents = "com.********.test.TunnelProvider"}(<CFString 0x353f9978 [0x37dbece8]>{contents = "1.0"}) to plugin sandbox
Jul 13 17:49:28 iPad pkd[124] <Notice>: enabling pid=170 for plug-in <CFString 0x16e85a10 [0x37dbece8]>{contents = "com.********.test.TunnelProvider"}(<CFString 0x353f9978 [0x37dbece8]>{contents = "1.0"}) <CFString 0x16d8e5a0 [0x37dbece8]>{contents = "C5B36C54-5C88-4219-897D-83BB597E9345"} <CFString 0x16d8e5d0 [0x37dbece8]>{contents = "/private/var/mobile/Containers/Bundle/Application/CA349E22-B61B-498F-809F-428449AB57FD/test.app/PlugIns/TunnelProvider.appex"}
Jul 13 17:49:28 iPad securityd[80] <Notice>: XPC [amfid[167]] operation: <CFString 0xfa2bc [0x37dbece8]>{contents = "trust_evaluate"} (8)
Jul 13 17:49:28 iPad securityd[80] <Notice>: SecError: Error Domain=NSOSStatusErrorDomain Code=-34018 "The operation couldn\M-b\M^@\M^Yt be completed. (OSStatus error -34018 - client has neither application-identifier nor keychain-access-groups entitlements)" UserInfo=0x16d1b350 {NSDescription=client has neither application-identifier nor keychain-access-groups entitlements}
Jul 13 17:49:28 iPad securityd[80] <Notice>: error SecCFCreateErrorWithFormatAndArguments SecError: The operation couldn\M-b\M^@\M^Yt be completed. (OSStatus error -34018 - client has neither application-identifier nor keychain-access-groups entitlements)\^J
Jul 13 17:49:28 iPad securityd[80] <Notice>: SecError: Error Domain=NSOSStatusErrorDomain Code=-34018 "The operation couldn\M-b\M^@\M^Yt be completed. (OSStatus error -34018 - client has neither application-identifier nor keychain-access-groups entitlements)" UserInfo=0x16d1b350 {NSDescription=client has neither application-identifier nor keychain-access-groups entitlements}
Jul 13 17:49:28 iPad securityd[80] <Notice>: error SecCFCreateErrorWithFormatAndArguments SecError: The operation couldn\M-b\M^@\M^Yt be completed. (OSStatus error -34018 - client has neither application-identifier nor keychain-access-groups entitlements)\^J
Jul 13 17:49:28 iPad amfid(Security)[167] <Notice>: <CFString 0x1661ec00 [0x37dbece8]>{contents = " [leaf IssuerCommonName]"}
Jul 13 17:49:28 iPad amfid(Security)[167] <Notice>: SecTrustEvaluate [leaf IssuerCommonName]\^J
Jul 13 17:49:28 iPad securityd[80] <Notice>: XPC [amfid[167]] operation: <CFString 0xfa2bc [0x37dbece8]>{contents = "trust_evaluate"} (8)
Jul 13 17:49:28 iPad springboardservicesrelay(liblockdown.dylib)[552] <Notice>: Checked in with lockdown on path 'xpc' socket 5 without SSL
Jul 13 17:49:28 iPad springboardservicesrelay(liblockdown.dylib)[552] <Notice>: The connection is now invalid.
Jul 13 17:49:28 iPad springboardservicesrelay(liblockdown.dylib)[552] <Notice>: XPC listener can now be shutdown
Jul 13 17:49:28 iPad securityd[80] <Notice>: XPC [amfid[167]] operation: <CFString 0xfa2bc [0x37dbece8]>{contents = "trust_evaluate"} (8)
Jul 13 17:49:28 iPad neagent(libextension.dylib)[170] <Notice>: completed calling plugIn beginUsing: for pid: 551
Jul 13 17:49:28 iPad UserEventAgent(AppleAwatchd-plugin)[19] <Notice>: watchdog: cannot find fg property
Jul 13 17:49:28 iPad TunnelProvider(CoreFoundation)[551] <Notice>: <CFString 0x14575e60 [0x37dbece8]>{contents = "*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: <__NSConcreteUUID 0x14571a20> FF30CE5F-C9D6-43FE-A9D2-060003828563)'\^J*** First throw call stack:\^J(0x22ebd153 0x3488ee0f 0x22dd8b79 0x340ce409 0x340cdae3 0x34faecff 0x34fbb081 0x34fba841 0x34fbcbcd 0x34fbca45 0x35164dcd 0x351649bc)\^J"}
Jul 13 17:49:28 iPad neagent(PlugInKit)[170] <Notice>: plugin <CFString 0x17635d40 [0x37dbece8]>{contents = "com.********.test.TunnelProvider"} interrupted
Jul 13 17:49:28 iPad neagent(libextension.dylib)[170] <Notice>: extension connection was interrupted
Jul 13 17:49:28 iPad neagent(libextension.dylib)[170] <Notice>: Unable to setup extension context - error: <CFString 0x17519100 [0x37dbece8]>{contents = "Couldn\M-b\M^@\M^Yt communicate with a helper application."}
Jul 13 17:49:28 iPad neagent(PlugInKit)[170] <Notice>: plugin <CFString 0x17635d40 [0x37dbece8]>{contents = "com.********.test.TunnelProvider"} invalidated
Jul 13 17:49:28 iPad neagent(NetworkExtension)[170] <Notice>: Extension com.********.test.TunnelProvider died unexpectedly
Jul 13 17:49:28 iPad neagent(NetworkExtension)[170] <Notice>: Failed to start extension com.********.test.TunnelProvider: Error Domain=NSExtensionErrorDomain Code=-1 "Unable to initialize remote proxy for extension. The connection was interrupted." UserInfo=0x175351d0 {NSLocalizedDescription=Unable to initialize remote proxy for extension. The connection was interrupted.}
Jul 13 17:49:28 iPad UserEventAgent(AppleAwatchd-plugin)[19] <Notice>: watchdog: cannot find fg property
Jul 13 17:49:28 iPad nesessionmanager(NetworkExtension)[169] <Notice>: NESMVPNSession[Test VPN:CA508B27-7498-4CFC-97DA-4F6723E44F59]: status changed to disconnecting
Jul 13 17:49:28 iPad nesessionmanager(NetworkExtension)[169] <Notice>: NESMVPNSession[Test VPN:CA508B27-7498-4CFC-97DA-4F6723E44F59]: status changed to disconnected, last stop reason Plugin failed
Jul 13 17:49:28 iPad symptomsd(SymptomEvaluator)[103] <Notice>: __51-[FlowAnalyticsEngine _applicationStateMonitorInit]_block_invoke Attempt to add an app with insufficient id, info {\^J BKSApplicationStateAppIsFrontmost = 1;\^J BKSApplicationStateExtensionKey = 1;\^J SBApplicationStateDisplayIDKey = "com.********.test.TunnelProvider";\^J SBApplicationStateKey = 8;\^J SBApplicationStateProcessIDKey = 551;\^J SBMostElevatedStateForProcessID = 8;\^J}
Jul 13 17:49:28 iPad ReportCrash[553] <Notice>: Formulating report for corpse[551] TunnelProvider
Jul 13 17:49:28 iPad ReportCrash[553] <Notice>: report not saved because the limit of 25 for <CFString 0x14d70730 [0x37dbece8]>{contents = "109_TunnelProvider"} logs has been reached.
Jul 13 17:49:28 iPad ReportCrash[553] <Notice>: Notice: This report is abbreviated for syslog inclusion because it could not be saved to disk.\^JSymbolication may be possible by manually cleaning up and including the Binary Image section of a full report from this same device -- good luck!
Jul 13 17:49:28 iPad ReportCrash[553] <Notice>: Process: TunnelProvider [551]\^JPath: /private/var/mobile/Containers/Bundle/Application/CA349E22-B61B-498F-809F-428449AB57FD/test.app/PlugIns/TunnelProvider.appex/TunnelProvider\^JOS Version: iOS 9.0 (13A4293g)\^J\^J
Jul 13 17:49:28 iPad ReportCrash[553] <Notice>: Exception Type: EXC_CRASH (SIGABRT)\^JException Codes: 0x0000000000000000, 0x0000000000000000\^JException Note: EXC_CORPSE_NOTIFY\^JTriggered by Thread: 3\^J\^J
Jul 13 17:49:28 iPad ReportCrash[553] <Notice>: Thread 0 name: Dispatch queue: com.apple.main-thread\^JThread 0:\^J0 libsystem_kernel.dylib 0x350b2f48 0x350b2000 + 3912\^J1 libsystem_kernel.dylib 0x350b2d48 0x350b2000 + 3400\^J2 CoreFoundation 0x22e804dc 0x22dc8000 + 754908\^J3 CoreFoundation 0x22e7e838 0x22dc8000 + 747576\^J4 CoreFoundation 0x22dd1224 0x22dc8000 + 37412\^J5 CoreFoundation 0x22dd1010 0x22dc8000 + 36880\^J6 Foundation 0x23c1167c 0x23c06000 + 46716\^J7 Foundation 0x23c605a8 0x23c06000 + 370088\^J8 libxpc.dylib 0x3518c4d4 0x35180000 + 50388\^J9 libxpc.dylib 0x3518db98 0x35180000 + 56216\^J10 Foundation 0x23db6768 0x23c06000 + 1771368\^J11 PlugInKit 0x2e8e514c 0x2e8d8000 + 53580\^J12 PlugInKit 0x2e8e4e1a 0x2e8d8000 + 52762\^J13 PlugInKit 0x2e8e5180 0x2e8d8000 + 53632\^J14 libextension.dylib 0x340dc7f4 0x340c9000 + 79860\^J15 libdyld.dylib 0x34ff7870 0x34ff5000 + 10352\^J\^J
Jul 13 17:49:28 iPad ReportCrash[553] <Notice>: Thread 1:\^J0 libsystem_kernel.dylib 0x350c792c 0x350b2000 + 88364\^J1 libsystem_pthread.dylib 0x35164dd4 0x35164000 + 3540\^J2 libsystem_pthread.dylib 0x351649b8 0x35164000 + 2488\^J\^J
Jul 13 17:49:28 iPad ReportCrash[553] <Notice>: Thread 2 name: Dispatch queue: com.apple.libdispatch-manager\^JThread 2:\^J0 libsystem_kernel.dylib 0x350c83c0 0x350b2000 + 91072\^J1 libdispatch.dylib 0x34fc277c 0x34fac000 + 92028\^J2 libdispatch.dylib 0x34fc24da 0x34fac000 + 91354\^J\^J
Jul 13 17:49:28 iPad ReportCrash[553] <Notice>: Thread 3 name: Dispatch queue: com.apple.extension.global-state-queue\^JThread 3 Crashed:\^J0 libsystem_kernel.dylib 0x350c6d24 0x350b2000 + 85284\^J1 libsystem_pthread.dylib 0x35167afe 0x35164000 + 15102\^J2 libsystem_c.dylib 0x3505ee8c 0x35014000 + 306828\^J3 libc++abi.dylib 0x33f60ae0 0x33f60000 + 2784\^J4 libc++abi.dylib 0x33f7969a 0x33f60000 + 104090\^J5 libobjc.A.dylib 0x3488f0a6 0x34888000 + 28838\^J6 libc++abi.dylib 0x33f76e14 0x33f60000 + 93716\^J7 libc++abi.dylib 0x33f765f0 0x33f60000 + 91632\^J8 libobjc.A.dylib 0x3488eede 0x34888000 + 28382\^J9 CoreFoundation 0x22dd8b74 0x22dc8000 + 68468\^J10 libextension.dylib 0x340ce404 0x340c9000 + 21508\^J11 libextension.dylib 0x340cdade 0x340c9000 + 19166\^J12 libdispatch.dylib 0x34faecfc 0x34fac000 + 11516\^J13 libdispatch.dylib 0x34fbb07c 0x34fac000 + 61564\^J14 libdispatch.dylib 0x34fba83c 0x34fac000 + 59452\^J15 libdispatch.dylib 0x34fbcbca 0x34fac000 + 68554\^J16 libdispatch.dylib 0x34fbca40 0x34fac000 + 68160\^J17 libsystem_pthread.dylib 0x35164dca 0x35164000 + 3530\^J18 libsystem_pthread.dylib 0x351649b8 0x35164000 + 2488\^J\^J
Jul 13 17:49:28 iPad ReportCrash[553] <Notice>: Thread 4:\^J0 libsystem_kernel.dylib 0x350c792c 0x350b2000 + 88364\^J1 libsystem_pthread.dylib 0x35164dd4 0x35164000 + 3540\^J2 libsystem_pthread.dylib 0x351649b8 0x35164000 + 2488\^J\^J
Jul 13 17:49:28 iPad ReportCrash[553] <Notice>: Thread 5:\^J0 libsystem_kernel.dylib 0x350c792c 0x350b2000 + 88364\^J1 libsystem_pthread.dylib 0x35164dd4 0x35164000 + 3540\^J2 libsystem_pthread.dylib 0x351649b8 0x35164000 + 2488\^J\^J
Jul 13 17:49:28 iPad ReportCrash[553] <Notice>: Thread 3 crashed with ARM Thread State (32-bit):\^J r0: 0x00000000 r1: 0x00000000 r2: 0x00000000 r3: 0x00000000\^J r4: 0x37db0044 r5: 0x37db8910 r6: 0x00000015 r7: 0x1f218fe0\^J r8: 0x1f219000 r9: 0x00020000 r10: 0x34fbc9e5 r11: 0x00002307\^J ip: 0x00000170 sp: 0x1f218fac lr: 0x35164dd9 pc: 0x350c792c\^J cpsr: 0x40000010\^J\^J
Jul 13 17:51:14 iPad hangtracerd[84] <Notice>: Replenish tokens from 0 to 1 - now/last_stackshot_time: 139ee29ecb - e976cc06b = 50775de60 report_period=141dd76000 max_reports=4
The app and the plug-in do both have a CFBundleIdentifier, so the app identifier should be blown into the entitlements automatically. And they also both have an explicit keychain access group. And neither one uses the keychain in the first place, making the notion that this could be the problem even sillier, so I'm guessing that the debug spew has no bearing on the actual problem.
I've also ensured that it has the packet-tunnel-provider entitlement under com.apple.developer.networking.networkextension, that the NSExtension dictionary in its Info.plist contains an empty NSExtensionAttributes dictionary, has NSExtensionPrincipalClass set to $(PRODUCT_MODULE_NAME).PacketTunnelProvider (the actual class name is PacketTunnelProvider), and that NSExtensionPointIdentifier is com.apple.networkextension.packet-tunnel.
I feel like I must be missing one simple setting somewhere, but the debug output gives no hint which setting that might be.
Any ideas what could be going on here?