Skip to content

Commit 4fe6002

Browse files
committed
refactor: disable swizzling in favor of manual forwarding
see microsoft/appcenter-sdk-apple#2137
1 parent e901ca3 commit 4fe6002

File tree

7 files changed

+38
-2
lines changed

7 files changed

+38
-2
lines changed

Info.plist

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<key>NSHumanReadableCopyright</key>
3232
<string>GPL-3.0 licence</string>
3333
<key>NSPrincipalClass</key>
34-
<string>NSApplication</string>
34+
<string>AppCenterApplication</string>
3535
<key>NSSupportsSuddenTermination</key>
3636
<string>true</string>
3737
<key>SUEnableAutomaticChecks</key>
@@ -46,5 +46,7 @@
4646
<string>true</string>
4747
<key>CFBundleIconFile</key>
4848
<string>app-icon</string>
49+
<key>AppCenterApplicationForwarderEnabled</key>
50+
<string>0</string>
4951
</dict>
5052
</plist>

alt-tab-macos-Bridging-Header.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#import "AppCenterApplication.h"

alt-tab-macos.xcodeproj/project.pbxproj

+8
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
D04BAD2A7F2E8BF64EE982E9 /* TextArea.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04BA7C836A8CE8C0B8D128B /* TextArea.swift */; };
9292
D04BAD43C122A1C7E88B0362 /* MouseEvents.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04BAF320F4D43F0DDFE063E /* MouseEvents.swift */; };
9393
D04BAD451966B43720120D2E /* Menubar.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04BAD905546AA93E5117B0A /* Menubar.swift */; };
94+
D04BADA3F2DAB820D6FC6E75 /* AppCenterApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = D04BA48BC82D3060C3A1AB11 /* AppCenterApplication.m */; };
9495
D04BADCDA9F9A6C3D6499877 /* SystemPermissions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04BA7C6F2519091717F4B4E /* SystemPermissions.swift */; };
9596
D04BAE8B16A06A10E2FA94DE /* AccessibilityEvents.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04BA8FDCF137D892114F5F3 /* AccessibilityEvents.swift */; };
9697
D04BAEE31B6FFCDC779E6C17 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = D04BAC2FF99F629CD4ED20FC /* MainMenu.xib */; };
@@ -104,6 +105,7 @@
104105

105106
/* Begin PBXFileReference section */
106107
4807A6C523A9CD190052A53E /* SkyLight.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SkyLight.framework; path = ../../../../System/Library/PrivateFrameworks/SkyLight.framework; sourceTree = "<group>"; };
108+
481FE54624D2D387001032F1 /* alt-tab-macos-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "alt-tab-macos-Bridging-Header.h"; sourceTree = "<group>"; };
107109
59DD4BE63D42EEFF1182BA7F /* Pods-alt-tab-macos.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-alt-tab-macos.release.xcconfig"; path = "Target Support Files/Pods-alt-tab-macos/Pods-alt-tab-macos.release.xcconfig"; sourceTree = "<group>"; };
108110
672F94799CC7C90282AEB3EA /* Pods-alt-tab-macos.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-alt-tab-macos.debug.xcconfig"; path = "Target Support Files/Pods-alt-tab-macos/Pods-alt-tab-macos.debug.xcconfig"; sourceTree = "<group>"; };
109111
C0712B3BEA2B3780398C0999 /* Pods_alt_tab_macos.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_alt_tab_macos.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -151,6 +153,7 @@
151153
D04BA4135D97F9E784709DA8 /* ko */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = ko; path = InfoPlist.strings; sourceTree = "<group>"; };
152154
D04BA4336B6004A0A99849AD /* package.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = package.json; sourceTree = "<group>"; };
153155
D04BA459034C1885CA43A807 /* LICENCE.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = LICENCE.md; sourceTree = "<group>"; };
156+
D04BA48BC82D3060C3A1AB11 /* AppCenterApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppCenterApplication.m; sourceTree = "<group>"; };
154157
D04BA48E6F24E0948C4CB4F7 /* import_l10n_strings_from_poeditor.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = import_l10n_strings_from_poeditor.sh; sourceTree = "<group>"; };
155158
D04BA49E45BFFF3D9FC60E43 /* HyperlinkLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HyperlinkLabel.swift; sourceTree = "<group>"; };
156159
D04BA4A26987F67DD94C827F /* AboutTab.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutTab.swift; sourceTree = "<group>"; };
@@ -232,6 +235,7 @@
232235
D04BAADF01EB8FF8A15AECC6 /* Acknowledgments.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = Acknowledgments.md; sourceTree = "<group>"; };
233236
D04BAAE6E6823304D66B74F8 /* update_website.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = update_website.sh; sourceTree = "<group>"; };
234237
D04BAAF760E3A8A22BDA84D6 /* appcast.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = appcast.xml; sourceTree = "<group>"; };
238+
D04BAAF79737A0673502FEB5 /* AppCenterApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppCenterApplication.h; sourceTree = "<group>"; };
235239
D04BAB08AD95CD9024BEE95A /* fi */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = fi; path = InfoPlist.strings; sourceTree = "<group>"; };
236240
D04BAB51808B6118EB00DFC7 /* mstile-150x150.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "mstile-150x150.png"; sourceTree = "<group>"; };
237241
D04BAB6652494D7575057E86 /* 14 windows - 3 lines.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "14 windows - 3 lines.jpg"; sourceTree = "<group>"; };
@@ -385,6 +389,7 @@
385389
D04BAB8A94DA69A6B5008AE5 /* Pipfile */,
386390
D04BA84F172AE89F210CA01D /* Pipfile.lock */,
387391
A638921971E99EC1D9EC383D /* Pods */,
392+
481FE54624D2D387001032F1 /* alt-tab-macos-Bridging-Header.h */,
388393
);
389394
sourceTree = "<group>";
390395
};
@@ -432,6 +437,8 @@
432437
D04BA26C75F76C277653C932 /* FeedbackWindow.swift */,
433438
D04BA2CBF267F267225CA671 /* generic-components */,
434439
D04BA1C271F0DA573345B860 /* permission-window */,
440+
D04BAAF79737A0673502FEB5 /* AppCenterApplication.h */,
441+
D04BA48BC82D3060C3A1AB11 /* AppCenterApplication.m */,
435442
);
436443
path = ui;
437444
sourceTree = "<group>";
@@ -1112,6 +1119,7 @@
11121119
D04BAD43C122A1C7E88B0362 /* MouseEvents.swift in Sources */,
11131120
D04BAFF30A98CF287F85DA1E /* BlacklistsTab.swift in Sources */,
11141121
D04BA56789A2AF52557A9BFF /* AppCenterCrashes.swift in Sources */,
1122+
D04BADA3F2DAB820D6FC6E75 /* AppCenterApplication.m in Sources */,
11151123
);
11161124
runOnlyForDeploymentPostprocessing = 0;
11171125
};

config/base.xcconfig

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ INFOPLIST_OUTPUT_FORMAT = binary
1313
PLIST_FILE_OUTPUT_FORMAT = binary
1414
COCOAPODS_PARALLEL_CODE_SIGN = YES // codesign pods faster
1515
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES
16+
SWIFT_OBJC_BRIDGING_HEADER = alt-tab-macos-Bridging-Header.h

src/ui/App.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Preferences
66

77
let cgsMainConnectionId = CGSMainConnectionID()
88

9-
class App: NSApplication, NSApplicationDelegate {
9+
class App: AppCenterApplication, NSApplicationDelegate {
1010
static let name = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as! String
1111
static let id = Bundle.main.object(forInfoDictionaryKey: "CFBundleIdentifier") as! String
1212
static let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as! String

src/ui/AppCenterApplication.h

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@import Cocoa;
2+
3+
@interface AppCenterApplication : NSApplication
4+
@end

src/ui/AppCenterApplication.m

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@import Cocoa;
2+
@import AppCenterCrashes;
3+
#import "AppCenterApplication.h"
4+
5+
@implementation AppCenterApplication
6+
7+
- (void)reportException:(NSException*)exception {
8+
[MSCrashes applicationDidReportException:exception];
9+
[super reportException:exception];
10+
}
11+
12+
- (void)sendEvent:(NSEvent*)theEvent {
13+
@try {
14+
[super sendEvent:theEvent];
15+
} @catch (NSException* exception) {
16+
[self reportException:exception];
17+
}
18+
}
19+
20+
@end

0 commit comments

Comments
 (0)