Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cordova/apple/ios): remove overlapping dependencies between main app and AppKit bridge targets #1788

Merged
merged 19 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading