Use Network Extension for VPN on iOS

I'm trying to use Network Extension to develop a VPN tool for iOS devices. I used a NETunnelProviderManager to create VPN configuration and created extension target conaining a subclass of NEPacketTunnelProvider.

But when I use NETunnelProviderManager.connection.startVPNTunnel() to enable the extension, I got a error output: "Failed to fetch info with type 2: Connection interrupted".

I checked my entitlements for both app and extension and they both contains PacketTunnel capability. And the info.plist for extension is correct with a principal class $(PRODUCT_MODULE_NAME).PacketTunnelProvider (which is identical to my provider class).

I want to know which configuration could cause the problem and how can I fix it. Thank for any helping.

Use Network Extension for VPN on iOS
 
 
Q