Skip to content

Commit

Permalink
fix(cordova/apple/ios): remove overlapping dependencies between main …
Browse files Browse the repository at this point in the history
…app and AppKit bridge targets (#1788)

* Synchronize macos versions and fix code signing identity.

* Add `OutlineNotification` as explicit target dependency.

* Format `Package.swift`.

* Set principal class on `Info.plist`.

* Combine guard statements.

* Remove CocoaLumberjack from AppKitBridge bundle.

* Remove OutlineNotification from AppKitBridge bundle.

* Remove type annotation.

* Move protocol to its own target.

* use framework.
works without launcher.

* Move the catalyst app module back to SPM.

* Move NSObject extension into its own module.

* Move the launcher back to SPM and re-add it to the main app target.

* Enable app launcher.

* Reset package to minimize diff.

* Remove unused module.

* Fix project.

* Update logging.

* Run `SwiftFormat` over the changed files.
  • Loading branch information
sbruens authored Nov 22, 2023
1 parent f38b935 commit 8c52359
Show file tree
Hide file tree
Showing 84 changed files with 714 additions and 431 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 9 additions & 18 deletions src/cordova/apple/OutlineAppleLib/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ let package = Package(
name: "OutlineLauncher",
targets: ["OutlineLauncher"]
),
.library(
name: "OutlineAppKitBridge",
targets: ["OutlineAppKitBridge"]
),
.library(
name: "PacketTunnelProvider",
targets: ["PacketTunnelProvider"]
Expand All @@ -31,32 +27,27 @@ let package = Package(
targets: [
.target(
name: "OutlineLauncher",
dependencies:
["CocoaLumberjack",
.product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack"),
"OutlineCatalystApp"]
),
.target(
name: "OutlineCatalystApp",
dependencies: [
"OutlineAppKitBridge",
"CocoaLumberjack",
.product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack"),
"OutlineCatalystApp",
]
),
.target(
name: "OutlineAppKitBridge",
name: "OutlineCatalystApp",
dependencies: [
.product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack"),
"OutlineNotification",
]
),
.target(
name: "PacketTunnelProvider",
dependencies:
["CocoaLumberjack",
.product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack"),
"Tun2socks",
"OutlineTunnel"],
dependencies: [
"CocoaLumberjack",
.product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack"),
"Tun2socks",
"OutlineTunnel",
],
cSettings: [
.headerSearchPath("Internal"),
]
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// limitations under the License.

#if targetEnvironment(macCatalyst)

import CocoaLumberjack
import CocoaLumberjackSwift
import Foundation
import OutlineAppKitBridge
import OutlineNotification
import ServiceManagement

Expand All @@ -25,7 +25,7 @@
public static func initApp() {
DDLog.add(DDOSLogger.sharedInstance)

let appKitBridge: AppKitBridgeProtocol = createAppKitBridge()
let appKitController = loadAppKitIntegrationFramework()

// Configure the window.
let scenes = UIApplication.shared.connectedScenes
Expand All @@ -39,23 +39,43 @@

// Initiate the connection status menu in unknown state by default.
// TODO: Check status in case the the VPN is already running.
appKitBridge.setConnectionStatus(.unknown)
appKitController._AppKitBridge_setConnectionStatus(.unknown)

NotificationCenter.default.addObserver(forName: NSNotification.kVpnConnected,
object: nil,
queue: nil)
{ _ in
appKitBridge.setConnectionStatus(.connected)
appKitController._AppKitBridge_setConnectionStatus(.connected)
}
NotificationCenter.default.addObserver(forName: NSNotification.kVpnDisconnected,
object: nil,
queue: nil)
{ _ in
appKitBridge.setConnectionStatus(.disconnected)
appKitController._AppKitBridge_setConnectionStatus(.disconnected)
}

// Enable app launcher to start on boot.
appKitBridge.setAppLauncherEnabled(true)
appKitController._AppKitBridge_setAppLauncherEnabled(true)
}
}

public func loadAppKitIntegrationFramework() -> NSObject {
if let frameworksPath = Bundle.main.privateFrameworksPath {
let bundlePath = "\(frameworksPath)/AppKitIntegration.framework"
do {
try Bundle(path: bundlePath)?.loadAndReturnError()

let bundle = Bundle(path: bundlePath)!
DDLogInfo("[CatalystApp] AppKit bundle loaded successfully")

if let appKitControllerClass = bundle.classNamed("AppKitIntegration.AppKitController") as? NSObject.Type {
return appKitControllerClass.init()
}
} catch {
DDLogInfo("[CatalystApp] Error loading: \(error)")
}
}
preconditionFailure("[CatalystApp] Unable to load")
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
import Foundation

@objc
public protocol AppKitBridgeProtocol: NSObjectProtocol {
init()

func terminate()

func setConnectionStatus(_ status: ConnectionStatus)

func setAppLauncherEnabled(_ isEnabled: Bool)
public enum ConnectionStatus: Int {
case unknown
case connected
case disconnected
}

func loadMainApp(_ launcherBundleId: String)
public extension NSObject {
@objc func _AppKitBridge_terminate() {}
@objc func _AppKitBridge_setConnectionStatus(_: ConnectionStatus) {}
@objc func _AppKitBridge_setAppLauncherEnabled(_: Bool) {}
@objc func _AppKitBridge_loadMainApp(_: String) {}
}
Loading

0 comments on commit 8c52359

Please sign in to comment.