My App is a VPN APP, use [com.apple.networkextension.packet-tunnel] extension app to provider a VPN service. A problem puzzled me for a long time: Sometimes the VPN doesn't start successfully, until the user restart the iOS System or reinstall my APP.
The detail is : The user use the app normally for many times, and suddenly can't start the vpn service, the APP log show API "startVPNTunnelWithOptions" call success, and return success. but the VPN extension status(NEVPNStatus) change from Disconnect to Connecting and then nothing happen, the VPN process not started, and not any log of the VPN extension created, my VPN log is start from the init function of the class inherit from PacketTunnelProvider, so can see that the vpn process not started.
My NETunnelProviderProtocol is :
NETunnelProviderProtocol *tunnel = [[NETunnelProviderProtocol alloc] init];
tunnel.providerBundleIdentifier = kTunBundleId;
tunnel.serverAddress = @"";
tunnel.disconnectOnSleep = NO;
[self.providerManager setEnabled:YES];
[self.providerManager setProtocolConfiguration:tunnel];
self.providerManager.localizedDescription = kAppName;
very simple, because my app use openvpn3 to provide the vpn service,so no need to set the serverAddress.
Because when this problem happened, I can't get any useful log (because APP can't get the iOS system log), so this is a really trouble for me. Could any body help !
The trick here is to have the user trigger a sysdiagnose log as soon as they see the problem. Then can then pass this on to your for analysis. For more information about this, see Your Friend the System Log.
this can get entire iOS system log ? I don't find the way to do this after I read the documents.
I said before:
because APP can't get the iOS system log
means, the log of my app is no useful, because the APP seems ok. The job to start the NetworkExtension Process is not the host APP( MY APP).
Host APP only setup the configuration and call the system API, and the log of my app show nothing wrong here.
The log of my APP shows: when after call startVPNTunnelWithOptions: success, the NEVPNStatus change from NEVPNStatusDisconnected to NEVPNStatusConnecting (from NEVPNStatusDidChangeNotification) but long time (about 1 mins) the VPN Process not created, and status change to disconnect.
So I think if i want to known why the VPN process not create success, I need to got the entiry iOS system log, this may show why the iOS system start the process fail.