From d477b132e4959cae4c97584db2f0ab5ea12232b4 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Wed, 7 Nov 2018 18:13:50 +0530 Subject: [PATCH] TunnelsManager: Return a manager with no tunnels in the simulator To be able to run at least parts of the app in the simulator. --- WireGuard/WireGuard/VPN/TunnelsManager.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/WireGuard/WireGuard/VPN/TunnelsManager.swift b/WireGuard/WireGuard/VPN/TunnelsManager.swift index d0fe337..3b72100 100644 --- a/WireGuard/WireGuard/VPN/TunnelsManager.swift +++ b/WireGuard/WireGuard/VPN/TunnelsManager.swift @@ -42,6 +42,10 @@ class TunnelsManager { } static func create(completionHandler: @escaping (TunnelsManager?) -> Void) { + #if targetEnvironment(simulator) + // NETunnelProviderManager APIs don't work on the simulator + completionHandler(TunnelsManager(tunnelProviders: [])) + #else NETunnelProviderManager.loadAllFromPreferences { (managers, error) in if let error = error { os_log("Failed to load tunnel provider managers: %{public}@", log: OSLog.default, type: .debug, "\(error)") @@ -49,6 +53,7 @@ class TunnelsManager { } completionHandler(TunnelsManager(tunnelProviders: managers ?? [])) } + #endif } func add(tunnelConfiguration: TunnelConfiguration, completionHandler: @escaping (TunnelContainer?, TunnelManagementError?) -> Void) {