Skip to content

Commit 7f7366a

Browse files
committed
Fix helper install failure
1 parent da56d08 commit 7f7366a

File tree

10 files changed

+96
-65
lines changed

10 files changed

+96
-65
lines changed

Core/Sources/RuntimeViewerCore/RuntimeEngine.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ public final class RuntimeEngine {
141141
self.connection = connection
142142
self.setupMessageHandlerForClient()
143143
}
144+
print("Client connected")
144145
}
145146
} else {
146147
observeRuntime()

RuntimeViewerUsingAppKit/RuntimeViewerCatalystHelper/Info.plist

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>SMPrivilegedExecutables</key>
6-
<dict>
7-
<key>com.JH.RuntimeViewerService</key>
8-
<string>identifier "com.JH.RuntimeViewerService" and anchor apple generic and certificate leaf[subject.CN] = "Apple Development: JieHui Lai (4ZZALU97YZ)" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */</string>
9-
</dict>
105
<key>UIApplicationSceneManifest</key>
116
<dict>
127
<key>UIApplicationSupportsMultipleScenes</key>

RuntimeViewerUsingAppKit/RuntimeViewerUsingAppKit.xcodeproj/project.pbxproj

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -980,8 +980,8 @@
980980
"$(inherited)",
981981
"@executable_path/../Frameworks",
982982
);
983-
MACOSX_DEPLOYMENT_TARGET = 13.0;
984-
MARKETING_VERSION = 1.0;
983+
MACOSX_DEPLOYMENT_TARGET = 12.0;
984+
MARKETING_VERSION = 1.1.0;
985985
PRODUCT_BUNDLE_IDENTIFIER = com.JH.RuntimeViewer;
986986
PRODUCT_NAME = RuntimeViewer;
987987
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -1015,8 +1015,8 @@
10151015
"$(inherited)",
10161016
"@executable_path/../Frameworks",
10171017
);
1018-
MACOSX_DEPLOYMENT_TARGET = 13.0;
1019-
MARKETING_VERSION = 1.0;
1018+
MACOSX_DEPLOYMENT_TARGET = 12.0;
1019+
MARKETING_VERSION = 1.1.0;
10201020
PRODUCT_BUNDLE_IDENTIFIER = com.JH.RuntimeViewer;
10211021
PRODUCT_NAME = RuntimeViewer;
10221022
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -1038,6 +1038,7 @@
10381038
CURRENT_PROJECT_VERSION = 1;
10391039
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = NO;
10401040
DEVELOPMENT_TEAM = D5Q73692VW;
1041+
ENABLE_HARDENED_RUNTIME = YES;
10411042
ENABLE_USER_SCRIPT_SANDBOXING = NO;
10421043
GENERATE_INFOPLIST_FILE = YES;
10431044
INFOPLIST_FILE = RuntimeViewerCatalystHelper/Info.plist;
@@ -1047,12 +1048,12 @@
10471048
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
10481049
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
10491050
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
1050-
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
1051+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
10511052
LD_RUNPATH_SEARCH_PATHS = (
10521053
"$(inherited)",
10531054
"@executable_path/Frameworks",
10541055
);
1055-
MARKETING_VERSION = 1.0;
1056+
MARKETING_VERSION = 1.1.0;
10561057
ONLY_ACTIVE_ARCH = NO;
10571058
PRODUCT_BUNDLE_IDENTIFIER = com.JH.RuntimeViewerCatalystHelper;
10581059
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -1082,6 +1083,7 @@
10821083
CURRENT_PROJECT_VERSION = 1;
10831084
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = NO;
10841085
DEVELOPMENT_TEAM = D5Q73692VW;
1086+
ENABLE_HARDENED_RUNTIME = YES;
10851087
ENABLE_USER_SCRIPT_SANDBOXING = NO;
10861088
GENERATE_INFOPLIST_FILE = YES;
10871089
INFOPLIST_FILE = RuntimeViewerCatalystHelper/Info.plist;
@@ -1091,12 +1093,12 @@
10911093
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
10921094
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
10931095
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
1094-
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
1096+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
10951097
LD_RUNPATH_SEARCH_PATHS = (
10961098
"$(inherited)",
10971099
"@executable_path/Frameworks",
10981100
);
1099-
MARKETING_VERSION = 1.0;
1101+
MARKETING_VERSION = 1.1.0;
11001102
ONLY_ACTIVE_ARCH = NO;
11011103
PRODUCT_BUNDLE_IDENTIFIER = com.JH.RuntimeViewerCatalystHelper;
11021104
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -1120,11 +1122,12 @@
11201122
COMBINE_HIDPI_IMAGES = YES;
11211123
CURRENT_PROJECT_VERSION = 1;
11221124
DEVELOPMENT_TEAM = D5Q73692VW;
1125+
ENABLE_HARDENED_RUNTIME = YES;
11231126
GENERATE_INFOPLIST_FILE = YES;
11241127
INFOPLIST_KEY_NSHumanReadableCopyright = "";
11251128
INFOPLIST_KEY_NSPrincipalClass = AppKitPluginImpl;
11261129
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles";
1127-
MACOSX_DEPLOYMENT_TARGET = 13.0;
1130+
MACOSX_DEPLOYMENT_TARGET = 12.0;
11281131
MARKETING_VERSION = 1.0;
11291132
PRODUCT_BUNDLE_IDENTIFIER = com.JH.RuntimeViewerCatalystHelperPlugin;
11301133
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -1142,11 +1145,12 @@
11421145
COMBINE_HIDPI_IMAGES = YES;
11431146
CURRENT_PROJECT_VERSION = 1;
11441147
DEVELOPMENT_TEAM = D5Q73692VW;
1148+
ENABLE_HARDENED_RUNTIME = YES;
11451149
GENERATE_INFOPLIST_FILE = YES;
11461150
INFOPLIST_KEY_NSHumanReadableCopyright = "";
11471151
INFOPLIST_KEY_NSPrincipalClass = AppKitPluginImpl;
11481152
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles";
1149-
MACOSX_DEPLOYMENT_TARGET = 13.0;
1153+
MACOSX_DEPLOYMENT_TARGET = 12.0;
11501154
MARKETING_VERSION = 1.0;
11511155
PRODUCT_BUNDLE_IDENTIFIER = com.JH.RuntimeViewerCatalystHelperPlugin;
11521156
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -1162,9 +1166,11 @@
11621166
baseConfigurationReference = E9C9E9C92C2D0E3C00C4AA34 /* Config.xcconfig */;
11631167
buildSettings = {
11641168
CODE_SIGN_STYLE = Automatic;
1169+
CREATE_INFOPLIST_SECTION_IN_BINARY = YES;
11651170
DEVELOPMENT_TEAM = D5Q73692VW;
11661171
ENABLE_HARDENED_RUNTIME = YES;
1167-
MACOSX_DEPLOYMENT_TARGET = 13.0;
1172+
INFOPLIST_FILE = "$(SRCROOT)/$(TARGETNAME)/Info.plist";
1173+
MACOSX_DEPLOYMENT_TARGET = 12.0;
11681174
PRODUCT_NAME = "$(TARGET_NAME)";
11691175
SKIP_INSTALL = YES;
11701176
SWIFT_VERSION = 5.0;
@@ -1176,9 +1182,11 @@
11761182
baseConfigurationReference = E9C9E9C92C2D0E3C00C4AA34 /* Config.xcconfig */;
11771183
buildSettings = {
11781184
CODE_SIGN_STYLE = Automatic;
1185+
CREATE_INFOPLIST_SECTION_IN_BINARY = YES;
11791186
DEVELOPMENT_TEAM = D5Q73692VW;
11801187
ENABLE_HARDENED_RUNTIME = YES;
1181-
MACOSX_DEPLOYMENT_TARGET = 13.0;
1188+
INFOPLIST_FILE = "$(SRCROOT)/$(TARGETNAME)/Info.plist";
1189+
MACOSX_DEPLOYMENT_TARGET = 12.0;
11821190
PRODUCT_NAME = "$(TARGET_NAME)";
11831191
SKIP_INSTALL = YES;
11841192
SWIFT_VERSION = 5.0;
@@ -1207,7 +1215,7 @@
12071215
"@executable_path/../Frameworks",
12081216
"@loader_path/Frameworks",
12091217
);
1210-
MACOSX_DEPLOYMENT_TARGET = 13.0;
1218+
MACOSX_DEPLOYMENT_TARGET = 12.0;
12111219
MARKETING_VERSION = 1.0;
12121220
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
12131221
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20";
@@ -1245,7 +1253,7 @@
12451253
"@executable_path/../Frameworks",
12461254
"@loader_path/Frameworks",
12471255
);
1248-
MACOSX_DEPLOYMENT_TARGET = 13.0;
1256+
MACOSX_DEPLOYMENT_TARGET = 12.0;
12491257
MARKETING_VERSION = 1.0;
12501258
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
12511259
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20";

RuntimeViewerUsingAppKit/RuntimeViewerUsingAppKit/Attach Process/AttachToProcessViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class AttachToProcessViewModel: ViewModel<MainRoute> {
3434
try await RuntimeEngineManager.shared.launchAttachedRuntimeEngine(name: name, identifier: bundleIdentifier)
3535
try await RuntimeInjectClient.shared.injectApplication(pid: app.processIdentifier, dylibURL: dylibURL)
3636
} catch {
37-
print(error)
37+
print(error, error.localizedDescription)
3838
}
3939

4040
await MainActor.run {

RuntimeViewerUsingAppKit/RuntimeViewerUsingAppKit/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<key>SMPrivilegedExecutables</key>
2727
<dict>
2828
<key>com.JH.RuntimeViewerService</key>
29-
<string>identifier "com.JH.RuntimeViewerService" and anchor apple generic and certificate leaf[subject.CN] = "Apple Development: JieHui Lai (4ZZALU97YZ)" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */</string>
29+
<string>anchor apple generic and identifier "com.JH.RuntimeViewerService" and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = D5Q73692VW)</string>
3030
</dict>
3131
<key>UTImportedTypeDeclarations</key>
3232
<array>

RuntimeViewerUsingAppKit/RuntimeViewerUsingAppKit/Main/MainMenuItemView.swift

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,40 @@
55
// Created by JH on 2025/3/31.
66
//
77

8-
import SwiftUI
8+
//import SwiftUI
99

10-
class MainMenuItemView: NSHostingView<MainMenuItemView.ContentView> {
11-
struct ContentView: View {
12-
let title: String
13-
14-
let icon: NSImage
15-
16-
var body: some View {
17-
HStack {
18-
Spacer()
19-
Label {
20-
Text(title)
21-
} icon: {
22-
Image(nsImage: icon)
23-
}
24-
}
25-
.frame(maxWidth: .infinity)
26-
.frame(minHeight: 30)
27-
}
28-
}
29-
30-
init(title: String, icon: NSImage) {
31-
super.init(rootView: .init(title: title, icon: icon))
32-
sizingOptions = .preferredContentSize
33-
}
34-
35-
@available(*, unavailable)
36-
@MainActor @preconcurrency dynamic required init?(coder aDecoder: NSCoder) {
37-
fatalError("init(coder:) has not been implemented")
38-
}
39-
40-
@available(*, unavailable)
41-
@MainActor @preconcurrency required init(rootView: MainMenuItemView.ContentView) {
42-
fatalError("init(rootView:) has not been implemented")
43-
}
44-
}
10+
//class MainMenuItemView: NSHostingView<MainMenuItemView.ContentView> {
11+
// struct ContentView: View {
12+
// let title: String
13+
//
14+
// let icon: NSImage
15+
//
16+
// var body: some View {
17+
// HStack {
18+
// Spacer()
19+
// Label {
20+
// Text(title)
21+
// } icon: {
22+
// Image(nsImage: icon)
23+
// }
24+
// }
25+
// .frame(maxWidth: .infinity)
26+
// .frame(minHeight: 30)
27+
// }
28+
// }
29+
//
30+
// init(title: String, icon: NSImage) {
31+
// super.init(rootView: .init(title: title, icon: icon))
32+
// sizingOptions = .preferredContentSize
33+
// }
34+
//
35+
// @available(*, unavailable)
36+
// @MainActor @preconcurrency dynamic required init?(coder aDecoder: NSCoder) {
37+
// fatalError("init(coder:) has not been implemented")
38+
// }
39+
//
40+
// @available(*, unavailable)
41+
// @MainActor @preconcurrency required init(rootView: MainMenuItemView.ContentView) {
42+
// fatalError("init(rootView:) has not been implemented")
43+
// }
44+
//}

RuntimeViewerUsingAppKit/RuntimeViewerUsingAppKit/Utils/HelperInstaller.swift

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,39 @@ public enum HelperAuthorizationError: Error {
88
}
99

1010
public enum HelperInstaller {
11-
private static let daemonService = SMAppService.daemon(plistName: "com.JH.RuntimeViewerService.plist")
11+
// private static let daemonService = SMAppService.daemon(plistName: "com.JH.RuntimeViewerService.plist")
1212

1313
public static func install() throws {
14-
try daemonService.register()
15-
print(daemonService.status.rawValue)
14+
// try daemonService.register()
15+
// print(daemonService.status.rawValue)
16+
// return
17+
func executeAuthorizationFunction(_ authorizationFunction: () -> (OSStatus)) throws {
18+
let osStatus = authorizationFunction()
19+
guard osStatus == errAuthorizationSuccess else {
20+
throw HelperAuthorizationError.message(String(describing: SecCopyErrorMessageString(osStatus, nil)))
21+
}
22+
}
23+
24+
func authorizationRef(_ rights: UnsafePointer<AuthorizationRights>?,
25+
_ environment: UnsafePointer<AuthorizationEnvironment>?,
26+
_ flags: AuthorizationFlags) throws -> AuthorizationRef? {
27+
var authRef: AuthorizationRef?
28+
try executeAuthorizationFunction { AuthorizationCreate(rights, environment, flags, &authRef) }
29+
return authRef
30+
}
31+
var cfError: Unmanaged<CFError>?
32+
33+
var authItem: AuthorizationItem = kSMRightBlessPrivilegedHelper.withCString {
34+
AuthorizationItem(name: $0, valueLength: 0, value: UnsafeMutableRawPointer(bitPattern: 0), flags: 0)
35+
}
36+
37+
var authRights = AuthorizationRights(count: 1, items: withUnsafeMutablePointer(to: &authItem) { $0 })
38+
39+
let authRef = try authorizationRef(&authRights, nil, [.interactionAllowed, .extendRights, .preAuthorize])
40+
SMJobBless(kSMDomainSystemLaunchd, RuntimeViewerMachServiceName as CFString, authRef, &cfError)
41+
if let error = cfError?.takeRetainedValue() {
42+
throw error
43+
}
1644
}
1745
}
1846
#endif

RuntimeViewerUsingAppKit/RuntimeViewerUsingAppKit/com.JH.RuntimeViewerService.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
<dict>
55
<key>Label</key>
66
<string>com.JH.RuntimeViewerService</string>
7+
<key>BundleProgram</key>
8+
<string>Contents/Library/LaunchServices</string>
79
<key>MachServices</key>
810
<dict>
911
<key>com.JH.RuntimeViewerService</key>
1012
<true/>
1113
</dict>
12-
<key>BundleProgram</key>
13-
<string>Contents/Library/LaunchServices</string>
1414
</dict>
1515
</plist>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
OTHER_LDFLAGS = $(inherited) -sectcreate __TEXT __info_plist "$(SRCROOT)/com.JH.RuntimeViewerService/Info.plist" -sectcreate __TEXT __launchd_plist "$(SRCROOT)/com.JH.RuntimeViewerService/launchd.plist"
1+
OTHER_LDFLAGS = $(inherited) -sectcreate __TEXT __launchd_plist "$(SRCROOT)/com.JH.RuntimeViewerService/launchd.plist"
22

RuntimeViewerUsingAppKit/com.JH.RuntimeViewerService/Info.plist

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
<string>1</string>
1515
<key>SMAuthorizedClients</key>
1616
<array>
17-
<string>identifier &quot;com.JH.RuntimeViewer&quot; and anchor apple generic and certificate leaf[subject.CN] = &quot;Apple Development: JieHui Lai (4ZZALU97YZ)&quot; and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */</string>
18-
<string>identifier &quot;com.JH.RuntimeViewerCatalystHelper&quot; and anchor apple generic and certificate leaf[subject.CN] = &quot;Apple Development: JieHui Lai (4ZZALU97YZ)&quot; and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */</string>
17+
<string>anchor apple generic and identifier "com.JH.RuntimeViewer" and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = D5Q73692VW)</string>
1918
</array>
2019
</dict>
2120
</plist>

0 commit comments

Comments
 (0)