objective-cswiftxcodeswift3networkextension

networkextension does not import newer version


I'm trying to work with networkextension in xcode 10 ios12 basically, I have imported it and it supposed to be from ios12 which has an extra func ( startVPNTunnelwithOptions ) i can overide it. but instead, xcode seems link it to older version. Now if I try to override it, xcode keeps telling me to use startVPNTunnel

Replace 'startVPNTunnelWithOptions(' with 'startVPNTunnel(options:
1. 'startVPNTunnelWithOptions' was obsoleted in Swift 3 (NetworkExtension.NEVPNConnection) 

As above msg shows, xcode seems using swift3 instead of 4.2 or 5.

but I'm using latest xcode and macOS and I even set project to development target to 12.2 and in Swift lang I set to swift5

enter image description here

startVPNTunnelWithOptions method is in customized PacketTunnelProvider.m and i have a bridge header file to bridge it following is what's in bridge file

#import "../ConnectTunnel/PacketTunnelProvider.h"

what am I missing here?


Solution

  • - (BOOL)startVPNTunnelWithOptions:(NSDictionary<NSString *,NSObject *> *)options 
                       andReturnError:(NSError * _Nullable *)error;
    

    This method is available in objc and was obsoleted in swift 3 Objc doc link: https://developer.apple.com/documentation/networkextension/nevpnconnection/1406061-startvpntunnelwithoptions?language=objc

    In swift 3+ the function was renamed to func startVPNTunnel(options: [String : NSObject]? = nil) throws

    Swift doc link: https://developer.apple.com/documentation/networkextension/nevpnconnection/1406061-startvpntunnel