feat: support macOS 12

This commit is contained in:
wibus-wee
2024-08-04 17:21:01 +08:00
parent 76b79bf46e
commit 48d28097b2
11 changed files with 128 additions and 41 deletions

View File

@@ -7,6 +7,9 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
381027E02C5F784F00348460 /* Extension+Scene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 381027DF2C5F784F00348460 /* Extension+Scene.swift */; };
381027E22C5F7C4800348460 /* Extension+Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = 381027E12C5F7C4800348460 /* Extension+Font.swift */; };
381027E42C5F7E1100348460 /* Extension+URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 381027E32C5F7E1100348460 /* Extension+URL.swift */; };
387CEA792C5BD9C400E3A5AC /* AdminPrivilegeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 387CEA782C5BD9C400E3A5AC /* AdminPrivilegeView.swift */; }; 387CEA792C5BD9C400E3A5AC /* AdminPrivilegeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 387CEA782C5BD9C400E3A5AC /* AdminPrivilegeView.swift */; };
387CEA7B2C5DEF0600E3A5AC /* Extension+String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 387CEA7A2C5DEF0600E3A5AC /* Extension+String.swift */; }; 387CEA7B2C5DEF0600E3A5AC /* Extension+String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 387CEA7A2C5DEF0600E3A5AC /* Extension+String.swift */; };
38877A1D2C4A6F83009F5910 /* InjectGUIApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38877A1C2C4A6F83009F5910 /* InjectGUIApp.swift */; }; 38877A1D2C4A6F83009F5910 /* InjectGUIApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38877A1C2C4A6F83009F5910 /* InjectGUIApp.swift */; };
@@ -33,6 +36,9 @@
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
381027DF2C5F784F00348460 /* Extension+Scene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Extension+Scene.swift"; sourceTree = "<group>"; };
381027E12C5F7C4800348460 /* Extension+Font.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Extension+Font.swift"; sourceTree = "<group>"; };
381027E32C5F7E1100348460 /* Extension+URL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Extension+URL.swift"; sourceTree = "<group>"; };
387CEA782C5BD9C400E3A5AC /* AdminPrivilegeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminPrivilegeView.swift; sourceTree = "<group>"; }; 387CEA782C5BD9C400E3A5AC /* AdminPrivilegeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminPrivilegeView.swift; sourceTree = "<group>"; };
387CEA7A2C5DEF0600E3A5AC /* Extension+String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Extension+String.swift"; sourceTree = "<group>"; }; 387CEA7A2C5DEF0600E3A5AC /* Extension+String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Extension+String.swift"; sourceTree = "<group>"; };
38877A192C4A6F83009F5910 /* InjectGUI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = InjectGUI.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38877A192C4A6F83009F5910 /* InjectGUI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = InjectGUI.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -144,6 +150,9 @@
38877A322C4A7222009F5910 /* PublishedStorage.swift */, 38877A322C4A7222009F5910 /* PublishedStorage.swift */,
38877A342C4A7254009F5910 /* ViewKit.swift */, 38877A342C4A7254009F5910 /* ViewKit.swift */,
387CEA7A2C5DEF0600E3A5AC /* Extension+String.swift */, 387CEA7A2C5DEF0600E3A5AC /* Extension+String.swift */,
381027DF2C5F784F00348460 /* Extension+Scene.swift */,
381027E12C5F7C4800348460 /* Extension+Font.swift */,
381027E32C5F7E1100348460 /* Extension+URL.swift */,
); );
path = Extension; path = Extension;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -253,13 +262,16 @@
38AD95EA2C58E70E0032E79F /* Injector.swift in Sources */, 38AD95EA2C58E70E0032E79F /* Injector.swift in Sources */,
38877A302C4A70DB009F5910 /* SoftwareManager.swift in Sources */, 38877A302C4A70DB009F5910 /* SoftwareManager.swift in Sources */,
38877A332C4A7222009F5910 /* PublishedStorage.swift in Sources */, 38877A332C4A7222009F5910 /* PublishedStorage.swift in Sources */,
381027E02C5F784F00348460 /* Extension+Scene.swift in Sources */,
38E944F22C5A761B00B252A3 /* Executor.swift in Sources */, 38E944F22C5A761B00B252A3 /* Executor.swift in Sources */,
38BC1F552C4B622500C3B60E /* WelcomeView.swift in Sources */, 38BC1F552C4B622500C3B60E /* WelcomeView.swift in Sources */,
38877A2E2C4A6FFA009F5910 /* InjectConfiguration.swift in Sources */, 38877A2E2C4A6FFA009F5910 /* InjectConfiguration.swift in Sources */,
38BC1F532C4B587A00C3B60E /* SidebarView.swift in Sources */, 38BC1F532C4B587A00C3B60E /* SidebarView.swift in Sources */,
38877A352C4A7254009F5910 /* ViewKit.swift in Sources */, 38877A352C4A7254009F5910 /* ViewKit.swift in Sources */,
38877A3A2C4A730F009F5910 /* Constants.swift in Sources */, 38877A3A2C4A730F009F5910 /* Constants.swift in Sources */,
381027E42C5F7E1100348460 /* Extension+URL.swift in Sources */,
38BC1F5C2C4BB02200C3B60E /* SettingsView.swift in Sources */, 38BC1F5C2C4BB02200C3B60E /* SettingsView.swift in Sources */,
381027E22C5F7C4800348460 /* Extension+Font.swift in Sources */,
387CEA792C5BD9C400E3A5AC /* AdminPrivilegeView.swift in Sources */, 387CEA792C5BD9C400E3A5AC /* AdminPrivilegeView.swift in Sources */,
38AD95EE2C58F59C0032E79F /* StatusView.swift in Sources */, 38AD95EE2C58F59C0032E79F /* StatusView.swift in Sources */,
); );
@@ -402,7 +414,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 16.1; IPHONEOS_DEPLOYMENT_TARGET = 16.1;
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.0; MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.1; MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = "dev.wibus-wee.InjectGUI"; PRODUCT_BUNDLE_IDENTIFIER = "dev.wibus-wee.InjectGUI";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
@@ -440,7 +452,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 16.1; IPHONEOS_DEPLOYMENT_TARGET = 16.1;
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.0; MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.1; MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = "dev.wibus-wee.InjectGUI"; PRODUCT_BUNDLE_IDENTIFIER = "dev.wibus-wee.InjectGUI";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";

View File

@@ -29,8 +29,8 @@ struct InjectGUIApp: App {
AdminPrivilegeView() AdminPrivilegeView()
} }
} }
.windowResizability(.contentSize)
.commands { SidebarCommands() } .commands { SidebarCommands() }
.contentSizedWindowResizability()
#if DEBUG #if DEBUG
// Release // Release

View File

@@ -285,11 +285,11 @@ class Injector: ObservableObject {
private func transformPath(path: String, to type: GenScriptType) -> String { private func transformPath(path: String, to type: GenScriptType) -> String {
switch type { switch type {
case .none: case .none:
return path.replacing("%20", with: " ") return path.replacingOccurrences(of: "%20", with: " ")
case .appleScript: case .appleScript:
return path.replacing("%20", with: " ").replacing(" ", with: "\\\\ ") return path.replacingOccurrences(of: "%20", with: " ").replacingOccurrences(of: " ", with: "\\\\ ")
case .bash: case .bash:
return path.replacing("%20", with: " ").replacing(" ", with: "\\ ") return path.replacingOccurrences(of: "%20", with: " ").replacingOccurrences(of: " ", with: "\\ ")
} }
} }
@@ -332,7 +332,7 @@ class Injector: ObservableObject {
func handleKeygenCommands() -> [(command: String, isAdmin: Bool)] { func handleKeygenCommands() -> [(command: String, isAdmin: Bool)] {
let userName = NSFullUserName() let userName = NSFullUserName()
let keygenStarterURL = self.genSourcePath(for: .bash, path: injectConfiguration.getInjecToolPath(name: "KeygenStarter")?.path()) let keygenStarterURL = self.genSourcePath(for: .bash, path: injectConfiguration.getInjecToolPath(name: "KeygenStarter")?.pathWithFallback())
let bundleIdentifier = self.appDetail?.identifier ?? "" let bundleIdentifier = self.appDetail?.identifier ?? ""
if self.injectDetail?.keygen ?? false { if self.injectDetail?.keygen ?? false {
return [("\(keygenStarterURL) '\(bundleIdentifier)' '\(userName)'", false)] return [("\(keygenStarterURL) '\(bundleIdentifier)' '\(userName)'", false)]
@@ -347,8 +347,8 @@ class Injector: ObservableObject {
let source = self.genSourcePath(for: .bash) let source = self.genSourcePath(for: .bash)
let destination = source.appending(".backup") let destination = source.appending(".backup")
let insert_dylib_URL = injectConfiguration.getInjecToolPath(name: "insert_dylib")?.path().replacing("%20", with: " ") let insert_dylib_URL = injectConfiguration.getInjecToolPath(name: "insert_dylib")?.pathWithFallback().replacingOccurrences(of: "%20", with: " ")
let QiuchenlyDylib_URL = injectConfiguration.getInjecToolPath(name: "91Qiuchenly.dylib")?.path().replacing("%20", with: " ") let QiuchenlyDylib_URL = injectConfiguration.getInjecToolPath(name: "91Qiuchenly.dylib")?.pathWithFallback().replacingOccurrences(of: "%20", with: " ")
if insert_dylib_URL == nil || QiuchenlyDylib_URL == nil { if insert_dylib_URL == nil || QiuchenlyDylib_URL == nil {
let alert = NSAlert() let alert = NSAlert()
@@ -448,22 +448,22 @@ class Injector: ObservableObject {
var replaceSpecialShell: [(String, String)] = [] // (from, to) var replaceSpecialShell: [(String, String)] = [] // (from, to)
// tool/optool // tool/optool
let optoolPath = self.genSourcePath(for: .appleScript, path: injectConfiguration.getInjecToolPath(name: "optool")?.path()) let optoolPath = self.genSourcePath(for: .appleScript, path: injectConfiguration.getInjecToolPath(name: "optool")?.pathWithFallback())
replaceSpecialShell.append(("tool/optool", optoolPath)) replaceSpecialShell.append(("tool/optool", optoolPath))
replaceSpecialShell.append(("./tool/optool", optoolPath)) replaceSpecialShell.append(("./tool/optool", optoolPath))
// tool/insert_dylib // tool/insert_dylib
let insert_dylibPath = self.genSourcePath(for: .appleScript, path: injectConfiguration.getInjecToolPath(name: "insert_dylib")?.path()) let insert_dylibPath = self.genSourcePath(for: .appleScript, path: injectConfiguration.getInjecToolPath(name: "insert_dylib")?.pathWithFallback())
replaceSpecialShell.append(("tool/insert_dylib", insert_dylibPath)) replaceSpecialShell.append(("tool/insert_dylib", insert_dylibPath))
replaceSpecialShell.append(("./tool/insert_dylib", insert_dylibPath)) replaceSpecialShell.append(("./tool/insert_dylib", insert_dylibPath))
// tool/91QiuChenly.dylib // tool/91QiuChenly.dylib
let dylibPath = self.genSourcePath(for: .appleScript, path: injectConfiguration.getInjecToolPath(name: "91Qiuchenly.dylib")?.path()) let dylibPath = self.genSourcePath(for: .appleScript, path: injectConfiguration.getInjecToolPath(name: "91Qiuchenly.dylib")?.pathWithFallback())
replaceSpecialShell.append(("tool/91QiuChenly.dylib", dylibPath)) replaceSpecialShell.append(("tool/91QiuChenly.dylib", dylibPath))
replaceSpecialShell.append(("./tool/91QiuChenly.dylib", dylibPath)) replaceSpecialShell.append(("./tool/91QiuChenly.dylib", dylibPath))
// tool/GenShineImpactStarter // tool/GenShineImpactStarter
let genShineImpactStarterPath = self.genSourcePath(for: .appleScript, path: injectConfiguration.getInjecToolPath(name: "GenShineImpactStarter")?.path()) let genShineImpactStarterPath = self.genSourcePath(for: .appleScript, path: injectConfiguration.getInjecToolPath(name: "GenShineImpactStarter")?.pathWithFallback())
replaceSpecialShell.append(("tool/GenShineImpactStarter", genShineImpactStarterPath)) replaceSpecialShell.append(("tool/GenShineImpactStarter", genShineImpactStarterPath))
replaceSpecialShell.append(("./tool/GenShineImpactStarter", genShineImpactStarterPath)) replaceSpecialShell.append(("./tool/GenShineImpactStarter", genShineImpactStarterPath))
@@ -494,10 +494,10 @@ class Injector: ObservableObject {
helpers = helperFile helpers = helperFile
for helper in helpers { for helper in helpers {
let genShineImpactStarterURL = self.genSourcePath(for: .bash, path: injectConfiguration.getInjecToolPath(name: "GenShineImpactStarter")?.path()) let genShineImpactStarterURL = self.genSourcePath(for: .bash, path: injectConfiguration.getInjecToolPath(name: "GenShineImpactStarter")?.pathWithFallback())
var targetHelper = (self.appDetail?.path ?? "").replacingOccurrences(of: "/Contents", with: "") + helper var targetHelper = (self.appDetail?.path ?? "").replacingOccurrences(of: "/Contents", with: "") + helper
let bridgeFile = (self.appDetail?.path ?? "").replacingOccurrences(of: "/Contents", with: "") + (self.injectDetail?.bridgeFile ?? "") let bridgeFile = (self.appDetail?.path ?? "").replacingOccurrences(of: "/Contents", with: "") + (self.injectDetail?.bridgeFile ?? "")
let insertDylibURL = self.genSourcePath(for: .bash, path: injectConfiguration.getInjecToolPath(name: "insert_dylib")?.path()) let insertDylibURL = self.genSourcePath(for: .bash, path: injectConfiguration.getInjecToolPath(name: "insert_dylib")?.pathWithFallback())
let helperName = targetHelper.split(separator: "/").last let helperName = targetHelper.split(separator: "/").last
let target = self.genSourcePath(for: .appleScript, path: "/Library/LaunchDaemons/\(helperName!).plist") let target = self.genSourcePath(for: .appleScript, path: "/Library/LaunchDaemons/\(helperName!).plist")

View File

@@ -0,0 +1,21 @@
//
// Extension+Font.swift
// InjectGUI
//
// Created by wibus on 2024/8/4.
//
import Foundation
import SwiftUI
extension Text {
func fontDesignAndWeight(font: Font.Design, weight: Font.Weight) -> Text {
if #available(macOS 13.0, *) {
return self
.fontDesign(font)
.fontWeight(weight)
} else {
return self
}
}
}

View File

@@ -0,0 +1,19 @@
//
// Extension+Scene.swift
// InjectGUI
//
// Created by wibus on 2024/8/4.
//
import Foundation
import SwiftUI
extension Scene {
func contentSizedWindowResizability() -> some Scene {
if #available(macOS 13.0, *) {
return self.windowResizability(.contentSize)
} else {
return self
}
}
}

View File

@@ -9,7 +9,7 @@ import Foundation
extension String { extension String {
func transformTo(to targetType: Injector.GenScriptType) -> String { func transformTo(to targetType: Injector.GenScriptType) -> String {
let original = self.replacing("\\\\ ", with: " ").replacing("\\ ", with: " ") let original = self.replacingOccurrences(of: "\\\\ ", with: " ").replacingOccurrences(of: "\\ ", with: " ")
print(original) print(original)
@@ -18,9 +18,9 @@ extension String {
case .none: case .none:
return original return original
case .appleScript: case .appleScript:
return original.replacing(" ", with: "\\\\ ") return original.replacingOccurrences(of: " ", with: "\\\\ ")
case .bash: case .bash:
return original.replacing(" ", with: "\\ ") return original.replacingOccurrences(of: " ", with: "\\ ")
} }
} }
} }

View File

@@ -0,0 +1,18 @@
//
// Extension+URL.swift
// InjectGUI
//
// Created by wibus on 2024/8/4.
//
import Foundation
extension URL {
func pathWithFallback(percentEncoded: Bool = true) -> String {
if #available(macOS 13.0, *) {
return self.path(percentEncoded: percentEncoded)
} else {
return self.path
}
}
}

View File

@@ -32,18 +32,16 @@ struct ContentView: View {
} }
} }
if !showAdminPrivilegeView { ToolbarItem {
ToolbarItem { Button {
Button { executor.password = ""
executor.password = "" showAdminPrivilegeView = true
showAdminPrivilegeView = true } label: {
} label: { Label("Enter password again", systemImage: "lock")
Label("Enter password again", systemImage: "lock")
}
} }
} }
ToolbarItem() { ToolbarItem {
Button { Button {
softwareManager.getList() softwareManager.getList()
injectConfiguration.updateRemoteConf() injectConfiguration.updateRemoteConf()

View File

@@ -191,11 +191,19 @@ struct SettingsView: View {
Spacer().frame(height: 16) Spacer().frame(height: 16)
Text("InjectGUI") if #available(macOS 13.0, *) {
.font(.system(.title2, design: .rounded, weight: .bold)) Text("InjectGUI")
Text("By wibus. Made with ❤️") .font(.system(.title2, design: .rounded, weight: .bold))
.font(.system(.body, design: .rounded, weight: .bold)) Text("By wibus. Made with ❤️")
.foregroundColor(.secondary) .font(.system(.body, design: .rounded, weight: .bold))
.foregroundColor(.secondary)
} else {
Text("Welcome to InjectGUI")
.font(.title)
.fontWeight(.bold)
Text("By wibus. Made with ❤️")
.foregroundColor(.secondary)
}
Spacer().frame(height: 24) Spacer().frame(height: 24)
} }

View File

@@ -85,8 +85,10 @@ struct StatusView: View {
.foregroundColor(.red) .foregroundColor(.red)
} }
Text("\(stage.description)") Text("\(stage.description)")
.fontDesign(.rounded) .fontDesignAndWeight(
.fontWeight(injector.stage.stages[index].status == .running ? .bold : .regular) font: .rounded,
weight: injector.stage.stages[index].status == .running ? .bold : .regular
)
// Text(injector.stage.stages[index].message) // Text(injector.stage.stages[index].message)
// .font(.subheadline) // .font(.subheadline)
// .foregroundColor(.secondary) // .foregroundColor(.secondary)
@@ -103,7 +105,7 @@ struct StatusView: View {
Image(systemName: "questionmark.circle.fill") Image(systemName: "questionmark.circle.fill")
.foregroundColor(.secondary) .foregroundColor(.secondary)
Text("\(stage.description)") Text("\(stage.description)")
.fontDesign(.rounded) .fontDesignAndWeight(font: .rounded, weight: .regular)
} }
} }
} }

View File

@@ -30,11 +30,20 @@ struct WelcomeView: View {
Spacer().frame(height: 16) Spacer().frame(height: 16)
Text("Welcome to InjectGUI") if #available(macOS 13.0, *) {
.font(.system(.title2, design: .rounded, weight: .bold)) Text("Welcome to InjectGUI")
Text("By wibus. Made with ❤️") .font(.system(.title2, design: .rounded, weight: .bold))
.font(.system(.body, design: .rounded, weight: .bold)) Text("By wibus. Made with ❤️")
.foregroundColor(.secondary) .font(.system(.body, design: .rounded, weight: .bold))
.foregroundColor(.secondary)
} else {
Text("Welcome to InjectGUI")
.font(.title)
.fontWeight(.bold)
Text("By wibus. Made with ❤️")
.foregroundColor(.secondary)
}
Spacer().frame(height: 24) Spacer().frame(height: 24)
} }