Skip to content

Commit a22e2c4

Browse files
authored
Merge pull request #43 from ProxymanApp/improve/support-catalyst
Support Catalyst
2 parents 3398e55 + 4128e3e commit a22e2c4

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

Sources/NetworkInjector.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,20 @@ extension NetworkInjector {
9494
if !ProcessInfo.processInfo.responds(to: #selector(getter: ProcessInfo.operatingSystemVersion)) {
9595
baseResumeClass = NSClassFromString("__NSCFLocalSessionTask")
9696
} else {
97+
#if targetEnvironment(macCatalyst)
98+
baseResumeClass = URLSessionTask.self
99+
#else
97100
let majorVersion = ProcessInfo.processInfo.operatingSystemVersion.majorVersion
98101
if majorVersion < 9 || majorVersion >= 14 {
99102
baseResumeClass = URLSessionTask.self
100103
} else {
101104
baseResumeClass = NSClassFromString("__NSCFURLSessionTask")
102105
}
106+
#endif
103107
}
104108

105109
guard let resumeClass = baseResumeClass else {
106-
assertionFailure()
110+
assertionFailure("Could not find URLSessionTask. Please open support ticket at https://github.com/ProxymanApp/atlantis")
107111
return
108112
}
109113

Sources/Packages.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111
#if os(OSX)
1212
import AppKit
1313
typealias Image = NSImage
14-
#elseif os(iOS)
14+
#elseif os(iOS) || targetEnvironment(macCatalyst)
1515
import UIKit
1616
typealias Image = UIImage
1717
#endif
@@ -131,7 +131,7 @@ struct Device: Codable {
131131
let macName = Host.current().name ?? "Unknown Mac Devices"
132132
name = macName
133133
model = "\(macName) \(ProcessInfo.processInfo.operatingSystemVersionString)"
134-
#elseif os(iOS)
134+
#elseif os(iOS) || targetEnvironment(macCatalyst)
135135
let device = UIDevice.current
136136
name = device.name
137137
model = "\(device.name) (\(device.systemName) \(device.systemVersion))"
@@ -236,9 +236,14 @@ extension Image {
236236
static var appIcon: Image? {
237237
#if os(OSX)
238238
return NSApplication.shared.applicationIconImage
239+
#elseif targetEnvironment(macCatalyst)
240+
guard let iconName = Bundle.main.infoDictionary?["CFBundleIconFile"] as? String else {
241+
return nil
242+
}
243+
return Image(named: iconName)
239244
#elseif os(iOS)
240-
guard let iconsDictionary = Bundle.main.infoDictionary?["CFBundleIcons"] as? [String:Any],
241-
let primaryIconsDictionary = iconsDictionary["CFBundlePrimaryIcon"] as? [String:Any],
245+
guard let iconsDictionary = Bundle.main.infoDictionary?["CFBundleIcons"] as? [String: Any],
246+
let primaryIconsDictionary = iconsDictionary["CFBundlePrimaryIcon"] as? [String: Any],
242247
let iconFiles = primaryIconsDictionary["CFBundleIconFiles"] as? [String],
243248
let lastIcon = iconFiles.last else { return nil }
244249
return Image(named: lastIcon)
@@ -252,7 +257,7 @@ extension Image {
252257
// Resize, we don't need 1024px size
253258
newRep.size = CGSize(width: 64, height: 64)
254259
return newRep.representation(using: .png, properties: [:])
255-
#elseif os(iOS)
260+
#elseif os(iOS) || targetEnvironment(macCatalyst)
256261
// It's already by 64px
257262
return self.pngData()
258263
#endif

0 commit comments

Comments
 (0)