Post not yet marked as solved
Post marked as unsolved with 2 replies, 1,038 views
TLDR: the following code yields `nil` when built with Xcode 10.1 and run on iOS 11:Class nwPathClass = [NWPath class];IMO this should not be the case, why is this happening, can anyone explain this?Long story:I maintain an application that offers VPN through NEPacketTunnelProvider and use KVO on the defaultPath keypath in order to listen for network changes and update all kinds of stuff necessary to keep the tunnel functioning. Here is the code in which the above observation became apparent:- (void) observeValueForKeyPath:(nullable NSString *) keyPath
ofObject:(nullable id) object
change:(nullable NSDictionary *) change
context:(nullable void *) context {
if ([keyPath isEqualToString:@"defaultPath"]) {
NWPath *oldPath, *newPath;
id oldObject = change[NSKeyValueChangeOldKey];
id newObject = change[NSKeyValueChangeNewKey];
if ([oldObject isKindOfClass:[NWPath class]]) { // never evaluates to true
oldPath = oldObject;
}
if ([newObject isKindOfClass:[NWPath class]]) { // never evaluates to true
newPath = newObject;
}
if (newPath.status == NWPathStatusSatisfied && ![oldPath isEqualToPath:newObject]) {
// update tunnel things
}
}
}This code is maybe a bit too defensive, but technically this should just work. However, when this code is run on iOS 11, while it was built using Xcode 10.1, the NWPath class cannot be loaded, and therefore I am missing out on some serieous tunnel updating.Fun fact, LLDB does not seem to agree. When I hit a breakpoint and perform the following command:(lldb) po [NWPath class]
NWPathI _do_ get a class...Checking what bundle the class is from: Network.framework(lldb) po [NSBundle bundleForClass:[NWPath class]]
NSBundle </System/Library/Frameworks/Network.framework> (loaded)Which also kind of surprises me, should this not be NetworkExtension.framework?