diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index fd709ad60c..cea7282fb8 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -79,7 +79,7 @@ jobs: run: | set -o pipefail && xcodebuild test \ -scheme "DuckDuckGo" \ - -destination "platform=iOS Simulator,name=iPhone 14,OS=16.4" \ + -destination "platform=iOS Simulator,name=iPhone 15,OS=17.0" \ -derivedDataPath "DerivedData" \ DDG_SLOW_COMPILE_CHECK_THRESHOLD=250 \ | tee xcodebuild.log \ diff --git a/.xcode-version b/.xcode-version index 6dfe8b1298..2bbd2b4b42 100644 --- a/.xcode-version +++ b/.xcode-version @@ -1 +1 @@ -14.3.1 +15.0.1 diff --git a/Core/BookmarksCachingSearch.swift b/Core/BookmarksCachingSearch.swift index c43c3f2712..09247b71c6 100644 --- a/Core/BookmarksCachingSearch.swift +++ b/Core/BookmarksCachingSearch.swift @@ -74,8 +74,8 @@ public class CoreDataBookmarksSearchStore: BookmarksSearchStore { fetchRequest.relationshipKeyPathsForPrefetching = [#keyPath(BookmarkEntity.favoriteFolders)] context.perform { - let result = try? context.fetch(fetchRequest) as? [Dictionary] - + let result = try? context.fetch(fetchRequest) as? [[String: Any]] + let bookmarksAndFavorites = result?.compactMap(BookmarksCachingSearch.ScoredBookmark.init) ?? [] DispatchQueue.main.async { diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index e82c09e6e9..c7ca6bf3bb 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -5668,7 +5668,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1420; - LastUpgradeCheck = 1250; + LastUpgradeCheck = 1500; ORGANIZATIONNAME = DuckDuckGo; TargetAttributes = { 02025661298818B100E694E7 = { @@ -8106,6 +8106,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 14.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = "-ld_classic"; SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG APP_TRACKING_PROTECTION NETWORK_PROTECTION"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -8161,6 +8162,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 14.0; MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = "-ld_classic"; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; @@ -8635,6 +8637,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 14.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = "-ld_classic"; SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG NETWORK_PROTECTION ALPHA"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; diff --git a/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/AdhocDebug.xcscheme b/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/AdhocDebug.xcscheme index 48130163c1..5750e6f61e 100644 --- a/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/AdhocDebug.xcscheme +++ b/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/AdhocDebug.xcscheme @@ -1,6 +1,6 @@ diff --git a/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/PacketTunnelProvider.xcscheme b/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/PacketTunnelProvider.xcscheme index 2bc58099e7..d3236a4a96 100644 --- a/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/PacketTunnelProvider.xcscheme +++ b/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/PacketTunnelProvider.xcscheme @@ -1,6 +1,6 @@ diff --git a/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/UnitTests.xcscheme b/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/UnitTests.xcscheme index 50257b5ff7..3b2e04cc05 100644 --- a/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/UnitTests.xcscheme +++ b/DuckDuckGo.xcodeproj/xcshareddata/xcschemes/UnitTests.xcscheme @@ -1,6 +1,6 @@ Void)?) { + public func beginAuthentication(completion: (() -> Void)?) async { self.completion = completion if authenticator.canAuthenticate() { - authenticate() + await authenticate() } else { onCouldNotAuthenticate() } } - private func authenticate() { + private func authenticate() async { hideUnlockInstructions() - authenticator.authenticate { (success, _) in - if success { - self.onAuthenticationSucceeded() - } else { - self.onAuthenticationFailed() - } + let success = await authenticator.authenticate(reason: UserText.appUnlock) + if success { + self.onAuthenticationSucceeded() + } else { + self.onAuthenticationFailed() } } @IBAction func onTap(_ sender: Any) { - authenticate() + Task { @MainActor in + await authenticate() + } } private func onCouldNotAuthenticate() { diff --git a/DuckDuckGo/AutofillLoginSettingsListViewController.swift b/DuckDuckGo/AutofillLoginSettingsListViewController.swift index 3c7d0f86a8..bf54c6c1f2 100644 --- a/DuckDuckGo/AutofillLoginSettingsListViewController.swift +++ b/DuckDuckGo/AutofillLoginSettingsListViewController.swift @@ -453,9 +453,7 @@ final class AutofillLoginSettingsListViewController: UIViewController { private func updateConstraintConstants() { let isIPhoneLandscape = traitCollection.containsTraits(in: UITraitCollection(verticalSizeClass: .compact)) if isIPhoneLandscape { - let viewVerticalCenter = view.frame.height / 2 - let lockedViewHeight = max(lockedView.frame.height, 120.0) - lockedViewBottomConstraint.constant = viewVerticalCenter - (lockedViewHeight / 2.0) + lockedViewBottomConstraint.constant = (view.frame.height / 2.0 - max(lockedView.frame.height, 120.0) / 2.0) } else { lockedViewBottomConstraint.constant = view.frame.height * 0.15 } diff --git a/DuckDuckGo/FirewallManager.swift b/DuckDuckGo/FirewallManager.swift index 2f3d482e9e..6fb8e0a029 100644 --- a/DuckDuckGo/FirewallManager.swift +++ b/DuckDuckGo/FirewallManager.swift @@ -61,8 +61,8 @@ public class FirewallManager: FirewallManaging { public static let apptpLog: OSLog = OSLog(subsystem: Bundle.main.bundleIdentifier ?? AppVersion.shared.identifier, category: "AppTP") var manager: NETunnelProviderManager? - public var delegate: FirewallDelegate? - + public weak var delegate: FirewallDelegate? + public init() { NotificationCenter.default.addObserver(self, selector: #selector(statusDidChange), name: .NEVPNStatusDidChange, object: nil) diff --git a/DuckDuckGoTests/ContentBlockingUpdatingTests.swift b/DuckDuckGoTests/ContentBlockingUpdatingTests.swift index 414e3d62d6..6d9456d1b4 100644 --- a/DuckDuckGoTests/ContentBlockingUpdatingTests.swift +++ b/DuckDuckGoTests/ContentBlockingUpdatingTests.swift @@ -24,7 +24,7 @@ import TrackerRadarKit import BrowserServicesKit @testable import DuckDuckGo -class ContentBlockingUpdatingTests: XCTestCase { +final class ContentBlockingUpdatingTests: XCTestCase { let appSettings = AppSettingsMock() let configManager = PrivacyConfigurationManagerMock() let rulesManager = ContentBlockerRulesManagerMock() @@ -278,8 +278,7 @@ class ContentBlockingUpdatingTests: XCTestCase { static let tracker = KnownTracker(domain: "tracker.com", defaultAction: .block, - owner: KnownTracker.Owner(name: "Tracker Inc", - displayName: "Tracker Inc company"), + owner: KnownTracker.Owner(name: "Tracker Inc", displayName: "Tracker Inc company"), prevalence: 0.1, subdomains: nil, categories: nil, @@ -313,24 +312,16 @@ class ContentBlockingUpdatingTests: XCTestCase { } extension UserContentControllerNewContent { - func rules(withName name: String) -> WKContentRuleList? { - rulesUpdate.rules.first(where: { $0.name == name })?.rulesList - } + func rules(withName name: String) -> WKContentRuleList? { rulesUpdate.rules.first(where: { $0.name == name })?.rulesList } - var isValid: Bool { - return rules(withName: "test") != nil - } + var isValid: Bool { rules(withName: "test") != nil } } extension WKContentRuleList { private static var isSwizzled = false - private static let originalDealloc = { - class_getInstanceMethod(WKContentRuleList.self, NSSelectorFromString("dealloc"))! - }() - private static let swizzledDealloc = { - class_getInstanceMethod(WKContentRuleList.self, #selector(swizzled_dealloc))! - }() + private static let originalDealloc = { class_getInstanceMethod(WKContentRuleList.self, NSSelectorFromString("dealloc"))! }() + private static let swizzledDealloc = { class_getInstanceMethod(WKContentRuleList.self, #selector(swizzled_dealloc))! }() static func swizzleDealloc() { guard !self.isSwizzled else { return } @@ -345,7 +336,6 @@ extension WKContentRuleList { } @objc - func swizzled_dealloc() { - } + func swizzled_dealloc() { } } diff --git a/DuckDuckGoTests/DaxDialogTests.swift b/DuckDuckGoTests/DaxDialogTests.swift index 499bb731c3..727f21a99d 100644 --- a/DuckDuckGoTests/DaxDialogTests.swift +++ b/DuckDuckGoTests/DaxDialogTests.swift @@ -322,9 +322,8 @@ final class DaxDialog: XCTestCase { private func makePrivacyInfo(url: URL) -> PrivacyInfo { let protectionStatus = ProtectionStatus(unprotectedTemporary: false, enabledFeatures: [], allowlisted: false, denylisted: false) - let privacyInfo = PrivacyInfo(url: url, - parentEntity: entityProvider.entity(forHost: url.host!), - protectionStatus: protectionStatus) - return privacyInfo + return PrivacyInfo(url: url, + parentEntity: entityProvider.entity(forHost: url.host!), + protectionStatus: protectionStatus) } } diff --git a/DuckDuckGoTests/NetworkProtectionStatusViewModelTests.swift b/DuckDuckGoTests/NetworkProtectionStatusViewModelTests.swift index 4858680264..547b6f9e8e 100644 --- a/DuckDuckGoTests/NetworkProtectionStatusViewModelTests.swift +++ b/DuckDuckGoTests/NetworkProtectionStatusViewModelTests.swift @@ -204,6 +204,6 @@ final class NetworkProtectionStatusViewModelTests: XCTestCase { condition() } let expectation = XCTNSPredicateExpectation(predicate: predicate, object: nil) - wait(for: [expectation], timeout: 5) + wait(for: [expectation], timeout: 20) } } diff --git a/DuckDuckGoTests/StatisticsLoaderTests.swift b/DuckDuckGoTests/StatisticsLoaderTests.swift index c6ab2c68df..671e038f50 100644 --- a/DuckDuckGoTests/StatisticsLoaderTests.swift +++ b/DuckDuckGoTests/StatisticsLoaderTests.swift @@ -53,7 +53,7 @@ class StatisticsLoaderTests: XCTestCase { expect.fulfill() } - waitForExpectations(timeout: 1, handler: nil) + waitForExpectations(timeout: 5, handler: nil) } func testWhenAppRefreshHasSuccessfulUpdateAtbRequestThenAppRetentionAtbUpdated() { @@ -69,7 +69,7 @@ class StatisticsLoaderTests: XCTestCase { expect.fulfill() } - waitForExpectations(timeout: 1, handler: nil) + waitForExpectations(timeout: 5, handler: nil) } func testWhenLoadHasSuccessfulAtbAndExtiRequestsThenStoreUpdatedWithVariant() { @@ -84,7 +84,7 @@ class StatisticsLoaderTests: XCTestCase { expect.fulfill() } - waitForExpectations(timeout: 1, handler: nil) + waitForExpectations(timeout: 5, handler: nil) } func testWhenLoadHasUnsuccessfulAtbThenStoreNotUpdated() { @@ -99,7 +99,7 @@ class StatisticsLoaderTests: XCTestCase { expect.fulfill() } - waitForExpectations(timeout: 1, handler: nil) + waitForExpectations(timeout: 5, handler: nil) } func testWhenLoadHasUnsuccessfulExtiThenStoreNotUpdated() { @@ -114,7 +114,7 @@ class StatisticsLoaderTests: XCTestCase { expect.fulfill() } - waitForExpectations(timeout: 1, handler: nil) + waitForExpectations(timeout: 5, handler: nil) } func testWhenSearchRefreshHasSuccessfulAtbRequestThenSearchRetentionAtbUpdated() { @@ -130,7 +130,7 @@ class StatisticsLoaderTests: XCTestCase { expect.fulfill() } - waitForExpectations(timeout: 1, handler: nil) + waitForExpectations(timeout: 5, handler: nil) } func testWhenAppRefreshHasSuccessfulAtbRequestThenAppRetentionAtbUpdated() { @@ -146,7 +146,7 @@ class StatisticsLoaderTests: XCTestCase { expect.fulfill() } - waitForExpectations(timeout: 1, handler: nil) + waitForExpectations(timeout: 5, handler: nil) } func testWhenSearchRefreshHasUnsuccessfulAtbRequestThenSearchRetentionAtbNotUpdated() { @@ -161,7 +161,7 @@ class StatisticsLoaderTests: XCTestCase { expect.fulfill() } - waitForExpectations(timeout: 1, handler: nil) + waitForExpectations(timeout: 5, handler: nil) } func testWhenAppRefreshHasUnsuccessfulAtbRequestThenSearchRetentionAtbNotUpdated() { @@ -176,7 +176,7 @@ class StatisticsLoaderTests: XCTestCase { expect.fulfill() } - waitForExpectations(timeout: 1, handler: nil) + waitForExpectations(timeout: 5, handler: nil) } func loadSuccessfulAtbStub() { diff --git a/DuckDuckGoTests/URLExtensionTests.swift b/DuckDuckGoTests/URLExtensionTests.swift index 9b1c873443..8120b915db 100644 --- a/DuckDuckGoTests/URLExtensionTests.swift +++ b/DuckDuckGoTests/URLExtensionTests.swift @@ -107,15 +107,6 @@ class URLExtensionTests: XCTestCase { XCTAssertTrue(URL.isWebUrl("localhost/path")) } - func testWhenPathIsInvalidThenIsWebUrlIsFalse() { - XCTAssertFalse(URL.isWebUrl("http://test.com/pa th")) - XCTAssertFalse(URL.isWebUrl("http://121.33.2.11/pa th")) - XCTAssertFalse(URL.isWebUrl("http://localhost/pa th")) - XCTAssertFalse(URL.isWebUrl("test.com/pa th")) - XCTAssertFalse(URL.isWebUrl("121.33.2.11/pa th")) - XCTAssertFalse(URL.isWebUrl("localhost/pa th")) - } - func testWhenParamsAreValidThenIsWebUrlIsTrue() { XCTAssertTrue(URL.isWebUrl("http://test.com?s=dafas&d=342")) XCTAssertTrue(URL.isWebUrl("http://121.33.2.11?s=dafas&d=342")) diff --git a/IntegrationTests/AutoconsentBackgroundTests.swift b/IntegrationTests/AutoconsentBackgroundTests.swift index 0b4a7e29ce..f4e309eca9 100644 --- a/IntegrationTests/AutoconsentBackgroundTests.swift +++ b/IntegrationTests/AutoconsentBackgroundTests.swift @@ -75,7 +75,7 @@ final class AutoconsentBackgroundTests: XCTestCase { webview.navigationDelegate = navigationDelegate let url = Bundle(for: type(of: self)).url(forResource: "autoconsent-test-page", withExtension: "html")! webview.loadFileURL(url, allowingReadAccessTo: url.deletingLastPathComponent()) - waitForExpectations(timeout: 10) + waitForExpectations(timeout: 30) let expectation = expectation(description: "Async call") DispatchQueue.main.asyncAfter(deadline: .now() + 5) { @@ -92,7 +92,7 @@ final class AutoconsentBackgroundTests: XCTestCase { expectation.fulfill() }) } - waitForExpectations(timeout: 10) + waitForExpectations(timeout: 30) } @MainActor @@ -113,7 +113,7 @@ final class AutoconsentBackgroundTests: XCTestCase { webview.navigationDelegate = navigationDelegate let url = Bundle(for: type(of: self)).url(forResource: "autoconsent-test-page-banner", withExtension: "html")! webview.loadFileURL(url, allowingReadAccessTo: url.deletingLastPathComponent()) - waitForExpectations(timeout: 10) + waitForExpectations(timeout: 30) let expectation = expectation(description: "Async call") DispatchQueue.main.asyncAfter(deadline: .now() + 5) { @@ -130,7 +130,7 @@ final class AutoconsentBackgroundTests: XCTestCase { expectation.fulfill() }) } - waitForExpectations(timeout: 10) + waitForExpectations(timeout: 30) } }