Skip to content

Commit

Permalink
A small patch
Browse files Browse the repository at this point in the history
Sometimes App Bundle name not equal to App Executable
  • Loading branch information
powenn committed Jul 30, 2022
1 parent 9d4b132 commit 29a5f80
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
4 changes: 2 additions & 2 deletions permasigneriOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 11;
CURRENT_PROJECT_VERSION = 12;
DEVELOPMENT_ASSET_PATHS = "\"permasigneriOS/Preview Content\"";
DEVELOPMENT_TEAM = L4LN9U3ZS7;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -394,7 +394,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 11;
CURRENT_PROJECT_VERSION = 12;
DEVELOPMENT_ASSET_PATHS = "\"permasigneriOS/Preview Content\"";
DEVELOPMENT_TEAM = L4LN9U3ZS7;
ENABLE_PREVIEWS = YES;
Expand Down
Binary file not shown.
6 changes: 4 additions & 2 deletions permasigneriOS/CheckApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CheckApp: ObservableObject {
var app_version:String = ""
var app_min_ios:String = ""
var app_author:String = ""

@Published var custom_app_executable:String = ""
var app_executable:String? = nil
var validInfoPlist:Bool = false
// ----------------------------
Expand Down Expand Up @@ -65,8 +65,10 @@ class CheckApp: ObservableObject {
app_version = config?["CFBundleShortVersionString"] as! String
app_min_ios = config?["MinimumOSVersion"] as! String? ?? "14.0"
app_author = app_bundle.components(separatedBy: ".")[1]
custom_app_bundle = app_bundle

custom_app_name = app_name
custom_app_bundle = app_bundle
custom_app_executable = app_executable!
validInfoPlist = true
} else {
validInfoPlist = false
Expand Down
44 changes: 20 additions & 24 deletions permasigneriOS/PackToDeb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Progress: ObservableObject {
try? FileManager.default.copyItem(at: postinstFileURL, to: DebDebianDirectory.appendingPathComponent("postinst"))
do {
var newPostinstFileText = try String(contentsOf: postinstFileURL, encoding: .utf8)
newPostinstFileText = newPostinstFileText.replacingOccurrences(of: "{APP_NAME}", with: CheckApp.shared.custom_app_name)
newPostinstFileText = newPostinstFileText.replacingOccurrences(of: "{APP_NAME}", with: CheckApp.shared.custom_app_executable)
try newPostinstFileText.write(to: DebDebianDirectory.appendingPathComponent("postinst"), atomically: true, encoding: .utf8)
}
catch {
Expand All @@ -79,7 +79,7 @@ class Progress: ObservableObject {
try? FileManager.default.copyItem(at: postrmFileURL, to: DebDebianDirectory.appendingPathComponent("postrm"))
do {
var newPostrmFileText = try String(contentsOf: postrmFileURL, encoding: .utf8)
newPostrmFileText = newPostrmFileText.replacingOccurrences(of: "{APP_NAME}", with: CheckApp.shared.custom_app_name)
newPostrmFileText = newPostrmFileText.replacingOccurrences(of: "{APP_NAME}", with: CheckApp.shared.custom_app_executable)
try newPostrmFileText.write(to: DebDebianDirectory.appendingPathComponent("postrm"), atomically: true, encoding: .utf8)
}
catch {
Expand All @@ -103,30 +103,26 @@ class Progress: ObservableObject {
}
// Info.plist
// get Info in plist file
if CheckApp.shared.app_bundle != CheckApp.shared.custom_app_bundle {
AppNameDir = CheckApp.shared.appNameInPayload.replacingOccurrences(of: CheckApp.shared.app_name, with: CheckApp.shared.custom_app_name)
let InfoPlistPathInTmpPayload = CheckApp.shared.payloadPath.appendingPathComponent("\(CheckApp.shared.appNameInPayload)/Info.plist")
if let PlistScriptFileURL = Bundle.main.url(forResource: "Plist", withExtension: "sh") {
try? FileManager.default.copyItem(at: PlistScriptFileURL, to: tmpDirectory.appendingPathComponent("Plist.sh"))
do {
var newPlistScriptText = try String(contentsOf: PlistScriptFileURL, encoding: .utf8)
newPlistScriptText = newPlistScriptText.replacingOccurrences(of: "{MY_PLIST_PATH}", with: InfoPlistPathInTmpPayload.path)
newPlistScriptText = newPlistScriptText.replacingOccurrences(of: "{OLD_VALUE}", with: CheckApp.shared.app_bundle)
newPlistScriptText = newPlistScriptText.replacingOccurrences(of: "{NEW_VALUE}", with: CheckApp.shared.custom_app_bundle)
try newPlistScriptText.write(to: tmpDirectory.appendingPathComponent("Plist.sh"), atomically: true, encoding: .utf8)
}
catch {
print(error.localizedDescription)
}
AppNameDir = CheckApp.shared.appNameInPayload.replacingOccurrences(of: CheckApp.shared.app_executable!, with: CheckApp.shared.custom_app_executable)
let InfoPlistPathInTmpPayload = CheckApp.shared.payloadPath.appendingPathComponent("\(CheckApp.shared.appNameInPayload)/Info.plist")
if let PlistScriptFileURL = Bundle.main.url(forResource: "Plist", withExtension: "sh") {
try? FileManager.default.copyItem(at: PlistScriptFileURL, to: tmpDirectory.appendingPathComponent("Plist.sh"))
do {
var newPlistScriptText = try String(contentsOf: PlistScriptFileURL, encoding: .utf8)
newPlistScriptText = newPlistScriptText.replacingOccurrences(of: "{MY_PLIST_PATH}", with: InfoPlistPathInTmpPayload.path)
newPlistScriptText = newPlistScriptText.replacingOccurrences(of: "{OLD_VALUE}", with: CheckApp.shared.app_bundle)
newPlistScriptText = newPlistScriptText.replacingOccurrences(of: "{NEW_VALUE}", with: CheckApp.shared.custom_app_bundle)
try newPlistScriptText.write(to: tmpDirectory.appendingPathComponent("Plist.sh"), atomically: true, encoding: .utf8)
}
catch {
print(error.localizedDescription)
}
let plistDict = NSMutableDictionary(contentsOfFile: InfoPlistPathInTmpPayload.path)
plistDict!.setObject(CheckApp.shared.custom_app_name, forKey: "CFBundleDisplayName" as NSCopying)
plistDict!.write(toFile: CheckApp.shared.payloadPath.appendingPathComponent("\(CheckApp.shared.appNameInPayload)/Info.plist").path, atomically: false)

AuxiliaryExecute.local.bash(command: "bash /var/mobile/Documents/permasigneriOS/tmp/Plist.sh")
} else {
AppNameDir = CheckApp.shared.appNameInPayload
}
let plistDict = NSMutableDictionary(contentsOfFile: InfoPlistPathInTmpPayload.path)
plistDict!.setObject(CheckApp.shared.custom_app_name, forKey: "CFBundleDisplayName" as NSCopying)
plistDict!.write(toFile: CheckApp.shared.payloadPath.appendingPathComponent("\(CheckApp.shared.appNameInPayload)/Info.plist").path, atomically: false)

AuxiliaryExecute.local.bash(command: "bash /var/mobile/Documents/permasigneriOS/tmp/Plist.sh")
}

func copyAppContent() {
Expand Down
5 changes: 4 additions & 1 deletion permasigneriOS/Views/SignView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,16 @@ struct CustomInfoView: View {
Text("Customize App Name")
TextField("App Name", text: $checkapp.custom_app_name)
.textFieldStyle(.roundedBorder)
Text("Customize App Executable")
TextField("App Executable", text: $checkapp.custom_app_executable)
.textFieldStyle(.roundedBorder)
Text("Customize App Bundle")
TextField("App Bundle", text: $checkapp.custom_app_bundle)
.textFieldStyle(.roundedBorder)
Text("Customize deb file description\n( Leave blank to use default )")
TextField("Description", text: $progress.CustomDebDescription)
.textFieldStyle(.roundedBorder)
Text("\nCustomized Name and Bundle are both required,\nif you want to prevent original apps being replaced\nRecommended to modify like this\n\nExampleApp2\ncom.example.exampleapp2")
Text("\nIf you want to prevent original apps being replaced\nRecommended to modify like this\n\nExampleApp2\nExampleApp2\ncom.example.exampleapp2\n\nWARNING:PLEASE MAKE SURE THE NAME\nIS NOT AS SAME AS THE SYSTEM APP NAMES")
.font(.footnote)
.foregroundColor(.gray)
}.padding()
Expand Down

0 comments on commit 29a5f80

Please sign in to comment.