-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the launcher back to SPM and re-add it to the main app target.
- Loading branch information
Showing
6 changed files
with
116 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/cordova/apple/OutlineAppleLib/Sources/OutlineLauncher/AppDelegate.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2018 The Outline Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#if targetEnvironment(macCatalyst) | ||
import CocoaLumberjack | ||
import CocoaLumberjackSwift | ||
import NetworkExtension | ||
import OutlineCatalystApp | ||
import UIKit | ||
|
||
@UIApplicationMain | ||
class AppDelegate: UIResponder, UIApplicationDelegate { | ||
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | ||
DDLog.add(DDOSLogger.sharedInstance) | ||
|
||
let appKitController = loadAppKitIntegrationFramework() | ||
shouldLaunchMainApp { shouldLaunch in | ||
defer { | ||
DDLogInfo("Exiting launcher...") | ||
appKitController._AppKitBridge_terminate() | ||
} | ||
if !shouldLaunch { | ||
DDLogInfo("Not launching, Outline not connected at shutdown") | ||
return | ||
} | ||
DDLogInfo("Outline connected at shutdown. Launching") | ||
|
||
guard let launcherBundleId = Bundle.main.bundleIdentifier else { | ||
DDLogError("Failed to retrieve the bundle ID for the launcher app.") | ||
return | ||
} | ||
appKitController._AppKitBridge_loadMainApp(launcherBundleId) | ||
} | ||
return true | ||
} | ||
|
||
// Returns whether the launcher should launch the main app. | ||
private func shouldLaunchMainApp(completion: @escaping (Bool) -> Void) { | ||
NETunnelProviderManager.loadAllFromPreferences { managers, error in | ||
guard error == nil, managers != nil else { | ||
DDLogError("Failed to get tunnel manager: \(String(describing: error))") | ||
return completion(false) | ||
} | ||
guard let manager: NETunnelProviderManager = managers!.first, managers!.count > 0 else { | ||
DDLogError("No tunnel managers found.") | ||
return completion(false) | ||
} | ||
DDLogInfo("Tunnel manager found.") | ||
return completion(manager.isOnDemandEnabled) | ||
} | ||
} | ||
} | ||
#endif |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters