Skip to content

Commit c445628

Browse files
committed
common refactor
Signed-off-by: Lessica <82flex@gmail.com>
1 parent 1acfc39 commit c445628

17 files changed

+831
-667
lines changed

TrollFools.xcodeproj/project.pbxproj

Lines changed: 113 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
6124A06D2CD2322400C52253 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6124A06C2CD2322400C52253 /* App.swift */; };
11+
6124A06F2CD2324200C52253 /* AppListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6124A06E2CD2324200C52253 /* AppListModel.swift */; };
12+
6124A0712CD2326500C52253 /* FilterOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6124A0702CD2326500C52253 /* FilterOptions.swift */; };
13+
6124A0742CD2328600C52253 /* AppListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6124A0732CD2328600C52253 /* AppListCell.swift */; };
14+
6124A0762CD232C600C52253 /* Option.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6124A0752CD232C600C52253 /* Option.swift */; };
15+
6124A0782CD232D400C52253 /* OptionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6124A0772CD232D400C52253 /* OptionCell.swift */; };
16+
6124A07B2CD2337500C52253 /* ViewControllerHost.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6124A07A2CD2337500C52253 /* ViewControllerHost.swift */; };
17+
6124A07D2CD233A700C52253 /* InjectedPlugIn.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6124A07C2CD233A700C52253 /* InjectedPlugIn.swift */; };
18+
6124A07F2CD233BA00C52253 /* PlugInCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6124A07E2CD233BA00C52253 /* PlugInCell.swift */; };
19+
6124A0812CD233DA00C52253 /* EjectListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6124A0802CD233DA00C52253 /* EjectListModel.swift */; };
1020
CC0E80FB2C54F84000B137B4 /* mv-15 in Resources */ = {isa = PBXBuildFile; fileRef = CC0E80FA2C54F84000B137B4 /* mv-15 */; };
1121
CC1548C92C4A6B2100A4173E /* ZIPFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = CC1548C82C4A6B2100A4173E /* ZIPFoundation */; };
1222
CC1548D12C4A6B8200A4173E /* ct_bypass in Resources */ = {isa = PBXBuildFile; fileRef = CC1548CF2C4A6B8200A4173E /* ct_bypass */; };
@@ -50,6 +60,16 @@
5060
/* End PBXBuildFile section */
5161

5262
/* Begin PBXFileReference section */
63+
6124A06C2CD2322400C52253 /* App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = "<group>"; };
64+
6124A06E2CD2324200C52253 /* AppListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppListModel.swift; sourceTree = "<group>"; };
65+
6124A0702CD2326500C52253 /* FilterOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterOptions.swift; sourceTree = "<group>"; };
66+
6124A0732CD2328600C52253 /* AppListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppListCell.swift; sourceTree = "<group>"; };
67+
6124A0752CD232C600C52253 /* Option.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Option.swift; sourceTree = "<group>"; };
68+
6124A0772CD232D400C52253 /* OptionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OptionCell.swift; sourceTree = "<group>"; };
69+
6124A07A2CD2337500C52253 /* ViewControllerHost.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewControllerHost.swift; sourceTree = "<group>"; };
70+
6124A07C2CD233A700C52253 /* InjectedPlugIn.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InjectedPlugIn.swift; sourceTree = "<group>"; };
71+
6124A07E2CD233BA00C52253 /* PlugInCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlugInCell.swift; sourceTree = "<group>"; };
72+
6124A0802CD233DA00C52253 /* EjectListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EjectListModel.swift; sourceTree = "<group>"; };
5373
CC0E80FA2C54F84000B137B4 /* mv-15 */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = "mv-15"; sourceTree = "<group>"; };
5474
CC1548CF2C4A6B8200A4173E /* ct_bypass */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = ct_bypass; sourceTree = "<group>"; };
5575
CC1548D22C4A743200A4173E /* SuccessView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SuccessView.swift; sourceTree = "<group>"; };
@@ -112,33 +132,100 @@
112132
/* End PBXFrameworksBuildPhase section */
113133

114134
/* Begin PBXGroup section */
115-
CC15490F2C4B84DD00A4173E /* Resources */ = {
135+
6124A06B2CD2321200C52253 /* ViewModel */ = {
136+
isa = PBXGroup;
137+
children = (
138+
6124A06C2CD2322400C52253 /* App.swift */,
139+
6124A06E2CD2324200C52253 /* AppListModel.swift */,
140+
6124A0702CD2326500C52253 /* FilterOptions.swift */,
141+
6124A0752CD232C600C52253 /* Option.swift */,
142+
6124A07C2CD233A700C52253 /* InjectedPlugIn.swift */,
143+
6124A0802CD233DA00C52253 /* EjectListModel.swift */,
144+
);
145+
name = ViewModel;
146+
sourceTree = "<group>";
147+
};
148+
6124A0722CD2327E00C52253 /* View */ = {
149+
isa = PBXGroup;
150+
children = (
151+
6124A0732CD2328600C52253 /* AppListCell.swift */,
152+
CCF4706D2C4A4BAB008D8197 /* AppListView.swift */,
153+
6124A0772CD232D400C52253 /* OptionCell.swift */,
154+
CCB6A1182C4A58C7000D75B0 /* OptionView.swift */,
155+
CC19E4BA2C561D7300E0F1B5 /* SettingsView.swift */,
156+
CCB6A11A2C4A6066000D75B0 /* InjectView.swift */,
157+
6124A07E2CD233BA00C52253 /* PlugInCell.swift */,
158+
CC15490D2C4B80AF00A4173E /* EjectListView.swift */,
159+
CC1548D22C4A743200A4173E /* SuccessView.swift */,
160+
CC1548D42C4A744300A4173E /* FailureView.swift */,
161+
);
162+
name = View;
163+
sourceTree = "<group>";
164+
};
165+
6124A0792CD2336100C52253 /* Extension */ = {
166+
isa = PBXGroup;
167+
children = (
168+
6124A07A2CD2337500C52253 /* ViewControllerHost.swift */,
169+
);
170+
name = Extension;
171+
sourceTree = "<group>";
172+
};
173+
6124A0822CD2345300C52253 /* Core */ = {
174+
isa = PBXGroup;
175+
children = (
176+
CC1548D62C4A768700A4173E /* Injector.swift */,
177+
CC1548DA2C4A7C7000A4173E /* Execute.swift */,
178+
CCF5A0A32C4D45160097D48D /* AuxiliaryExecute.swift */,
179+
CCF5A0A52C4D45400097D48D /* AuxiliaryExecute+Spawn.swift */,
180+
);
181+
name = Core;
182+
sourceTree = "<group>";
183+
};
184+
6124A0832CD2348E00C52253 /* Tools */ = {
116185
isa = PBXGroup;
117186
children = (
118-
CCF4705D2C4A464B008D8197 /* Assets.xcassets */,
119187
CCF925432C4CE47800880D48 /* chown */,
120188
CC1548E02C4A963500A4173E /* cp */,
121189
CC1549012C4B62E300A4173E /* cp-15 */,
122190
CC1548CF2C4A6B8200A4173E /* ct_bypass */,
123-
CC61A87B2C4A677B003BD9A0 /* CydiaSubstrate.framework.zip */,
124-
CC60FBE92CC4E6C400A6D21A /* Info.plist */,
125191
CC1548DC2C4A8DC500A4173E /* insert_dylib */,
126192
CC5E54BC2C4E12F900FDE4A8 /* install_name_tool */,
127193
CCC564E82C4BE8320097C300 /* ldid */,
194+
CCFC78632C4E853D008EB25D /* mkdir */,
195+
CCECB7CD2C54DC660094C8E6 /* mv */,
196+
CC0E80FA2C54F84000B137B4 /* mv-15 */,
197+
CC15490B2C4B79D800A4173E /* optool */,
198+
CC1548FF2C4AB43600A4173E /* rm */,
128199
CCC564E62C4BE8320097C300 /* libcrypto.3.dylib */,
129200
CC1548E22C4A974400A4173E /* libintl.8.dylib */,
130201
CC1548E32C4A974400A4173E /* libiosexec.1.dylib */,
131202
CCC564E72C4BE8320097C300 /* libplist-2.0.3.dylib */,
132203
CC5E54BB2C4E12F900FDE4A8 /* libxar.1.dylib */,
204+
CC61A87B2C4A677B003BD9A0 /* CydiaSubstrate.framework.zip */,
205+
);
206+
name = Tools;
207+
sourceTree = "<group>";
208+
};
209+
6124A0842CD234E000C52253 /* CExtension */ = {
210+
isa = PBXGroup;
211+
children = (
212+
CCF925422C4C1B6F00880D48 /* LSApplicationProxy.h */,
213+
CCF925412C4C1B6F00880D48 /* LSApplicationWorkspace.h */,
214+
CCF470712C4A4E81008D8197 /* TrollFools-Bridging-Header.h */,
215+
CCF470722C4A4E81008D8197 /* TrollFoolsStub.m */,
216+
);
217+
name = CExtension;
218+
sourceTree = "<group>";
219+
};
220+
CC15490F2C4B84DD00A4173E /* Resources */ = {
221+
isa = PBXGroup;
222+
children = (
223+
CCF4705D2C4A464B008D8197 /* Assets.xcassets */,
224+
CC60FBE92CC4E6C400A6D21A /* Info.plist */,
133225
CCF4706B2C4A4919008D8197 /* Localizable.strings */,
134-
CCFC78632C4E853D008EB25D /* mkdir */,
135-
CCECB7CD2C54DC660094C8E6 /* mv */,
136-
CC0E80FA2C54F84000B137B4 /* mv-15 */,
137-
CC15490B2C4B79D800A4173E /* optool */,
138-
CC1548FF2C4AB43600A4173E /* rm */,
139226
CC3485142C71B219007E0E28 /* TrollFools.entitlements */,
140-
CC3485162C71B219007E0E28 /* Version.Debug.xcconfig */,
141227
CC3485152C71B219007E0E28 /* Version.xcconfig */,
228+
CC3485162C71B219007E0E28 /* Version.Debug.xcconfig */,
142229
);
143230
name = Resources;
144231
sourceTree = "<group>";
@@ -173,21 +260,12 @@
173260
children = (
174261
CC60FBEB2CC50F5A00A6D21A /* BartyCrouch.swift */,
175262
CCF470592C4A4649008D8197 /* TrollFoolsApp.swift */,
176-
CCF4706D2C4A4BAB008D8197 /* AppListView.swift */,
177-
CCB6A1182C4A58C7000D75B0 /* OptionView.swift */,
178-
CC19E4BA2C561D7300E0F1B5 /* SettingsView.swift */,
179-
CCB6A11A2C4A6066000D75B0 /* InjectView.swift */,
180-
CC15490D2C4B80AF00A4173E /* EjectListView.swift */,
181-
CC1548D22C4A743200A4173E /* SuccessView.swift */,
182-
CC1548D42C4A744300A4173E /* FailureView.swift */,
183-
CC1548D62C4A768700A4173E /* Injector.swift */,
184-
CC1548DA2C4A7C7000A4173E /* Execute.swift */,
185-
CCF5A0A32C4D45160097D48D /* AuxiliaryExecute.swift */,
186-
CCF5A0A52C4D45400097D48D /* AuxiliaryExecute+Spawn.swift */,
187-
CCF925422C4C1B6F00880D48 /* LSApplicationProxy.h */,
188-
CCF925412C4C1B6F00880D48 /* LSApplicationWorkspace.h */,
189-
CCF470722C4A4E81008D8197 /* TrollFoolsStub.m */,
190-
CCF470712C4A4E81008D8197 /* TrollFools-Bridging-Header.h */,
263+
6124A0822CD2345300C52253 /* Core */,
264+
6124A0722CD2327E00C52253 /* View */,
265+
6124A06B2CD2321200C52253 /* ViewModel */,
266+
6124A0792CD2336100C52253 /* Extension */,
267+
6124A0842CD234E000C52253 /* CExtension */,
268+
6124A0832CD2348E00C52253 /* Tools */,
191269
CC15490F2C4B84DD00A4173E /* Resources */,
192270
);
193271
path = TrollFools;
@@ -295,16 +373,26 @@
295373
isa = PBXSourcesBuildPhase;
296374
buildActionMask = 2147483647;
297375
files = (
376+
6124A0782CD232D400C52253 /* OptionCell.swift in Sources */,
298377
CCF5A0A62C4D45400097D48D /* AuxiliaryExecute+Spawn.swift in Sources */,
299378
CCB6A11B2C4A6066000D75B0 /* InjectView.swift in Sources */,
300379
CCF470732C4A4E81008D8197 /* TrollFoolsStub.m in Sources */,
380+
6124A06D2CD2322400C52253 /* App.swift in Sources */,
301381
CC15490E2C4B80AF00A4173E /* EjectListView.swift in Sources */,
302382
CC60FBEC2CC50F5A00A6D21A /* BartyCrouch.swift in Sources */,
383+
6124A0762CD232C600C52253 /* Option.swift in Sources */,
384+
6124A07D2CD233A700C52253 /* InjectedPlugIn.swift in Sources */,
303385
CC1548DB2C4A7C7000A4173E /* Execute.swift in Sources */,
386+
6124A0742CD2328600C52253 /* AppListCell.swift in Sources */,
304387
CCF5A0A42C4D45160097D48D /* AuxiliaryExecute.swift in Sources */,
388+
6124A0712CD2326500C52253 /* FilterOptions.swift in Sources */,
389+
6124A07B2CD2337500C52253 /* ViewControllerHost.swift in Sources */,
305390
CCF4705A2C4A4649008D8197 /* TrollFoolsApp.swift in Sources */,
391+
6124A0812CD233DA00C52253 /* EjectListModel.swift in Sources */,
306392
CC19E4BB2C561D7300E0F1B5 /* SettingsView.swift in Sources */,
307393
CC1548D72C4A768700A4173E /* Injector.swift in Sources */,
394+
6124A07F2CD233BA00C52253 /* PlugInCell.swift in Sources */,
395+
6124A06F2CD2324200C52253 /* AppListModel.swift in Sources */,
308396
CCB6A1192C4A58C7000D75B0 /* OptionView.swift in Sources */,
309397
CCF4706E2C4A4BAB008D8197 /* AppListView.swift in Sources */,
310398
CC1548D32C4A743200A4173E /* SuccessView.swift in Sources */,

TrollFools/App.swift

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
//
2+
// App.swift
3+
// TrollFools
4+
//
5+
// Created by 82Flex on 2024/10/30.
6+
//
7+
8+
import Foundation
9+
10+
final class App: Identifiable, ObservableObject {
11+
let id: String
12+
let name: String
13+
let type: String
14+
let teamID: String
15+
let url: URL
16+
let version: String?
17+
18+
@Published var isDetached: Bool = false
19+
@Published var isAllowedToAttachOrDetach: Bool
20+
@Published var isInjected: Bool = false
21+
22+
lazy var icon: UIImage? = UIImage._applicationIconImage(forBundleIdentifier: id, format: 0, scale: 3.0)
23+
var alternateIcon: UIImage?
24+
25+
lazy var isUser: Bool = type == "User"
26+
lazy var isSystem: Bool = !isUser
27+
lazy var isFromApple: Bool = id.hasPrefix("com.apple.")
28+
lazy var isFromTroll: Bool = isSystem && !isFromApple
29+
lazy var isRemovable: Bool = url.path.contains("/var/containers/Bundle/Application/")
30+
31+
init(
32+
id: String,
33+
name: String,
34+
type: String,
35+
teamID: String,
36+
url: URL,
37+
version: String? = nil,
38+
alternateIcon: UIImage? = nil
39+
) {
40+
self.id = id
41+
self.name = name
42+
self.type = type
43+
self.teamID = teamID
44+
self.url = url
45+
self.version = version
46+
self.isDetached = Injector.isBundleDetached(url)
47+
self.isAllowedToAttachOrDetach = type == "User" && Injector.isBundleAllowedToAttachOrDetach(url)
48+
self.isInjected = Injector.isBundleInjected(url)
49+
self.alternateIcon = alternateIcon
50+
}
51+
52+
func reload() {
53+
reloadDetachedStatus()
54+
reloadInjectedStatus()
55+
}
56+
57+
private func reloadDetachedStatus() {
58+
self.isDetached = Injector.isBundleDetached(url)
59+
self.isAllowedToAttachOrDetach = isUser && Injector.isBundleAllowedToAttachOrDetach(url)
60+
}
61+
62+
private func reloadInjectedStatus() {
63+
self.isInjected = Injector.isBundleInjected(url)
64+
}
65+
}

0 commit comments

Comments
 (0)