diff --git a/CHANGELOG.md b/CHANGELOG.md index bb86293f..c41c2dc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to SideInstaller are documented here. +## 2.4.0 + +### Added +- **My apps.** A tab of its own, between Install and Tools, with the apps SideInstaller installed + that are still on this iPhone: each with its icon, version and how long it has left, and a + **Refresh** button that signs it again from the IPA SideInstaller kept, so its seven days start + over whenever you like. **Refresh all** does every one. SideInstaller now notes each app it + installs; the ones it installed before this version are found by the IPA it still holds for + them. Tools › Sideloaded apps still lists every sideloaded app, whoever installed it. + ## 2.3.0 ### Added diff --git a/README.md b/README.md index dd70932f..60f7a3e5 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ **Install SideStore and LiveContainer directly on your iPhone. No PC required.** [![Install](https://img.shields.io/badge/Install-SideInstaller-2ea44f?style=for-the-badge)](https://sideinstaller.net/) -[![Version](https://img.shields.io/badge/version-2.3.0-2669ed?style=for-the-badge)](CHANGELOG.md) +[![Version](https://img.shields.io/badge/version-2.4.0-2669ed?style=for-the-badge)](CHANGELOG.md) [![Platform](https://img.shields.io/badge/platform-iOS-lightgrey?style=for-the-badge&logo=apple)](#requirements) [![License](https://img.shields.io/badge/license-Custom-orange?style=for-the-badge)](LICENSE.md) @@ -65,38 +65,39 @@ anyone to read, audit, or contribute to, so you can see exactly what's running o ## How to use it [siboot](https://github.com/FrizzleM/siboot) installs SideInstaller from the iPhone itself, signed -with your own Apple account: no computer and no certificate. It's one command in Open Minis, with -LocalDevVPN connected; no other app is needed. You need iOS 27 or later, Wi-Fi, Developer Mode on -and Open Minis 1.16 or later. [sideinstaller.net](https://sideinstaller.net/install.html) shows the -same steps. +with your own Apple account: no computer and no certificate. It's one command in rootshell, with +LocalDevVPN connected. You need iOS 27 or later, Wi-Fi and Developer Mode on. +[sideinstaller.net](https://sideinstaller.net/install.html) shows the same steps, with screenshots +and a shortcut that runs the command for you. -1. **Get the apps.** Install [Open Minis](https://apps.apple.com/app/id6759188481) and +1. **Get the apps.** Install [rootshell](https://apps.apple.com/app/id6755794662) and [LocalDevVPN](https://apps.apple.com/app/id6755608044), both free on the App Store. -2. **Run siboot in Open Minis.** Connect LocalDevVPN. In Open Minis, tap the console icon at the - top right, then **Shell Terminal**, and run: +2. **Set up rootshell.** In rootshell's Settings › General, turn on **Location Diary Mode** (it + keeps siboot running behind Safari and Settings) and **Terminal Notifications** (the pairing + code comes as one); in Settings › Terminal, turn on **Open Links from Programs**. Tap **Allow** + when rootshell asks for the local network. +3. **Run siboot in rootshell.** Connect LocalDevVPN, then paste this into rootshell and press + Return: ```sh - wget -qO- https://raw.githubusercontent.com/FrizzleM/siboot/main/minis/install.sh | sh + sh -c "$(curl -fsSL https://raw.githubusercontent.com/FrizzleM/siboot/main/rootshell/install.sh)" ``` - siboot opens a page over the terminal and says what to do. The first time, it pairs the iPhone - with itself: tap **Start pairing**, open **Settings › Privacy & Security › Developer Mode**, - scroll to the bottom, tap **Pair with siboot**, and enter your passcode and the 6-digit code - siboot shows. Leave the player that opens over Minis alone, and go back to Minis once Settings - says it's paired (later runs use the saved pairing). Then enter your Apple account email, - password and verification code. Keep Minis open until it says it's done. The first time, trust - your Apple account in **Settings › General › VPN & Device Management**. -3. **Open SideInstaller.** With LocalDevVPN connected, log in with your Apple account and tap + siboot opens its page in Safari. Pick SideInstaller on the Install tab and tap **Install**. The + first time, it pairs the iPhone with itself: tap **Start pairing**, open **Settings › Privacy & + Security › Developer Mode**, scroll to the bottom, tap **Pair with siboot**, and enter your + passcode and the 6-digit code siboot shows. Go back to Safari once Settings says it's paired + (later runs use the saved pairing). Then enter your Apple account email, password and + verification code. The first time, trust your Apple account in **Settings › General › VPN & + Device Management**. +4. **Open SideInstaller.** With LocalDevVPN connected, log in with your Apple account and tap **Install SideStore** or **Install SideStore + LiveContainer**. -Once paired, `siboot developer-mode` in Open Minis asks the iPhone to show the Developer Mode switch -in Settings, or with `--turn-on` to turn it on ([details](https://github.com/FrizzleM/siboot/blob/main/minis/README.md#developer-mode)). - ### Legacy: enterprise certificates Before iOS 27, or if siboot doesn't work for you, install SideInstaller with one of the enterprise certificates at [sideinstaller.net/#legacy](https://sideinstaller.net/#legacy) instead, then go on -from step 3. +from step 4. ### Links diff --git a/ios-app/AppsView.swift b/ios-app/AppsView.swift index 5569925f..ff10511d 100644 --- a/ios-app/AppsView.swift +++ b/ios-app/AppsView.swift @@ -470,6 +470,10 @@ final class SideloadedAppsManager: ObservableObject { let matched = ProfileMatcher.match(apps: apps, profiles: profiles) entries = matched.entries unmatched = matched.unmatched + // What SideInstaller installed and is gone is forgotten. + let onDevice = Set(inventory.apps.compactMap { $0["CFBundleIdentifier"] as? String }) + if !onDevice.isEmpty { InstalledAppsLedger.keep(onDevice) } + recorded = InstalledAppsLedger.installed() await rebuildRefreshable() hasLoaded = true lastRefreshed = Date() @@ -481,12 +485,61 @@ final class SideloadedAppsManager: ObservableObject { /// Re-signs and reinstalls every refreshable app, one at a time (they share /// one device link and signing queue, and Apple's API is rate-limited). func refreshAll() { - guard !isRefreshing, !isWorking, !refreshable.isEmpty else { return } + refresh(refreshable) + } + + /// Refreshes `selected`, unless a load, a refresh or an install runs. + private func refresh(_ selected: [RefreshJob]) { + guard !isRefreshing, !isWorking, !selected.isEmpty else { return } guard !engine.isRunning else { lastError = ErrorHelp.explained(L("An install is already running. Wait for it to finish, then refresh.")) return } - startRefresh(refreshable, showsFailure: true) + startRefresh(selected, showsFailure: true) + } + + // MARK: - My apps + + /// The bundle IDs SideInstaller recorded installing, as of the last read. + @Published private(set) var recorded: Set = [] + + /// The listed apps SideInstaller installed, for the My apps tab. + var mine: [SideloadedAppStatus] { + MyApps.select(entries, recorded: recorded, refreshable: refreshable) + } + + /// The refresh jobs for `mine`. + var mineRefreshable: [RefreshJob] { + let ids = Set(mine.map(\.id)) + return refreshable.filter { ids.contains($0.bundleID) } + } + + /// The job that refreshes `bundleID`, when there's an IPA to refresh it from. + func job(for bundleID: String) -> RefreshJob? { + refreshable.first { $0.bundleID == bundleID } + } + + /// My apps' Refresh all. + func refreshMine() { + refresh(mineRefreshable) + } + + /// My apps' Refresh on one app. + func refresh(bundleID: String) { + refresh(job(for: bundleID).map { [$0] } ?? []) + } + + /// The read when the My apps tab shows: the first time, as `autoLoad`, + /// and again once SideInstaller has installed an app the last read + /// didn't have, so the new app is listed. + func autoLoadMine() { + guard hasLoaded else { return autoLoad() } + guard !isWorking, !isRefreshing, + !InstalledAppsLedger.installed().isSubset(of: recorded) else { return } + engine.refreshNetworkStatus() + guard engine.vpnConnected, + !NetworkStatus.links().mobileDataOnly || MobileDataMode.shared.mayHaveOpenTunnel else { return } + load(quiet: true) } /// Refreshes `selected` in the background, as the page lists them. A run diff --git a/ios-app/ChineseStrings.swift b/ios-app/ChineseStrings.swift index b7efc4bf..c5c8b528 100644 --- a/ios-app/ChineseStrings.swift +++ b/ios-app/ChineseStrings.swift @@ -1480,4 +1480,16 @@ let chineseStrings: [String: String] = [ "蜂窝数据", "Mobile Data Mode": "蜂窝数据模式", + + // My apps: the apps SideInstaller installed. + "My apps": + "我的应用", + "No apps yet": + "还没有应用", + "Apps SideInstaller installs show up here, with how long they have left.": + "SideInstaller 安装的应用会显示在这里,并注明剩余时间。", + "Apps on a free Apple ID last seven days. Refreshing one starts its seven days again.": + "免费 Apple ID 的应用可用七天。续签后,七天重新开始计算。", + "Its IPA is gone. Install it again to refresh it.": + "它的 IPA 已不在了。重新安装后才能续签。", ] diff --git a/ios-app/Engine.swift b/ios-app/Engine.swift index 43790350..1b5bbc3a 100644 --- a/ios-app/Engine.swift +++ b/ios-app/Engine.swift @@ -2223,6 +2223,10 @@ final class Engine { throw EngineError.appLimit } installProgress = 1 + // So My apps can tell it from apps other tools installed. + if let installed = signedAppBundleID() { + InstalledAppsLedger.record(installed) + } setStep(.install, .done) } diff --git a/ios-app/FrenchStrings.swift b/ios-app/FrenchStrings.swift index ef781a30..8d102208 100644 --- a/ios-app/FrenchStrings.swift +++ b/ios-app/FrenchStrings.swift @@ -1535,4 +1535,16 @@ let frenchStrings: [String: String] = [ "Données cellulaires", "Mobile Data Mode": "Mode données cellulaires", + + // My apps: the apps SideInstaller installed. + "My apps": + "Mes apps", + "No apps yet": + "Aucune app pour l'instant", + "Apps SideInstaller installs show up here, with how long they have left.": + "Les apps installées par SideInstaller apparaissent ici, avec le temps qu'il leur reste.", + "Apps on a free Apple ID last seven days. Refreshing one starts its seven days again.": + "Les apps d'un Apple ID gratuit durent sept jours. En renouveler une fait repartir ses sept jours.", + "Its IPA is gone. Install it again to refresh it.": + "Son IPA n'est plus là. Réinstallez-la pour la renouveler.", ] diff --git a/ios-app/ItalianStrings.swift b/ios-app/ItalianStrings.swift index 5d24dfca..b5312f43 100644 --- a/ios-app/ItalianStrings.swift +++ b/ios-app/ItalianStrings.swift @@ -1528,4 +1528,16 @@ let italianStrings: [String: String] = [ "Dati cellulare", "Mobile Data Mode": "Modalità dati cellulare", + + // My apps: the apps SideInstaller installed. + "My apps": + "Le mie app", + "No apps yet": + "Ancora nessuna app", + "Apps SideInstaller installs show up here, with how long they have left.": + "Le app installate da SideInstaller compaiono qui, con il tempo che resta a ciascuna.", + "Apps on a free Apple ID last seven days. Refreshing one starts its seven days again.": + "Le app di un Apple ID gratuito durano sette giorni. Rinnovandone una, i suoi sette giorni ripartono.", + "Its IPA is gone. Install it again to refresh it.": + "La sua IPA non c'è più. Installala di nuovo per rinnovarla.", ] diff --git a/ios-app/JapaneseStrings.swift b/ios-app/JapaneseStrings.swift index dbb53208..9ad233e9 100644 --- a/ios-app/JapaneseStrings.swift +++ b/ios-app/JapaneseStrings.swift @@ -1492,4 +1492,16 @@ let japaneseStrings: [String: String] = [ "モバイルデータ通信", "Mobile Data Mode": "モバイルデータモード", + + // My apps: the apps SideInstaller installed. + "My apps": + "マイアプリ", + "No apps yet": + "まだアプリがありません", + "Apps SideInstaller installs show up here, with how long they have left.": + "SideInstaller でインストールしたアプリが、残りの期間とともにここに表示されます。", + "Apps on a free Apple ID last seven days. Refreshing one starts its seven days again.": + "無料の Apple ID のアプリは7日間使えます。更新すると、7日間が数え直されます。", + "Its IPA is gone. Install it again to refresh it.": + "IPA が残っていません。更新するには、もう一度インストールしてください。", ] diff --git a/ios-app/KoreanStrings.swift b/ios-app/KoreanStrings.swift index 3172bfdb..310eb8a5 100644 --- a/ios-app/KoreanStrings.swift +++ b/ios-app/KoreanStrings.swift @@ -1494,4 +1494,16 @@ let koreanStrings: [String: String] = [ "모바일 데이터", "Mobile Data Mode": "모바일 데이터 모드", + + // My apps: the apps SideInstaller installed. + "My apps": + "내 앱", + "No apps yet": + "아직 앱이 없습니다", + "Apps SideInstaller installs show up here, with how long they have left.": + "SideInstaller로 설치한 앱이 남은 기간과 함께 여기에 표시됩니다.", + "Apps on a free Apple ID last seven days. Refreshing one starts its seven days again.": + "무료 Apple ID의 앱은 7일 동안 사용할 수 있습니다. 갱신하면 7일이 다시 시작됩니다.", + "Its IPA is gone. Install it again to refresh it.": + "IPA가 남아 있지 않습니다. 갱신하려면 다시 설치하세요.", ] diff --git a/ios-app/MyAppsView.swift b/ios-app/MyAppsView.swift new file mode 100644 index 00000000..5b5bf1ba --- /dev/null +++ b/ios-app/MyAppsView.swift @@ -0,0 +1,307 @@ +import SwiftUI + +// MARK: - What SideInstaller installed + +/// The apps SideInstaller installed, by the bundle ID they have on the device +/// (isideload's `.`), so My apps can tell them from apps +/// other tools installed. Each read of the device forgets the ones that are +/// gone. +enum InstalledAppsLedger { + /// Bundle ID → when SideInstaller installed it. + private static let key = "installedApps" + + private static func all(_ defaults: UserDefaults) -> [String: Date] { + defaults.dictionary(forKey: key)?.compactMapValues { $0 as? Date } ?? [:] + } + + /// The bundle IDs SideInstaller installed. + static func installed(_ defaults: UserDefaults = .standard) -> Set { + Set(all(defaults).keys) + } + + /// Notes an app SideInstaller has just installed. + static func record(_ bundleID: String, defaults: UserDefaults = .standard) { + var apps = all(defaults) + apps[bundleID] = Date() + defaults.set(apps, forKey: key) + } + + /// Forgets the apps that aren't among `onDevice` any more. + static func keep(_ onDevice: Set, defaults: UserDefaults = .standard) { + let apps = all(defaults) + let kept = apps.filter { onDevice.contains($0.key) } + if kept.count != apps.count { defaults.set(kept, forKey: key) } + } +} + +/// Which listed apps are SideInstaller's own. Static, so it's tested without +/// a device. +enum MyApps { + /// The apps SideInstaller recorded installing, and, from before it kept a + /// record, the ones it can sign again from an IPA it holds that carry the + /// team suffix its signing adds. + static func select(_ entries: [SideloadedAppStatus], recorded: Set, + refreshable: [RefreshJob]) -> [SideloadedAppStatus] { + let signedHere = Set(refreshable.filter { job in + guard let team = job.teamID, !team.isEmpty else { return false } + return job.bundleID.hasSuffix("." + team) + }.map(\.bundleID)) + return entries.filter { recorded.contains($0.id) || signedHere.contains($0.id) } + } + + /// Whose icon an installed app gets: SideInstaller's builds by their + /// bundle ID, anything else a custom IPA's plain tile. + static func source(of bundleID: String) -> InstallSource { + InstallSource.allCases.first { source in + source.pairingBundleIDBase.map { bundleID == $0 || bundleID.hasPrefix($0 + ".") } ?? false + } ?? .custom + } +} + +// MARK: - View + +/// The My apps tab: the apps SideInstaller installed that are still on this +/// iPhone, with how long each has left, refreshed one at a time or all +/// together. It's Tools › Sideloaded apps' list cut to SideInstaller's own, +/// from the same manager, so both pages show the same read and the same +/// refresh. +struct MyAppsView: View { + /// Observed so labels redraw when the language changes. + @EnvironmentObject private var loc: Localizer + /// Observed for `installProgress` during a refresh. + @Environment(Engine.self) private var engine + @ObservedObject var manager: SideloadedAppsManager + + @State private var showSettings = false + @State private var confirmRefresh = false + + var body: some View { + NavigationStack { + ScrollView { + VStack(spacing: 16) { + header.cascadeItem(0) + actions.cascadeItem(1) + list + } + .padding(20) + .pageColumn() + .animation(.smooth(duration: 0.35), value: manager.entries) + .animation(.smooth(duration: 0.3), value: manager.isWorking) + .animation(.smooth(duration: 0.35), value: manager.jobs) + .animation(.smooth(duration: 0.35), value: manager.refreshable) + } + .background(AppBackground()) + .toolbar { settingsToolbarItem(isPresented: $showSettings) } + .sheet(isPresented: $showSettings) { SettingsView() } + .onAppear { manager.autoLoadMine() } + .alert(L("Refresh all apps?"), isPresented: $confirmRefresh) { + Button(L("Refresh all")) { manager.refreshMine() } + Button(L("Cancel"), role: .cancel) { } + } message: { + let jobs = manager.mineRefreshable + Text(jobs.count == 1 + ? L("%@ will be signed again with your Apple ID and installed over the copy on this device. It keeps its data, and its seven days start over.", + jobs.first?.name ?? "") + : L("%d apps will be signed again with your Apple ID and installed over the copies on this device. They keep their data, and their seven days start over.", + jobs.count)) + } + } + } + + // MARK: Header + + private var header: some View { + BrandHeader(icon: "square.grid.2x2", image: "AppsLogo", title: L("My apps")) { + let mine = manager.mine + if manager.hasLoaded && !mine.isEmpty { + let expiring = mine.filter { [.expired, .critical].contains(ExpiryUrgency.of($0.current)) }.count + StatusDot(text: expiring > 0 + ? (expiring == 1 ? L("%d app needs refreshing", expiring) + : L("%d apps need refreshing", expiring)) + : (mine.count == 1 ? L("%d app", mine.count) : L("%d apps", mine.count)), + color: expiring > 0 ? Theme.warning : Theme.positive) + .transition(.opacity) + } + } + } + + // MARK: Actions + + /// Refresh all and Reload once the list is read (Cancel and what the + /// refresh is doing while it runs), Load apps before. + @ViewBuilder + private var actions: some View { + let refreshable = manager.mineRefreshable + VStack(spacing: 8) { + if manager.isRefreshing { + Button { } label: { + HStack(spacing: 8) { + ProgressView() + Text(manager.refreshStatus ?? L("Getting ready")).lineLimit(1) + } + } + .buttonStyle(PrimaryButtonStyle()) + .disabled(true) + // Only the install step reports progress. + if engine.installProgress > 0, engine.installProgress < 1 { + ProgressView(value: engine.installProgress).tint(Theme.accent) + } + Button(role: .cancel) { manager.cancelRefresh() } label: { + Text(L("Cancel")).frame(maxWidth: .infinity) + } + .buttonStyle(SecondaryButtonStyle(), sound: .tap) + .controlSize(.large) + } else if manager.hasLoaded && !refreshable.isEmpty { + Button { confirmRefresh = true } label: { + HStack(spacing: 8) { + Image(systemName: "arrow.triangle.2.circlepath") + Text(L("Refresh all")) + } + } + .buttonStyle(PrimaryButtonStyle()) + .disabled(manager.isWorking) + Button { manager.load() } label: { + loadLabel(spinner: Theme.accent).frame(maxWidth: .infinity) + } + .buttonStyle(SecondaryButtonStyle(), sound: .tap) + .controlSize(.large) + .disabled(manager.isWorking) + } else { + Button { manager.load() } label: { loadLabel(spinner: .white) } + .buttonStyle(PrimaryButtonStyle()) + .disabled(manager.isWorking) + } + // How the last refresh went, once one has. + Text((manager.isRefreshing ? nil : manager.refreshSummary) + ?? L("Apps on a free Apple ID last seven days. Refreshing one starts its seven days again.")) + .font(.caption) + .foregroundStyle(Theme.muted) + .multilineTextAlignment(.center) + .fixedSize(horizontal: false, vertical: true) + } + } + + private func loadLabel(spinner: Color) -> some View { + HStack(spacing: 8) { + if manager.isWorking { + ProgressView().tint(spinner) + Text(L("Reading the device")) + } else { + Image(systemName: manager.hasLoaded ? "arrow.clockwise" : "iphone.and.arrow.forward") + .contentTransition(.symbolEffect(.replace)) + Text(manager.hasLoaded ? L("Reload") : L("Load apps")) + } + } + } + + // MARK: List + + @ViewBuilder + private var list: some View { + let mine = manager.mine + if manager.hasLoaded && mine.isEmpty && !manager.isWorking { + emptyState + .transition(.cardAppear) + .cascadeItem(2) + } else if !mine.isEmpty { + // Enumerated so rows redraw on a language change. + ForEach(Array(mine.enumerated()), id: \.element.id) { idx, status in + row(status).cascadeItem(2 + idx) + } + } + } + + private func row(_ status: SideloadedAppStatus) -> some View { + let profile = status.current + let urgency = ExpiryUrgency.of(profile) + let job = manager.jobs.first { $0.bundleID == status.id } + let refreshable = manager.job(for: status.id) != nil + return PanelCard { + VStack(alignment: .leading, spacing: 8) { + HStack(spacing: 12) { + AppIconTile(source: MyApps.source(of: status.id), side: 44) + VStack(alignment: .leading, spacing: 4) { + HStack(alignment: .firstTextBaseline, spacing: 6) { + Text(status.app.name) + .font(.subheadline.weight(.medium)) + .lineLimit(1) + if let version = status.app.version, !version.isEmpty { + Text(version) + .font(.caption) + .foregroundStyle(Theme.muted) + .lineLimit(1) + } + } + HStack(spacing: 6) { + Image(systemName: urgency.symbol) + Text(ExpiryUrgency.text(for: profile)) + } + .font(.caption.weight(.medium)) + .foregroundStyle(urgency.color) + } + Spacer(minLength: 8) + trailing(job: job, status: status, refreshable: refreshable) + } + if case let .failed(message)? = job?.state { + Text(message) + .font(.caption2) + .foregroundStyle(.secondary) + .fixedSize(horizontal: false, vertical: true) + } else if !refreshable { + Text(L("Its IPA is gone. Install it again to refresh it.")) + .font(.caption2) + .foregroundStyle(Theme.muted) + .fixedSize(horizontal: false, vertical: true) + } + } + } + } + + /// The row's Refresh button, or how its refresh is going while one runs. + @ViewBuilder + private func trailing(job: RefreshJob?, status: SideloadedAppStatus, refreshable: Bool) -> some View { + switch manager.isRefreshing ? job?.state : nil { + case .pending?: + Text(L("Waiting")) + .font(.caption2.weight(.medium)) + .foregroundStyle(.secondary) + case .working?: + ProgressView().controlSize(.small) + case .done?: + Image(systemName: "checkmark.circle") + .foregroundStyle(Theme.positive) + .accessibilityLabel(L("Done")) + default: + if refreshable { + Button { manager.refresh(bundleID: status.id) } label: { + Text(L("Refresh")) + } + .buttonStyle(SecondaryButtonStyle(), sound: .tap) + .controlSize(.small) + .disabled(manager.isRefreshing || manager.isWorking) + } else if case .failed? = job?.state { + Image(systemName: "xmark.circle.fill") + .foregroundStyle(Theme.negative) + .accessibilityLabel(L("Failed")) + } + } + } + + private var emptyState: some View { + PanelCard { + VStack(spacing: 8) { + Image(systemName: "square.grid.2x2") + .font(.largeTitle) + .foregroundStyle(Theme.muted) + Text(L("No apps yet")) + .font(.headline) + Text(L("Apps SideInstaller installs show up here, with how long they have left.")) + .font(.footnote) + .foregroundStyle(.secondary) + .multilineTextAlignment(.center) + } + .frame(maxWidth: .infinity) + .padding(.vertical, 8) + } + } +} diff --git a/ios-app/PortugueseStrings.swift b/ios-app/PortugueseStrings.swift index 0bb83fe0..9ef97320 100644 --- a/ios-app/PortugueseStrings.swift +++ b/ios-app/PortugueseStrings.swift @@ -1520,4 +1520,16 @@ let portugueseStrings: [String: String] = [ "Dados celulares", "Mobile Data Mode": "Modo Dados Celulares", + + // My apps: the apps SideInstaller installed. + "My apps": + "Meus apps", + "No apps yet": + "Nenhum app ainda", + "Apps SideInstaller installs show up here, with how long they have left.": + "Os apps que o SideInstaller instala aparecem aqui, com o tempo que resta a cada um.", + "Apps on a free Apple ID last seven days. Refreshing one starts its seven days again.": + "Apps de um Apple ID gratuito duram sete dias. Ao renovar um, os sete dias dele começam de novo.", + "Its IPA is gone. Install it again to refresh it.": + "O IPA dele não está mais aqui. Instale de novo para renová-lo.", ] diff --git a/ios-app/RootView.swift b/ios-app/RootView.swift index 7582d35e..50ceda93 100644 --- a/ios-app/RootView.swift +++ b/ios-app/RootView.swift @@ -1,6 +1,6 @@ import SwiftUI -/// Tab container (Install, Tools, About). Each page draws its own +/// Tab container (Install, My apps, Tools, About). Each page draws its own /// `AppBackground`, since `TabView` would hide a shared one. Also hosts the /// sign-in sheet (2FA, and which team signs) and the pages' popups, so they /// show over any tab. @@ -8,7 +8,7 @@ struct RootView: View { /// The tabs. The selection is tracked so a tab switch can tick, and a /// link can bring the Install tab forward. private enum Page: Hashable { - case install, tools, about + case install, myApps, tools, about } /// What the sign-in sheet shows: a 2FA prompt, or which team signs. @@ -81,6 +81,9 @@ struct RootView: View { ContentView() .tabItem { Label(L("Install"), systemImage: "square.and.arrow.down") } .tag(Page.install) + MyAppsView(manager: appsManager) + .tabItem { Label(L("My apps"), systemImage: "square.grid.2x2") } + .tag(Page.myApps) ToolsView(pairingManager: pairingManager, certManager: certManager, locationManager: locationManager, diff --git a/ios-app/SpanishStrings.swift b/ios-app/SpanishStrings.swift index 6bb328a8..5f474a54 100644 --- a/ios-app/SpanishStrings.swift +++ b/ios-app/SpanishStrings.swift @@ -1531,4 +1531,16 @@ let spanishStrings: [String: String] = [ "Datos móviles", "Mobile Data Mode": "Modo datos móviles", + + // My apps: the apps SideInstaller installed. + "My apps": + "Mis apps", + "No apps yet": + "Aún no hay apps", + "Apps SideInstaller installs show up here, with how long they have left.": + "Las apps que instala SideInstaller aparecen aquí, con el tiempo que les queda.", + "Apps on a free Apple ID last seven days. Refreshing one starts its seven days again.": + "Las apps de un Apple ID gratuito duran siete días. Al renovar una, sus siete días empiezan de nuevo.", + "Its IPA is gone. Install it again to refresh it.": + "Su IPA ya no está. Vuelve a instalarla para renovarla.", ] diff --git a/ios-app/TurkishStrings.swift b/ios-app/TurkishStrings.swift index f9fcc1c7..4b1e17f0 100644 --- a/ios-app/TurkishStrings.swift +++ b/ios-app/TurkishStrings.swift @@ -1390,4 +1390,16 @@ let turkishStrings: [String: String] = [ "Mobil veri", "Mobile Data Mode": "Mobil Veri Modu", + + // My apps: the apps SideInstaller installed. + "My apps": + "Uygulamalarım", + "No apps yet": + "Henüz uygulama yok", + "Apps SideInstaller installs show up here, with how long they have left.": + "SideInstaller'ın yüklediği uygulamalar kalan süreleriyle birlikte burada görünür.", + "Apps on a free Apple ID last seven days. Refreshing one starts its seven days again.": + "Ücretsiz bir Apple kimliğindeki uygulamalar yedi gün çalışır. Birini yenilemek yedi gününü yeniden başlatır.", + "Its IPA is gone. Install it again to refresh it.": + "IPA'sı artık yok. Yenilemek için yeniden yükleyin.", ] diff --git a/ios-app/VietnameseStrings.swift b/ios-app/VietnameseStrings.swift index bef3344b..10aeca06 100644 --- a/ios-app/VietnameseStrings.swift +++ b/ios-app/VietnameseStrings.swift @@ -1526,4 +1526,16 @@ let vietnameseStrings: [String: String] = [ "Dữ liệu di động", "Mobile Data Mode": "Chế độ dữ liệu di động", + + // My apps: the apps SideInstaller installed. + "My apps": + "Ứng dụng của tôi", + "No apps yet": + "Chưa có ứng dụng nào", + "Apps SideInstaller installs show up here, with how long they have left.": + "Các ứng dụng do SideInstaller cài đặt sẽ hiện ở đây, kèm thời gian còn lại.", + "Apps on a free Apple ID last seven days. Refreshing one starts its seven days again.": + "Ứng dụng trên Apple ID miễn phí dùng được bảy ngày. Gia hạn một ứng dụng sẽ tính lại bảy ngày từ đầu.", + "Its IPA is gone. Install it again to refresh it.": + "Tệp IPA của ứng dụng này không còn nữa. Hãy cài lại để gia hạn.", ] diff --git a/ios-tests/MyAppsTests.swift b/ios-tests/MyAppsTests.swift new file mode 100644 index 00000000..a250f858 --- /dev/null +++ b/ios-tests/MyAppsTests.swift @@ -0,0 +1,67 @@ +import Foundation +import Testing +@testable import SideInstaller + +/// My apps' choice of which sideloaded apps are SideInstaller's, and the +/// record it keeps of what it installed. Bundle IDs and teams are made up. +@Suite("My apps") +struct MyAppsTests { + + private func app(_ bundleID: String) throws -> SideloadedAppStatus { + let app = try #require(SideloadedApp(plist: ["ProfileValidated": true, + "CFBundleIdentifier": bundleID, + "CFBundleDisplayName": bundleID])) + return SideloadedAppStatus(app: app, profiles: []) + } + + private func job(_ bundleID: String, team: String?) -> RefreshJob { + RefreshJob(bundleID: bundleID, name: bundleID, + ipa: URL(fileURLWithPath: "/tmp/\(bundleID).ipa"), teamID: team) + } + + /// A scratch suite, emptied first, so the test leaves the app's own alone. + private func defaults() throws -> UserDefaults { + let name = "MyAppsTests" + let defaults = try #require(UserDefaults(suiteName: name)) + defaults.removePersistentDomain(forName: name) + return defaults + } + + @Test("Mine are the apps it recorded, and those it signed from an IPA it holds") + func selects() throws { + let entries = try [ + app("com.SideStore.SideStore.ABCDE12345"), // recorded + app("com.kdt.livecontainer.ABCDE12345"), // from before the record: IPA + team suffix + app("com.SideStore.SideStore"), // an IPA it holds, signed by another tool + app("com.example.Feather"), // someone else's + ] + let mine = MyApps.select(entries, + recorded: ["com.SideStore.SideStore.ABCDE12345"], + refreshable: [job("com.kdt.livecontainer.ABCDE12345", team: "ABCDE12345"), + job("com.SideStore.SideStore", team: "ABCDE12345")]) + #expect(mine.map(\.id) == ["com.SideStore.SideStore.ABCDE12345", "com.kdt.livecontainer.ABCDE12345"]) + #expect(MyApps.select(entries, recorded: [], refreshable: [job("com.example.Feather", team: nil)]).isEmpty) + } + + @Test("An app's icon comes from its bundle ID") + func icons() { + #expect(MyApps.source(of: "com.SideStore.SideStore.ABCDE12345") == .sideStore) + #expect(MyApps.source(of: "com.kdt.livecontainer.ABCDE12345") == .liveContainer) + #expect(MyApps.source(of: "com.rileytestut.AltStore.ABCDE12345") == .altStore) + #expect(MyApps.source(of: "com.SideStore.SideStoreBeta") == .custom) + #expect(MyApps.source(of: "com.example.Feather.ABCDE12345") == .custom) + } + + @Test("The record keeps what was installed until it's gone from the device") + func ledger() throws { + let defaults = try defaults() + #expect(InstalledAppsLedger.installed(defaults).isEmpty) + InstalledAppsLedger.record("com.SideStore.SideStore.ABCDE12345", defaults: defaults) + InstalledAppsLedger.record("com.kdt.livecontainer.ABCDE12345", defaults: defaults) + #expect(InstalledAppsLedger.installed(defaults) == ["com.SideStore.SideStore.ABCDE12345", + "com.kdt.livecontainer.ABCDE12345"]) + InstalledAppsLedger.keep(["com.kdt.livecontainer.ABCDE12345", "com.apple.mobilesafari"], defaults: defaults) + #expect(InstalledAppsLedger.installed(defaults) == ["com.kdt.livecontainer.ABCDE12345"]) + defaults.removePersistentDomain(forName: "MyAppsTests") + } +}