Skip to content

Commit

Permalink
New deployment target set to 11.4 (#1592)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/0/1204736441183124/f

**Description**:
This PR adjusts deployment target to macOS 11.4 and removes unnecessary
code required for support of older macOS versions.
  • Loading branch information
tomasstrba authored Sep 10, 2023
1 parent d7e5bed commit bb74fca
Show file tree
Hide file tree
Showing 113 changed files with 296 additions and 1,418 deletions.
2 changes: 1 addition & 1 deletion Configuration/Common.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ GCC_PREPROCESSOR_DEFINITIONS[config=CI][arch=*][sdk=*] = DEBUG=1 CI=1 $(inherite
GCC_PREPROCESSOR_DEFINITIONS[config=Debug][arch=*][sdk=*] = DEBUG=1 $(inherited)
GCC_PREPROCESSOR_DEFINITIONS[config=Review][arch=*][sdk=*] = REVIEW=1 $(inherited)

MACOSX_DEPLOYMENT_TARGET = 10.15.4
MACOSX_DEPLOYMENT_TARGET = 11.4

PRODUCT_MODULE_NAME = $(TARGET_NAME:c99extidentifier)

Expand Down
2 changes: 1 addition & 1 deletion Configuration/Tests/IntegrationTests.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "TestsTargetsBase.xcconfig"

MACOSX_DEPLOYMENT_TARGET = 11.1
MACOSX_DEPLOYMENT_TARGET = 11.4

FEATURE_FLAGS = FEEDBACK NETWORK_PROTECTION

Expand Down
2 changes: 1 addition & 1 deletion Configuration/UITests/UITests.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CODE_SIGN_IDENTITY[config=CI][sdk=macosx*] =

DEAD_CODE_STRIPPING = YES

MACOSX_DEPLOYMENT_TARGET = 11.3
MACOSX_DEPLOYMENT_TARGET = 11.4

INFOPLIST_FILE = UI Tests/Info.plist
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.UI-Tests
Expand Down
60 changes: 7 additions & 53 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

19 changes: 2 additions & 17 deletions DuckDuckGo/AppDelegate/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel
UserDefaultsWrapper<Any>.clearRemovedKeys()

#if NETWORK_PROTECTION
if #available(macOS 11.4, *) {
/// Once we drop support for macOS versions below 11.4, we can turn `NetworkProtectionAppEvents`
/// into a property. Right now it's easier to avoid it since we can't place macOS version conditions on properties.
///
/// In any case this is not going to happen on a high frequency and should not affect performance in any relevant
/// way.
NetworkProtectionAppEvents().applicationDidFinishLaunching()
}

NetworkProtectionAppEvents().applicationDidFinishLaunching()
UNUserNotificationCenter.current().delegate = self
#endif

Expand All @@ -232,14 +224,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel
// Do nothing when code fetching fails, as the app will try again later
}

if #available(macOS 11.4, *) {
/// Once we drop support for macOS versions below 11.4, we can turn `NetworkProtectionAppEvents`
/// into a property. Right now it's easier to avoid it since we can't place macOS version conditions on properties.
///
/// In any case this is not going to happen on a high frequency and should not affect performance in any relevant
/// way.
NetworkProtectionAppEvents().applicationDidBecomeActive()
}
NetworkProtectionAppEvents().applicationDidBecomeActive()
#endif
}

Expand Down
3 changes: 0 additions & 3 deletions DuckDuckGo/Autoconsent/AutoconsentUserScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ protocol UserScriptWithAutoconsent: UserScript {
var delegate: AutoconsentUserScriptDelegate? { get set }
}

@available(macOS 11, *)
final class AutoconsentUserScript: NSObject, WKScriptMessageHandlerWithReply, UserScriptWithAutoconsent {
var injectionTime: WKUserScriptInjectionTime { .atDocumentStart }
var forMainFrameOnly: Bool { false }
Expand Down Expand Up @@ -79,7 +78,6 @@ final class AutoconsentUserScript: NSObject, WKScriptMessageHandlerWithReply, Us
}
}

@available(macOS 11, *)
extension AutoconsentUserScript {
enum MessageName: String, CaseIterable {
case `init`
Expand Down Expand Up @@ -157,7 +155,6 @@ extension AutoconsentUserScript {
}
}

@available(macOS 11, *)
extension AutoconsentUserScript {
@MainActor
func handleMessage(replyHandler: @escaping (Any?, String?) -> Void,
Expand Down
12 changes: 4 additions & 8 deletions DuckDuckGo/Autoconsent/UI/CookieConsentUserPermissionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,10 @@ struct CookieConsentUserPermissionView_Previews: PreviewProvider {
static var previews: some View {
let result: (Bool) -> Void = { _ in }

if #available(macOS 11.0, *) {
CookieConsentUserPermissionView(sketchAnimationModel: CookieConsentAnimationMock(), type: .site, result: result).preferredColorScheme(.dark)
.padding()
CookieConsentUserPermissionView(sketchAnimationModel: CookieConsentAnimationMock(), type: .site, result: result).preferredColorScheme(.light)
.padding()
} else {
CookieConsentUserPermissionView(sketchAnimationModel: CookieConsentAnimationMock(), type: .site, result: result)
}
CookieConsentUserPermissionView(sketchAnimationModel: CookieConsentAnimationMock(), type: .site, result: result).preferredColorScheme(.dark)
.padding()
CookieConsentUserPermissionView(sketchAnimationModel: CookieConsentAnimationMock(), type: .site, result: result).preferredColorScheme(.light)
.padding()
}
}

Expand Down
8 changes: 8 additions & 0 deletions DuckDuckGo/Bookmarks/Extensions/NSPopUpButtonExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@ extension NSPopUpButton {
selectItem(withTitle: title)
}

@discardableResult
func addItem(withTitle title: String, representedObject: Any?) -> NSMenuItem {
self.addItem(withTitle: title)
let item = self.item(at: self.numberOfItems - 1)!
item.representedObject = representedObject
return item
}

}
1 change: 0 additions & 1 deletion DuckDuckGo/Bookmarks/View/BookmarkListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ final class BookmarkListViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()

view.subscribeForAppApperanceUpdates()?.store(in: &cancellables)
preferredContentSize = CGSize(width: 420, height: 500)

outlineView.register(BookmarkOutlineViewCell.nib, forIdentifier: BookmarkOutlineViewCell.identifier)
Expand Down
3 changes: 0 additions & 3 deletions DuckDuckGo/Bookmarks/View/BookmarkPopoverViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,9 @@ final class BookmarkPopoverViewController: NSViewController {
}
}

private var appearanceCancellable: AnyCancellable?

override func viewDidLoad() {
super.viewDidLoad()

appearanceCancellable = view.subscribeForAppApperanceUpdates()
textField.delegate = self

folderPickerSelectionCancellable = folderPickerPopUpButton.selectionPublisher.dropFirst().sink { [weak self] index in
Expand Down
3 changes: 0 additions & 3 deletions DuckDuckGo/Bookmarks/View/BookmarkTableRowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ final class BookmarkTableRowView: NSTableRowView {
}

override var interiorBackgroundStyle: NSView.BackgroundStyle {
if #unavailable(macOS 11.0) {
return .light
}
return .normal
}

Expand Down
3 changes: 0 additions & 3 deletions DuckDuckGo/Bookmarks/View/RoundedSelectionRowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ final class RoundedSelectionRowView: NSTableRowView {
}

override var interiorBackgroundStyle: NSView.BackgroundStyle {
if #unavailable(macOS 11.0) {
return .light
}
return .normal
}

Expand Down
4 changes: 0 additions & 4 deletions DuckDuckGo/Bridging.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@

#import "WKWebView+Private.h"
#import "NSException+Catch.h"
#import "WKNavigationAction+Private.h"

#import "WKGeolocationProvider.h"

#ifndef APPSTORE
#import "_WKDownload.h"
#import "WKProcessPool+Private.h"
#import "BWEncryption.h"
#import "PFMoveApplication.h"
#endif
9 changes: 1 addition & 8 deletions DuckDuckGo/Common/Extensions/NSAppearanceExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ import Cocoa

extension NSAppearance {
static func withAppAppearance(_ closure: () -> Void) {
if #available(macOS 11.0, *) {
NSApp.effectiveAppearance.performAsCurrentDrawingAppearance(closure)
} else {
let previousAppearance = NSAppearance.current
NSAppearance.current = NSApp.effectiveAppearance
closure()
NSAppearance.current = previousAppearance
}
NSApp.effectiveAppearance.performAsCurrentDrawingAppearance(closure)
}
}
7 changes: 1 addition & 6 deletions DuckDuckGo/Common/Extensions/NSOpenPanelExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ extension NSOpenPanel {

panel.directoryURL = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent("Desktop")
panel.canChooseFiles = true
if #available(macOS 11.0, *) {
panel.allowedContentTypes = [UniformTypeIdentifiers.UTType.init(filenameExtension: allowedExtension)].compactMap { $0 }
} else {
panel.allowedFileTypes = [allowedExtension]
}

panel.allowedContentTypes = UTType(filenameExtension: allowedExtension).map { [$0] } ?? []
panel.canChooseDirectories = false

return panel
Expand Down
28 changes: 1 addition & 27 deletions DuckDuckGo/Common/Extensions/NSViewExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extension NSView {

func applyDropShadow() {
wantsLayer = true
layer?.shadowColor = NSColor.controlShadowColor.cgColor
layer?.shadowColor = NSColor.black.withAlphaComponent(0.2).cgColor
layer?.shadowOpacity = 1.0
layer?.masksToBounds = false
}
Expand Down Expand Up @@ -146,30 +146,4 @@ extension NSView {
layer?.cornerRadius = 3.0
}

// MARK: - Appearance updates

/**
* Sets current app appearance to the view and subscribes for subsequent updates.
*
* This is needed on Catalina for views displayed in popovers that have custom, opaque backgrounds.
* Presentation in popover overrides view appearance to `.vibrantLight` or `.vibrantDark`, which
* makes subviews such as `NSTextField` and `NSButton` draw their backgrounds with vibrancy effect,
* which in turn removes opaque background locally. Calling this method on the top-level view seems
* to be solving the issue.
*
* See [](https://app.asana.com/0/1177771139624306/1202121324275642/f) for an example screenshot.
*/
func subscribeForAppApperanceUpdates() -> AnyCancellable? {
if #available(macOS 11.0, *) {
return nil
}

appearance = NSApp.effectiveAppearance

return NSApp
.publisher(for: \.effectiveAppearance)
.map { $0 as NSAppearance? }
.assign(to: \.appearance, onWeaklyHeld: self)
}

}
7 changes: 6 additions & 1 deletion DuckDuckGo/Common/Extensions/StringExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import Foundation
import BrowserServicesKit
import UniformTypeIdentifiers

extension String {

Expand Down Expand Up @@ -73,13 +74,17 @@ extension String {
static func uniqueFilename(for fileType: UTType? = nil) -> String {
let fileName = UUID().uuidString

if let ext = fileType?.fileExtension {
if let ext = fileType?.preferredFilenameExtension {
return fileName.appending("." + ext)
}

return fileName
}

var pathExtension: String {
(self as NSString).pathExtension
}

// MARK: - Mutating

@inlinable mutating func prepend(_ string: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,19 @@ extension WKUserContentController {

func addHandler(_ userScript: UserScript) {
for messageName in userScript.messageNames {
if #available(macOS 11.0, *) {
let contentWorld: WKContentWorld = userScript.getContentWorld()
if let handlerWithReply = userScript as? WKScriptMessageHandlerWithReply {
addScriptMessageHandler(handlerWithReply, contentWorld: contentWorld, name: messageName)
} else {
add(userScript, contentWorld: contentWorld, name: messageName)
}
let contentWorld: WKContentWorld = userScript.getContentWorld()
if let handlerWithReply = userScript as? WKScriptMessageHandlerWithReply {
addScriptMessageHandler(handlerWithReply, contentWorld: contentWorld, name: messageName)
} else {
add(userScript, name: messageName)
add(userScript, contentWorld: contentWorld, name: messageName)
}
}
}

func removeHandler(_ userScript: UserScript) {
userScript.messageNames.forEach {
if #available(macOS 11.0, *) {
let contentWorld: WKContentWorld = userScript.getContentWorld()
removeScriptMessageHandler(forName: $0, contentWorld: contentWorld)
} else {
removeScriptMessageHandler(forName: $0)
}
let contentWorld: WKContentWorld = userScript.getContentWorld()
removeScriptMessageHandler(forName: $0, contentWorld: contentWorld)
}
}

Expand Down
26 changes: 8 additions & 18 deletions DuckDuckGo/Common/Extensions/WKWebView+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// limitations under the License.
//
#import <WebKit/WebKit.h>
#import "_WKDownload.h"

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -27,19 +26,20 @@ typedef NS_OPTIONS(NSUInteger, _WKMediaCaptureStateDeprecated) {
_WKMediaCaptureStateDeprecatedActiveCamera = 1 << 1,
_WKMediaCaptureStateDeprecatedMutedMicrophone = 1 << 2,
_WKMediaCaptureStateDeprecatedMutedCamera = 1 << 3,
};
} API_AVAILABLE(macos(10.13), ios(11.0));

typedef NS_OPTIONS(NSUInteger, _WKMediaMutedState) {
_WKMediaNoneMuted = 0,
_WKMediaAudioMuted = 1 << 0,
_WKMediaCaptureDevicesMuted = 1 << 1,
_WKMediaScreenCaptureMuted = 1 << 2,
};
} API_AVAILABLE(macos(10.13), ios(11.0));

typedef NS_OPTIONS(NSUInteger, _WKCaptureDevices) {
_WKCaptureDeviceMicrophone = 1 << 0,
_WKCaptureDeviceCamera = 1 << 1,
_WKCaptureDeviceDisplay = 1 << 2,
} API_AVAILABLE(macosx(10.3));
} API_AVAILABLE(macos(10.13), ios(11.0));

typedef NS_OPTIONS(NSUInteger, _WKFindOptions) {
_WKFindOptionsCaseInsensitive = 1 << 0,
Expand All @@ -59,22 +59,12 @@ typedef NS_OPTIONS(NSUInteger, _WKFindOptions) {
- (void)_restoreFromSessionStateData:(NSData *)data;
- (NSData * _Nullable)_sessionStateData;

- (void)createWebArchiveDataWithCompletionHandler:(void (^)(NSData * _Nullable, NSError * _Nullable))completionHandler;
- (void)createPDFWithConfiguration:(id _Nullable)pdfConfiguration completionHandler:(void (^)(NSData * _Nullable pdfDocumentData, NSError * _Nullable error))completionHandler;

@property (nonatomic, readonly) _WKMediaCaptureStateDeprecated _mediaCaptureState;
@property (nonatomic, readonly) _WKMediaCaptureStateDeprecated _mediaCaptureState API_AVAILABLE(macos(10.15), ios(13.0));

- (void)setMicrophoneCaptureState:(WKMediaCaptureState)state completionHandler:(void (^)(void))completionHandler API_AVAILABLE(macos(12.0), ios(15.0));
- (void)setCameraCaptureState:(WKMediaCaptureState)state completionHandler:(void (^)(void))completionHandler API_AVAILABLE(macos(12.0), ios(15.0));
- (void)_stopMediaCapture;
- (void)_stopMediaCapture API_AVAILABLE(macos(10.15.4), ios(13.4));
- (void)_stopAllMediaPlayback;
- (_WKMediaMutedState)_mediaMutedState;
- (void)_setPageMuted:(_WKMediaMutedState)mutedState;

- (NSPrintOperation *)_printOperationWithPrintInfo:(NSPrintInfo *)printInfo;
- (NSPrintOperation * _Nullable)_printOperationWithPrintInfo:(NSPrintInfo *)printInfo forFrame:(id)frame;

- (NSView *)_fullScreenPlaceholderView;
- (_WKMediaMutedState)_mediaMutedState API_AVAILABLE(macos(11.0), ios(14.0));;
- (void)_setPageMuted:(_WKMediaMutedState)mutedState API_AVAILABLE(macos(10.13), ios(11.0));

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ extension WKWebViewConfiguration {

self.userContentController = userContentController
self.processPool.geolocationProvider = GeolocationProvider(processPool: self.processPool)
#if !APPSTORE
self.processPool.setDownloadDelegateIfNeeded(using: LegacyWebKitDownloadDelegate.init)
#endif
}

}
Loading

0 comments on commit bb74fca

Please sign in to comment.