Skip to content

Commit

Permalink
fix khanhduytran0#293, more helps, more robust LCAppInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeBlack committed Jan 4, 2025
1 parent ad60e48 commit ce6ed51
Show file tree
Hide file tree
Showing 11 changed files with 161 additions and 36 deletions.
2 changes: 1 addition & 1 deletion LCSharedUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ + (NSString*) teamIdentifier {

+ (NSString *)appGroupID {
static dispatch_once_t once;
static NSString *appGroupID = @"group.com.SideStore.SideStore";
static NSString *appGroupID = @"Unknown";
dispatch_once(&once, ^{
NSArray* possibleAppGroups = @[
[@"group.com.SideStore.SideStore." stringByAppendingString:[self teamIdentifier]],
Expand Down
19 changes: 14 additions & 5 deletions LiveContainerSwiftUI/LCAppInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ - (NSString*)displayName {
} else if (_infoPlist[@"CFBundleExecutable"]) {
return _infoPlist[@"CFBundleExecutable"];
} else {
return @"Unknown";
return @"App Corrupted, Please Reinstall This App";
}
}

Expand All @@ -100,14 +100,24 @@ - (NSString*)version {
if (!version) {
version = _infoPlist[@"CFBundleVersion"];
}
return version;
if(version) {
return version;
} else {
return @"Unknown";
}
}

- (NSString*)bundleIdentifier {
NSString* ans = nil;
if([self doUseLCBundleId]) {
return _info[@"LCOrignalBundleIdentifier"];
ans = _info[@"LCOrignalBundleIdentifier"];
} else {
return _infoPlist[@"CFBundleIdentifier"];
ans = _infoPlist[@"CFBundleIdentifier"];
}
if(ans) {
return ans;
} else {
return @"Unknown";
}
}

Expand Down Expand Up @@ -269,7 +279,6 @@ - (void)patchExecAndSignIfNeedWithCompletionHandler:(void(^)(bool success, NSStr
return;
}
info[@"LCPatchRevision"] = @(currentPatchRev);
[info writeToFile:infoPath atomically:YES];
}

if (!LCUtils.certificatePassword) {
Expand Down
11 changes: 11 additions & 0 deletions LiveContainerSwiftUI/LCAppListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ struct LCAppListView : View, LCAppBannerDelegate, LCAppModelDelegate {
@State private var navigateTo : AnyView?
@State private var isNavigationActive = false

@State private var helpPresent = false

@EnvironmentObject private var sharedModel : SharedModel

init(appDataFolderNames: Binding<[String]>, tweakFolderNames: Binding<[String]>) {
Expand Down Expand Up @@ -169,6 +171,12 @@ struct LCAppListView : View, LCAppBannerDelegate, LCAppModelDelegate {
}
}
}
ToolbarItem(placement: .topBarLeading) {
Button("Help", systemImage: "questionmark") {
helpPresent = true
}
}

ToolbarItem(placement: .topBarTrailing) {
Button("lc.appList.openLink".loc, systemImage: "link", action: {
Task { await onOpenWebViewTapped() }
Expand Down Expand Up @@ -228,6 +236,9 @@ struct LCAppListView : View, LCAppBannerDelegate, LCAppModelDelegate {
.fullScreenCover(isPresented: $safariViewOpened) {
SafariView(url: $safariViewURL)
}
.sheet(isPresented: $helpPresent) {
LCHelpView(isPresent: $helpPresent)
}

}

Expand Down
34 changes: 34 additions & 0 deletions LiveContainerSwiftUI/LCHelpView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// LCHelpView.swift
// LiveContainerSwiftUI
//
// Created by s s on 2025/1/4.
//

import SwiftUI

struct LCHelpView : View {
@Binding var isPresent : Bool

var body: some View {
NavigationView {
ScrollView {
VStack(alignment: .leading) {
Text("lc.helpView.text1")
Text("")
Text("lc.helpView.text2")
}
.padding()
}
.navigationTitle("lc.helpView.title")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem {
Button("lc.common.done") {
isPresent = false
}
}
}
}
}
}
26 changes: 15 additions & 11 deletions LiveContainerSwiftUI/LCJITLessDiagnoseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct LCJITLessDiagnoseView : View {
@State var certificateDataFound = false
@State var certificatePasswordFound = false
@State var appGroupAccessible = false
@State var certLastUpdateDateStr = "lc.common.unknown".loc
@State var certLastUpdateDateStr : String? = nil

@State var isJITLessTestInProgress = false

Expand All @@ -39,13 +39,13 @@ struct LCJITLessDiagnoseView : View {
Text("lc.jitlessDiag.appGroupId".loc)
Spacer()
Text(appGroupId)
.foregroundStyle(.gray)
.foregroundStyle(appGroupId == "Unknown" ? .red : .green)
}
HStack {
Text("lc.jitlessDiag.appGroupAccessible".loc)
Spacer()
Text(appGroupAccessible ? "lc.common.yes".loc : "lc.common.no".loc)
.foregroundStyle(.gray)
.foregroundStyle(appGroupAccessible ? .green : .red)
}
HStack {
Text("lc.jitlessDiag.store".loc)
Expand All @@ -62,28 +62,34 @@ struct LCJITLessDiagnoseView : View {
Text("lc.jitlessDiag.patchDetected".loc)
Spacer()
Text(isPatchDetected ? "lc.common.yes".loc : "lc.common.no".loc)
.foregroundStyle(.gray)
.foregroundStyle(isPatchDetected ? .green : .red)
}

HStack {
Text("lc.jitlessDiag.certDataFound".loc)
Spacer()
Text(certificateDataFound ? "lc.common.yes".loc : "lc.common.no".loc)
.foregroundStyle(.gray)
.foregroundStyle(certificateDataFound ? .green : .red)

}
HStack {
Text("lc.jitlessDiag.certPassFound".loc)
Spacer()
Text(certificatePasswordFound ? "lc.common.yes".loc : "lc.common.no".loc)
.foregroundStyle(.gray)
.foregroundStyle(certificatePasswordFound ? .green : .red)
}

HStack {
Text("lc.jitlessDiag.certLastUpdate".loc)
Spacer()
Text(certLastUpdateDateStr)
.foregroundStyle(.gray)
if let certLastUpdateDateStr {
Text(certLastUpdateDateStr)
.foregroundStyle(.green)
} else {
Text("lc.common.unknown".loc)
.foregroundStyle(.red)
}

}

Button {
Expand Down Expand Up @@ -145,8 +151,6 @@ struct LCJITLessDiagnoseView : View {
formatter1.dateStyle = .short
formatter1.timeStyle = .medium
certLastUpdateDateStr = formatter1.string(from: lastUpdateDate)
} else {
certLastUpdateDateStr = "lc.common.unknown".loc
}


Expand Down Expand Up @@ -194,6 +198,6 @@ struct LCJITLessDiagnoseView : View {
}

func getHelp() {
UIApplication.shared.open(URL(string: "https://github.com/khanhduytran0/LiveContainer/issues/265")!)
UIApplication.shared.open(URL(string: "https://github.com/khanhduytran0/LiveContainer/issues/265#issuecomment-2558409380")!)
}
}
42 changes: 27 additions & 15 deletions LiveContainerSwiftUI/LCUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#import "LCVersionInfo.h"
#import "../ZSign/zsigner.h"

Class LCSharedUtilsClass = nil;

// make SFSafariView happy and open data: URLs
@implementation NSURL(hack)
- (BOOL)safari_isHTTPFamilyURL {
Expand All @@ -17,13 +19,17 @@ - (BOOL)safari_isHTTPFamilyURL {

@implementation LCUtils

+ (void)load {
LCSharedUtilsClass = NSClassFromString(@"LCSharedUtils");
}

#pragma mark Certificate & password
+ (NSString *)teamIdentifier {
return [NSClassFromString(@"LCSharedUtils") teamIdentifier];
return [LCSharedUtilsClass teamIdentifier];
}

+ (NSURL *)appGroupPath {
return [NSClassFromString(@"LCSharedUtils") appGroupPath];
return [LCSharedUtilsClass appGroupPath];
}

+ (NSData *)certificateData {
Expand All @@ -33,7 +39,7 @@ + (NSData *)certificateData {
}

+ (NSString *)certificatePassword {
return [NSClassFromString(@"LCSharedUtils") certificatePassword];
return [LCSharedUtilsClass certificatePassword];
}

+ (void)setCertificatePassword:(NSString *)certPassword {
Expand All @@ -42,20 +48,20 @@ + (void)setCertificatePassword:(NSString *)certPassword {
}

+ (NSString *)appGroupID {
return [NSClassFromString(@"LCSharedUtils") appGroupID];
return [LCSharedUtilsClass appGroupID];
}

#pragma mark LCSharedUtils wrappers
+ (BOOL)launchToGuestApp {
return [NSClassFromString(@"LCSharedUtils") launchToGuestApp];
return [LCSharedUtilsClass launchToGuestApp];
}

+ (BOOL)askForJIT {
return [NSClassFromString(@"LCSharedUtils") askForJIT];
return [LCSharedUtilsClass askForJIT];
}

+ (BOOL)launchToGuestAppWithURL:(NSURL *)url {
return [NSClassFromString(@"LCSharedUtils") launchToGuestAppWithURL:url];
return [LCSharedUtilsClass launchToGuestAppWithURL:url];
}

#pragma mark Code signing
Expand Down Expand Up @@ -98,18 +104,16 @@ + (void)loadStoreFrameworksWithError2:(NSError **)error {
loaded = YES;
}

+ (NSString *)storeBundleID {
// Assuming this format never changes...
// group.BUNDLEID.YOURTEAMID
return [self.appGroupID substringWithRange:NSMakeRange(6, self.appGroupID.length - 17)];
}

+ (NSURL *)storeBundlePath {
return [self.appGroupPath URLByAppendingPathComponent:[NSString stringWithFormat:@"Apps/%@/App.app", self.storeBundleID]];
if ([self store] == SideStore) {
return [self.appGroupPath URLByAppendingPathComponent:@"Apps/com.SideStore.SideStore/App.app"];
} else {
return [self.appGroupPath URLByAppendingPathComponent:@"Apps/com.rileytestut.AltStore/App.app"];
}
}

+ (NSString *)storeInstallURLScheme {
if ([self.storeBundleID containsString:@"SideStore"]) {
if ([self store] == SideStore) {
return @"sidestore://install?url=%@";
} else {
return @"altstore://install?url=%@";
Expand Down Expand Up @@ -388,6 +392,14 @@ + (NSURL *)archiveTweakedAltStoreWithError:(NSError **)error {

NSFileManager *manager = NSFileManager.defaultManager;
NSURL *appGroupPath = [NSFileManager.defaultManager containerURLForSecurityApplicationGroupIdentifier:self.appGroupID];
if(!appGroupPath) {
NSDictionary* userInfo = @{
NSLocalizedDescriptionKey : @"Unable to access App Group. Please check JITLess diagnose page for more information."
};
*error = [NSError errorWithDomain:@"Unable to Access App Group" code:-1 userInfo:userInfo];
return nil;
}

NSURL *lcBundlePath = [appGroupPath URLByAppendingPathComponent:@"Apps/com.kdt.livecontainer"];
NSURL *bundlePath;
if ([self store] == SideStore) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
173564D22C76FE3500C6C918 /* LCAppBanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 173564C72C76FE3500C6C918 /* LCAppBanner.swift */; };
173564D32C76FE3500C6C918 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 173564C82C76FE3500C6C918 /* Assets.xcassets */; };
173F18402C7B7B74002953AA /* LCWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 173F183F2C7B7B74002953AA /* LCWebView.swift */; };
1747D7522D2965FE005694C7 /* LCHelpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1747D7512D2965F3005694C7 /* LCHelpView.swift */; };
17583D342D08555000FBA7F0 /* LCAppPreferenceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17583D332D08554400FBA7F0 /* LCAppPreferenceView.swift */; };
178B4C3E2C77654400DD1F74 /* Shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = 178B4C3D2C77654400DD1F74 /* Shared.swift */; };
179765E12CF8192600D40B95 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179765E02CF8192200D40B95 /* AppDelegate.swift */; };
Expand Down Expand Up @@ -56,6 +57,7 @@
173564C72C76FE3500C6C918 /* LCAppBanner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LCAppBanner.swift; sourceTree = "<group>"; };
173564C82C76FE3500C6C918 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
173F183F2C7B7B74002953AA /* LCWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LCWebView.swift; sourceTree = "<group>"; };
1747D7512D2965F3005694C7 /* LCHelpView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LCHelpView.swift; sourceTree = "<group>"; };
17583D332D08554400FBA7F0 /* LCAppPreferenceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LCAppPreferenceView.swift; sourceTree = "<group>"; };
178B4C3D2C77654400DD1F74 /* Shared.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shared.swift; sourceTree = "<group>"; };
178B4C3F2C7766A300DD1F74 /* LiveContainerSwiftUI-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "LiveContainerSwiftUI-Bridging-Header.h"; sourceTree = "<group>"; };
Expand All @@ -80,6 +82,7 @@
173564BB2C76FE1500C6C918 /* LiveContainerSwiftUI */ = {
isa = PBXGroup;
children = (
1747D7512D2965F3005694C7 /* LCHelpView.swift */,
17EC1CDF2D13BE9000A17824 /* LCJITLessDiagnoseView.swift */,
170D51B42D02E291009000A6 /* LCSelectContainerView.swift */,
173F183F2C7B7B74002953AA /* LCWebView.swift */,
Expand Down Expand Up @@ -214,6 +217,7 @@
171014182CE9B42000673269 /* LCVersionInfo.m in Sources */,
173564D22C76FE3500C6C918 /* LCAppBanner.swift in Sources */,
173F18402C7B7B74002953AA /* LCWebView.swift in Sources */,
1747D7522D2965FE005694C7 /* LCHelpView.swift in Sources */,
173564CE2C76FE3500C6C918 /* Makefile in Sources */,
17A7640C2C9D1B6C00456519 /* LCAppModel.swift in Sources */,
17C536F42C98529D006C2C75 /* LCAppSettingsView.swift in Sources */,
Expand Down
51 changes: 51 additions & 0 deletions LiveContainerSwiftUI/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1997,6 +1997,57 @@
}
}
},
"lc.helpView.text1" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Setup JITLess mode (Patch Store) in settings to use LiveContainer without JIT.\n\n**Check JITLess Diagnose page in settings if you have trouble enabling JITLess mode.**\n\nPress plus button to install apps.\n\nLong press app for app-specific settings, fixes and adding apps to homescreen."
}
},
"zh_CN" : {
"stringUnit" : {
"state" : "translated",
"value" : "在设置中配置免JIT模式(打补丁)来使得LiveContainer无需JIT权限即可使用。\n\n**如果配置免JIT模式时遇到问题,请查看免JIT模式诊断页面。**\n\n点击加号按钮来安装App。\n\n长按App可查看App设置,修复App问题,以及将App添加到主屏幕。"
}
}
}
},
"lc.helpView.text2" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "**Check [LiveContainer FAQ](https://github.com/khanhduytran0/LiveContainer/issues/265) for common issues.**\n \nIf you encounters a bug or competibility issue please submit on [GitHub issues](https://github.com/khanhduytran0/LiveContainer/issues)."
}
},
"zh_CN" : {
"stringUnit" : {
"state" : "translated",
"value" : "**遇到问题时请先查看[LiveContainer常见问题(英语)](https://github.com/khanhduytran0/LiveContainer/issues/265)。**\n \n如果你遇到Bug或者App兼容性问题,请到[GitHub issues](https://github.com/khanhduytran0/LiveContainer/issues)提交。"
}
}
}
},
"lc.helpView.title" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "LiveContainer Help"
}
},
"zh_CN" : {
"stringUnit" : {
"state" : "translated",
"value" : "LiveContainer帮助"
}
}
}
},
"lc.jitlessDiag.appGroupAccessible" : {
"extractionState" : "manual",
"localizations" : {
Expand Down
Loading

0 comments on commit ce6ed51

Please sign in to comment.