Skip to content

Commit aa44ee9

Browse files
committed
Remove CocoaPods from tray_icon_example macOS project
Migrates the tray_icon_example macOS project away from CocoaPods by deleting Podfile and Podfile.lock, updating Xcode project files to remove CocoaPods references, and switching to Swift Package for plugin integration. Also updates multiple_window_example to change view order, enhances NSWindow swizzling, and updates cnativeapi header includes and submodule.
1 parent 4c0a239 commit aa44ee9

12 files changed

Lines changed: 95 additions & 145 deletions

File tree

examples/multiple_window_example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MyApp extends StatelessWidget {
1919
theme: ThemeData(
2020
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
2121
),
22-
home: ViewCollection(views: [PrimaryWindow(), SecondaryWindow()]),
22+
home: ViewCollection(views: [SecondaryWindow(), PrimaryWindow()]),
2323
);
2424
}
2525
}

examples/multiple_window_example/macos/Runner/NSWindow+Swizzle.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ extension NSWindow {
1919
return
2020
}
2121
method_exchangeImplementations(originalMethod, swizzledMethod)
22+
23+
// Swizzle makeKeyAndOrderFront(_:)
24+
let originalMakeKey = #selector(NSWindow.makeKeyAndOrderFront(_:))
25+
let swizzledMakeKey = #selector(NSWindow.swizzled_makeKeyAndOrderFront(_:))
26+
guard
27+
let originalMakeKeyMethod = class_getInstanceMethod(NSWindow.self, originalMakeKey),
28+
let swizzledMakeKeyMethod = class_getInstanceMethod(NSWindow.self, swizzledMakeKey)
29+
else {
30+
assertionFailure("[Swizzle] Failed to find methods for makeKeyAndOrderFront swizzling")
31+
return
32+
}
33+
method_exchangeImplementations(originalMakeKeyMethod, swizzledMakeKeyMethod)
2234
}()
2335

2436
// MARK: - Swizzled implementation
@@ -36,6 +48,15 @@ extension NSWindow {
3648
return window
3749
}
3850

51+
// Intercepts makeKeyAndOrderFront(_:) calls
52+
@objc dynamic func swizzled_makeKeyAndOrderFront(_ sender: Any?) {
53+
NSLog("[Swizzle] Intercepted makeKeyAndOrderFront for window: \(String(describing: self))")
54+
55+
self.center()
56+
// Because we've swapped implementations, calling swizzled_makeKeyAndOrderFront(_:) actually calls the original
57+
self.swizzled_makeKeyAndOrderFront(sender)
58+
}
59+
3960
// MARK: - Appearance configuration
4061
private static func configureDefaultAppearance(for window: NSWindow) {
4162
window.hasShadow = false
@@ -47,7 +68,7 @@ extension NSWindow {
4768
window.titlebarAppearsTransparent = true
4869
}
4970

50-
window.alphaValue = 0.5
71+
// window.alphaValue = 0.5
5172
NSLog("[Swizzle] Modified NSWindow: \(String(describing: window))")
5273
}
5374
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
21
#include "ephemeral/Flutter-Generated.xcconfig"
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
21
#include "ephemeral/Flutter-Generated.xcconfig"

examples/tray_icon_example/macos/Podfile

Lines changed: 0 additions & 42 deletions
This file was deleted.

examples/tray_icon_example/macos/Podfile.lock

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)