From 31d63f40b039ff2d9790d15b7de5c7badcfb1d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 18 Jun 2024 08:43:41 +0800 Subject: [PATCH] Fix build with xcode 16 beta --- .../Service/UIProfileUpdateTask.swift | 35 ++++++++----------- SFI/ApplicationDelegate.swift | 16 ++++----- SFT/ApplicationDelegate.swift | 8 ++--- sing-box.xcodeproj/project.pbxproj | 17 --------- .../xcshareddata/swiftpm/Package.resolved | 12 ++----- 5 files changed, 28 insertions(+), 60 deletions(-) diff --git a/ApplicationLibrary/Service/UIProfileUpdateTask.swift b/ApplicationLibrary/Service/UIProfileUpdateTask.swift index ea2269d..4fde2a7 100644 --- a/ApplicationLibrary/Service/UIProfileUpdateTask.swift +++ b/ApplicationLibrary/Service/UIProfileUpdateTask.swift @@ -9,21 +9,21 @@ import Library public class UIProfileUpdateTask: BGAppRefreshTask { private static let taskSchedulerPermittedIdentifier = "\(FilePath.packageName).update_profiles" - private actor Register { - private var registered = false - func configure() async throws { - if !registered { - let success = BGTaskScheduler.shared.register(forTaskWithIdentifier: taskSchedulerPermittedIdentifier, using: nil) { task in - NSLog("profile update task started") - Task { - await UIProfileUpdateTask.getAndUpdateProfiles(task) - } + private static var registered = false + public static func configure() throws { + if !registered { + let success = BGTaskScheduler.shared.register(forTaskWithIdentifier: taskSchedulerPermittedIdentifier, using: nil) { task in + NSLog("profile update task started") + Task { + await UIProfileUpdateTask.getAndUpdateProfiles(task) } - if !success { - throw NSError(domain: "register failed", code: 0) - } - registered = true } + if !success { + throw NSError(domain: "register task failed", code: 0) + } + registered = true + } + Task { BGTaskScheduler.shared.cancelAllTaskRequests() let profiles = try await ProfileManager.listAutoUpdateEnabled() if profiles.isEmpty { @@ -31,13 +31,8 @@ import Library } try scheduleUpdate(ProfileUpdateTask.calculateEarliestBeginDate(profiles)) } - } - - private static let register = Register() - public static func configure() async throws { - try await register.configure() - if await UIApplication.shared.backgroundRefreshStatus != .available { - Task { + Task { + if await UIApplication.shared.backgroundRefreshStatus != .available { await updateOnce() } } diff --git a/SFI/ApplicationDelegate.swift b/SFI/ApplicationDelegate.swift index 21f0dbe..0120242 100644 --- a/SFI/ApplicationDelegate.swift +++ b/SFI/ApplicationDelegate.swift @@ -11,23 +11,23 @@ class ApplicationDelegate: NSObject, UIApplicationDelegate { func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { NSLog("Here I stand") LibboxSetup(FilePath.sharedDirectory.relativePath, FilePath.workingDirectory.relativePath, FilePath.cacheDirectory.relativePath, false) - Task { - await setup() - } + setup() return true } - private func setup() async { + private func setup() { do { - try await UIProfileUpdateTask.configure() + try UIProfileUpdateTask.configure() NSLog("setup background task success") } catch { NSLog("setup background task error: \(error.localizedDescription)") } - if UIDevice.current.userInterfaceIdiom == .phone { - await requestNetworkPermission() + Task { + if UIDevice.current.userInterfaceIdiom == .phone { + await requestNetworkPermission() + } + await setupBackground() } - await setupBackground() } private nonisolated func setupBackground() async { diff --git a/SFT/ApplicationDelegate.swift b/SFT/ApplicationDelegate.swift index 9fd4cd8..2c1fc83 100644 --- a/SFT/ApplicationDelegate.swift +++ b/SFT/ApplicationDelegate.swift @@ -8,15 +8,13 @@ class ApplicationDelegate: NSObject, UIApplicationDelegate { func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { NSLog("Here I stand") LibboxSetup(FilePath.sharedDirectory.relativePath, FilePath.workingDirectory.relativePath, FilePath.cacheDirectory.relativePath, true) - Task { - await setup() - } + setup() return true } - private func setup() async { + private func setup() { do { - try await UIProfileUpdateTask.configure() + try UIProfileUpdateTask.configure() NSLog("setup background task success") } catch { NSLog("setup background task error: \(error.localizedDescription)") diff --git a/sing-box.xcodeproj/project.pbxproj b/sing-box.xcodeproj/project.pbxproj index 10bdd39..0f13cd8 100644 --- a/sing-box.xcodeproj/project.pbxproj +++ b/sing-box.xcodeproj/project.pbxproj @@ -70,7 +70,6 @@ 3A648D2D2A4EEAA600D95A12 /* Library.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A648D2C2A4EEAA600D95A12 /* Library.swift */; }; 3A648D542A4EF4C700D95A12 /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AF342B12A4AA520002B34AC /* NetworkExtension.framework */; }; 3A6CA4542BC19FDE0012B238 /* OnDemandRulesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A6CA4532BC19FDE0012B238 /* OnDemandRulesView.swift */; }; - 3A6CA5A02A71317A0027933B /* MarkdownUI in Frameworks */ = {isa = PBXBuildFile; productRef = 3A6CA59F2A71317A0027933B /* MarkdownUI */; }; 3A6CA5A32A713A580027933B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3AEECC0A2A6DF9CA006A0E0C /* Assets.xcassets */; }; 3A6CA5A62A713AA10027933B /* AppIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 3A6CA5A52A713AA10027933B /* AppIcon.icns */; }; 3A6CA5A72A713ABA0027933B /* AppIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 3A6CA5A52A713AA10027933B /* AppIcon.icns */; }; @@ -587,7 +586,6 @@ buildActionMask = 2147483647; files = ( 3A4EAD1B2A4FEB02005435B3 /* Library.framework in Frameworks */, - 3A6CA5A02A71317A0027933B /* MarkdownUI in Frameworks */, 3A4A020D2B53E3DC004EFB87 /* QRCode in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1088,7 +1086,6 @@ ); name = ApplicationLibrary; packageProductDependencies = ( - 3A6CA59F2A71317A0027933B /* MarkdownUI */, 3A4A020C2B53E3DC004EFB87 /* QRCode */, ); productName = ApplicationLibrary; @@ -1356,7 +1353,6 @@ 3A7E90362A46778E00D53052 /* XCRemoteSwiftPackageReference "BinaryCodable" */, 3A017F902A4AB2E4009149FA /* XCRemoteSwiftPackageReference "GRDB" */, 3A57DF3A2A4D705000690BC5 /* XCRemoteSwiftPackageReference "MacControlCenterUI" */, - 3ADB2D832A71266E00A6517D /* XCRemoteSwiftPackageReference "swift-markdown-ui" */, 3A4A020B2B53E3DC004EFB87 /* XCRemoteSwiftPackageReference "qrcode" */, ); productRefGroup = 3AEC20C72A45991900A63465 /* Products */; @@ -2893,14 +2889,6 @@ minimumVersion = 2.0.0; }; }; - 3ADB2D832A71266E00A6517D /* XCRemoteSwiftPackageReference "swift-markdown-ui" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/gonzalezreal/swift-markdown-ui"; - requirement = { - kind = upToNextMajorVersion; - minimumVersion = 2.1.0; - }; - }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -2914,11 +2902,6 @@ package = 3A4A020B2B53E3DC004EFB87 /* XCRemoteSwiftPackageReference "qrcode" */; productName = QRCode; }; - 3A6CA59F2A71317A0027933B /* MarkdownUI */ = { - isa = XCSwiftPackageProductDependency; - package = 3ADB2D832A71266E00A6517D /* XCRemoteSwiftPackageReference "swift-markdown-ui" */; - productName = MarkdownUI; - }; 3A7E90372A46778E00D53052 /* BinaryCodable */ = { isa = XCSwiftPackageProductDependency; package = 3A7E90362A46778E00D53052 /* XCRemoteSwiftPackageReference "BinaryCodable" */; diff --git a/sing-box.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/sing-box.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 029a589..6c91f1e 100644 --- a/sing-box.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/sing-box.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,4 +1,5 @@ { + "originHash" : "82fb479ec8c73c3348b93e33a9102fc692bb5a0a0d6f14beb4c5f31445c36e81", "pins" : [ { "identity" : "binarycodable", @@ -45,15 +46,6 @@ "version" : "17.0.0" } }, - { - "identity" : "swift-markdown-ui", - "kind" : "remoteSourceControl", - "location" : "https://github.com/gonzalezreal/swift-markdown-ui", - "state" : { - "revision" : "12b351a75201a8124c2f2e1f9fc6ef5cd812c0b9", - "version" : "2.1.0" - } - }, { "identity" : "swift-qrcode-generator", "kind" : "remoteSourceControl", @@ -73,5 +65,5 @@ } } ], - "version" : 2 + "version" : 3 }