Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
fix: something get wrong with low version swift and xcode
Browse files Browse the repository at this point in the history
  • Loading branch information
wibus-wee committed Aug 8, 2024
1 parent d427614 commit 541e83c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 34 deletions.
50 changes: 25 additions & 25 deletions InjectGUI/Backend/Injector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@ extension InjectStage {
var description: String {
switch self {
case .start:
"Start Injecting"
return "Start Injecting"
case .copyExecutableFileAsBackup:
"Copying Executable File as Backup"
return "Copying Executable File as Backup"
case .checkPermissionAndRun:
"Checking Permission and Run"
return "Checking Permission and Run"
case .handleKeygen:
"Handling Keygen"
return "Handling Keygen"
case .handleDeepCodeSign:
"Handling Deep Code Sign"
return "Handling Deep Code Sign"
case .handleAutoHandleHelper:
"Handling Auto Handle Helper"
return "Handling Auto Handle Helper"
case .handleTccutil:
"Handling Tccutil"
return "Handling Tccutil"
case .handleExtraShell:
"Handling Extra Shell"
return "Handling Extra Shell"
case .handleInjectLibInject:
"Handling Inject Lib Inject"
return "Handling Inject Lib Inject"
case .end:
"Injecting Finished"
return "Injecting Finished"
}
}
}
Expand Down Expand Up @@ -220,26 +220,26 @@ class Injector: ObservableObject {
func commandsForStage(_ stage: InjectStage) -> [(command: String, isAdmin: Bool)] {
switch stage {
case .copyExecutableFileAsBackup:
self.copyExecutableFileAsBackupCommands()
return self.copyExecutableFileAsBackupCommands()
case .checkPermissionAndRun:
self.checkPermissionAndRunCommands()
return self.checkPermissionAndRunCommands()
case .handleInjectLibInject:
self.handleInjectLibInjectAdminCommands()
return self.handleInjectLibInjectAdminCommands()
case .handleKeygen:
self.handleKeygenCommands()
return self.handleKeygenCommands()
case .handleDeepCodeSign:
self.handleDeepCodeSignCommands()
return self.handleDeepCodeSignCommands()
case .handleAutoHandleHelper:
self.handleAutoHandleHelperCommands()
return self.handleAutoHandleHelperCommands()
case .handleTccutil:
self.handleTccutilCommands()
return self.handleTccutilCommands()
case .handleExtraShell:
self.handleExtraShellCommands()
return self.handleExtraShellCommands()
// case .end:
// let openApp = "open '\((self.appDetail?.path ?? "").replacingOccurrences(of: "/Contents", with: ""))'"
// return [(openApp, false)]
default:
[]
return []
}
}

Expand All @@ -257,9 +257,9 @@ class Injector: ObservableObject {

private func getBridgeDir(executable: Bool? = nil, injectDetail: AppList?) -> String {
if (executable ?? false) || injectDetail?.autoHandleSetapp == true {
"/MacOS/"
return "/MacOS/"
} else {
injectDetail?.bridgeFile?.replacingOccurrences(of: "/Contents", with: "") ?? "/Frameworks/"
return injectDetail?.bridgeFile?.replacingOccurrences(of: "/Contents", with: "") ?? "/Frameworks/"
}
}

Expand Down Expand Up @@ -292,17 +292,17 @@ class Injector: ObservableObject {
}

private func genSourcePath(for type: GenScriptType, path: String?) -> String {
self.transformPath(path: path ?? "", to: type)
return self.transformPath(path: path ?? "", to: type)
}

private func transformPath(path: String, to type: GenScriptType) -> String {
switch type {
case .none:
path.replacingOccurrences(of: "%20", with: " ")
return path.replacingOccurrences(of: "%20", with: " ")
case .appleScript:
path.replacingOccurrences(of: "%20", with: " ").replacingOccurrences(of: " ", with: "\\\\ ")
return path.replacingOccurrences(of: "%20", with: " ").replacingOccurrences(of: " ", with: "\\\\ ")
case .bash:
path.replacingOccurrences(of: "%20", with: " ").replacingOccurrences(of: " ", with: "\\ ")
return path.replacingOccurrences(of: "%20", with: " ").replacingOccurrences(of: " ", with: "\\ ")
}
}

Expand Down
10 changes: 1 addition & 9 deletions InjectGUI/Backend/SoftwareManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,7 @@ class SoftwareManager: ObservableObject {
let iconFileRaw = plist["CFBundleIconFile"] as? String ?? plist["CFBundleIconName"] as? String

// 检查文件名并添加扩展名(如果需要)
let iconFile: String? = if let iconFileRaw {
iconFileRaw.hasSuffix(
".icns"
) ? iconFileRaw : iconFileRaw.appending(
".icns"
)
} else {
nil
}
let iconFile: String? = iconFileRaw?.hasSuffix(".icns") ?? false ? iconFileRaw : iconFileRaw?.appending(".icns")

// 检查 iconFile 是否为 nil
guard let finalIconFile = iconFile else {
Expand Down

0 comments on commit 541e83c

Please sign in to comment.