Skip to content

Commit

Permalink
Fixes for Xcode16 (#2907)
Browse files Browse the repository at this point in the history
  • Loading branch information
mallexxx authored Jul 4, 2024
1 parent 0a0ea91 commit c83ac79
Show file tree
Hide file tree
Showing 39 changed files with 988 additions and 406 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## User settings
xcuserdata/
.vscode/
default.profraw

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
Expand Down
2 changes: 1 addition & 1 deletion Configuration/App/DuckDuckGo.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*] =
PROVISIONING_PROFILE_SPECIFIER[config=Release][sdk=macosx*] = MacOS Browser
PROVISIONING_PROFILE_SPECIFIER[config=Review][sdk=macosx*] = MacOS Browser Product Review

GCC_PREPROCESSOR_DEFINITIONS[arch=*][sdk=*] = NETP_SYSTEM_EXTENSION=1 SWIFT_OBJC_INTERFACE_HEADER_NAME=$(SWIFT_OBJC_INTERFACE_HEADER_NAME)
GCC_PREPROCESSOR_DEFINITIONS[arch=*][sdk=*] = NETP_SYSTEM_EXTENSION=1 SWIFT_OBJC_INTERFACE_HEADER_NAME=$(SWIFT_OBJC_INTERFACE_HEADER_NAME) uint64_t="unsigned long long" _UINT64_T=1
GCC_PREPROCESSOR_DEFINITIONS[config=CI][arch=*][sdk=*] = NETP_SYSTEM_EXTENSION=1 DEBUG=1 CI=1 SWIFT_OBJC_INTERFACE_HEADER_NAME=$(SWIFT_OBJC_INTERFACE_HEADER_NAME) $(inherited)
GCC_PREPROCESSOR_DEFINITIONS[config=Debug][arch=*][sdk=*] = NETP_SYSTEM_EXTENSION=1 DEBUG=1 SWIFT_OBJC_INTERFACE_HEADER_NAME=$(SWIFT_OBJC_INTERFACE_HEADER_NAME) $(inherited)
GCC_PREPROCESSOR_DEFINITIONS[config=Review][arch=*][sdk=*] = NETP_SYSTEM_EXTENSION=1 REVIEW=1 SWIFT_OBJC_INTERFACE_HEADER_NAME=$(SWIFT_OBJC_INTERFACE_HEADER_NAME) $(inherited)
Expand Down
1 change: 1 addition & 0 deletions Configuration/Tests/IntegrationTests.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ INFOPLIST_FILE = IntegrationTests/Info.plist
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.Integration-Tests

SWIFT_OBJC_BRIDGING_HEADER = $(SRCROOT)/IntegrationTests/Common/IntegrationTestsBridging.h
GCC_PREPROCESSOR_DEFINITIONS[arch=*][sdk=*] = uint64_t="unsigned long long" _UINT64_T=1 $(inherited)

TEST_HOST=$(BUILT_PRODUCTS_DIR)/DuckDuckGo.app/Contents/MacOS/DuckDuckGo
1 change: 1 addition & 0 deletions Configuration/Tests/UnitTests.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ INFOPLIST_FILE = UnitTests/Info.plist
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser.DuckDuckGoTests

SWIFT_OBJC_BRIDGING_HEADER = $(SRCROOT)/UnitTests/Common/TestsBridging.h
GCC_PREPROCESSOR_DEFINITIONS[arch=*][sdk=*] = uint64_t="unsigned long long" _UINT64_T=1 $(inherited)

TEST_HOST=$(BUILT_PRODUCTS_DIR)/DuckDuckGo.app/Contents/MacOS/DuckDuckGo
26 changes: 8 additions & 18 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "683424378092d5ca3c57df50d5676cf8c7d2d83c",
"version" : "164.2.2"
"revision" : "28dd48c5aca37c46402e2a14f7c47aad3877b3aa",
"version" : "164.3.0"
}
},
{
Expand Down Expand Up @@ -75,10 +75,10 @@
{
"identity" : "lottie-spm",
"kind" : "remoteSourceControl",
"location" : "https://github.com/airbnb/lottie-spm.git",
"location" : "https://github.com/airbnb/lottie-spm",
"state" : {
"revision" : "3bd43e12d6fb54654366a61f7cfaca787318b8ce",
"version" : "4.4.1"
"revision" : "1d29eccc24cc8b75bff9f6804155112c0ffc9605",
"version" : "4.4.3"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
version = "1.8">
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
Expand Down
70 changes: 34 additions & 36 deletions DuckDuckGo/Bookmarks/View/BookmarkListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -672,43 +672,41 @@ extension BookmarkListPopover: BookmarkListViewControllerDelegate {
}

#if DEBUG
private let previewEmptyState = false
@available(macOS 14.0, *)
#Preview(traits: .fixedLayout(width: BookmarkListViewController.preferredContentSize.width, height: BookmarkListViewController.preferredContentSize.height)) { {

let vc = BookmarkListViewController(bookmarkManager: {
let bkman = LocalBookmarkManager(bookmarkStore: BookmarkStoreMock(bookmarks: previewEmptyState ? [] : [
BookmarkFolder(id: "1", title: "Folder 1", children: [
BookmarkFolder(id: "2", title: "Nested Folder", children: [
Bookmark(id: "b1", url: URL.duckDuckGo.absoluteString, title: "DuckDuckGo", isFavorite: false, parentFolderUUID: "2")
])
]),
BookmarkFolder(id: "3", title: "Another Folder", children: [
BookmarkFolder(id: "4", title: "Nested Folder", children: [
BookmarkFolder(id: "5", title: "Another Nested Folder", children: [
Bookmark(id: "b2", url: URL.duckDuckGo.absoluteString, title: "DuckDuckGo", isFavorite: false, parentFolderUUID: "5")
])
// swiftlint:disable:next identifier_name
func _mockPreviewBookmarkManager(previewEmptyState: Bool) -> BookmarkManager {
let bkman = LocalBookmarkManager(bookmarkStore: BookmarkStoreMock(bookmarks: previewEmptyState ? [] : [
BookmarkFolder(id: "1", title: "Folder 1", children: [
BookmarkFolder(id: "2", title: "Nested Folder", children: [
Bookmark(id: "b1", url: URL.duckDuckGo.absoluteString, title: "DuckDuckGo", isFavorite: false, parentFolderUUID: "2")
])
]),
BookmarkFolder(id: "3", title: "Another Folder", children: [
BookmarkFolder(id: "4", title: "Nested Folder", children: [
BookmarkFolder(id: "5", title: "Another Nested Folder", children: [
Bookmark(id: "b2", url: URL.duckDuckGo.absoluteString, title: "DuckDuckGo", isFavorite: false, parentFolderUUID: "5")
])
]),
Bookmark(id: "b3", url: URL.duckDuckGo.absoluteString, title: "Bookmark 1", isFavorite: false, parentFolderUUID: ""),
Bookmark(id: "b4", url: URL.duckDuckGo.absoluteString, title: "Bookmark 2", isFavorite: false, parentFolderUUID: ""),
Bookmark(id: "b5", url: URL.duckDuckGo.absoluteString, title: "DuckDuckGo", isFavorite: false, parentFolderUUID: "")
]))
bkman.loadBookmarks()
customAssertionFailure = { _, _, _ in }

return bkman
}())

var c: AnyCancellable!
c = vc.publisher(for: \.view.window).sink { window in
window?.titlebarAppearsTransparent = true
window?.titleVisibility = .hidden
window?.styleMask = []
withExtendedLifetime(c) {}
}
])
]),
Bookmark(id: "b3", url: URL.duckDuckGo.absoluteString, title: "Bookmark 1", isFavorite: false, parentFolderUUID: ""),
Bookmark(id: "b4", url: URL.duckDuckGo.absoluteString, title: "Bookmark 2", isFavorite: false, parentFolderUUID: ""),
Bookmark(id: "b5", url: URL.duckDuckGo.absoluteString, title: "DuckDuckGo", isFavorite: false, parentFolderUUID: "")
]))
bkman.loadBookmarks()
customAssertionFailure = { _, _, _ in }

return bkman
}

return vc
@available(macOS 14.0, *)
#Preview("Test Bookmark data",
traits: BookmarkListViewController.preferredContentSize.fixedLayout) {
BookmarkListViewController(bookmarkManager: _mockPreviewBookmarkManager(previewEmptyState: false))
._preview_hidingWindowControlsOnAppear()
}

}() }
@available(macOS 14.0, *)
#Preview("Empty Scope", traits: BookmarkListViewController.preferredContentSize.fixedLayout) {
BookmarkListViewController(bookmarkManager: _mockPreviewBookmarkManager(previewEmptyState: true))
._preview_hidingWindowControlsOnAppear()
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ extension BookmarkManagementSidebarViewController: FolderMenuItemSelectors {
#if DEBUG
private let previewSize = NSSize(width: 400, height: 660)
@available(macOS 14.0, *)
#Preview(traits: .fixedLayout(width: previewSize.width, height: previewSize.height)) { {
#Preview(traits: previewSize.fixedLayout) { {

let vc = BookmarkManagementSidebarViewController(bookmarkManager: {
let bkman = LocalBookmarkManager(bookmarkStore: BookmarkStoreMock(bookmarks: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extension BookmarkManagementSplitViewController: BookmarkManagementDetailViewCon
#if DEBUG
private let previewSize = NSSize(width: 700, height: 660)
@available(macOS 14.0, *)
#Preview(traits: .fixedLayout(width: previewSize.width, height: previewSize.height)) { {
#Preview(traits: previewSize.fixedLayout) { {

let vc = BookmarkManagementSplitViewController(bookmarkManager: {
let bkman = LocalBookmarkManager(bookmarkStore: BookmarkStoreMock(bookmarks: [
Expand Down
10 changes: 10 additions & 0 deletions DuckDuckGo/Common/Extensions/NSSizeExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,13 @@ extension NSSize {
}

}

extension CGSize {
/// #Preview helper to convert CGSize to Preview Traits
@available(macOS 14.0, *)
var fixedLayout: PreviewTrait<Preview.ViewTraits> {
MainActor.assumeIsolated {
.fixedLayout(width: width, height: height)
}
}
}
26 changes: 26 additions & 0 deletions DuckDuckGo/Common/Extensions/NSViewControllerExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,30 @@ extension NSViewController {
closure()
CATransaction.commit()
}

/// #Preview helper to hide Window controls on View Controller appearance
func _preview_hidingWindowControlsOnAppear() -> Self { // swiftlint:disable:this identifier_name
Preview_ViewControllerWindowObserver().attach(to: self)
return self
}

}

/// #Preview helper to hide Window controls on View Controller appearance
final class Preview_ViewControllerWindowObserver: NSObject {
func attach(to viewController: NSViewController) {
// Start observing the view.window property
viewController.addObserver(self, forKeyPath: #keyPath(NSViewController.view.window), options: [.initial, .new], context: nil)
viewController.onDeinit {
withExtendedLifetime(self) {}
}
}

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {
guard let window = change?[.newKey] as? NSWindow else { return }

window.titlebarAppearsTransparent = true
window.titleVisibility = .hidden
window.styleMask = []
}
}
Loading

0 comments on commit c83ac79

Please sign in to comment.