Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Check a Mac app sold with its iPhone version against its Mac listing

Țugui Dragoș667e8a20dd26
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index f56874af..0820ffa9 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -325,9 +325,11 @@ macOS asks the user to approve it once. It talks to the app over XPC.
settings from. It asks on its own only while Check for app updates is on (`OwnUpdateCheck`), and the update
round of the other apps passes over Peel.
- **Updates of other apps.** `UpdateChecker` asks each app's own feed, or the App Store about an app from the App
- Store, and uses what Homebrew knows for an app a cask installed. Every answer that changes nothing makes the next
- check of that app wait longer, up to a week (`UpdateSchedule`), and `UpdateMemory` keeps the last answer across
- launches.
+ Store, and uses what Homebrew knows for an app a cask installed. From the App Store it reads the listing of the
+ installed bundle (`AppStoreListing`): the Mac's, which Apple gives for the desktop, also for an app sold once for
+ iPhone and Mac, or the iPhone and iPad one for an app of those devices installed on the Mac. Every answer that
+ changes nothing makes the next check of that app wait longer, up to a week (`UpdateSchedule`), and `UpdateMemory`
+ keeps the last answer across launches.
- **Orphaned Files.** `OrphanScanner` lists what no installed app claims, under the app Peel saw go when it can
name it (`AppMemory`), and selects nothing for the person.
- **Resetting an app.** `AppReset` selects an app's settings, caches, and window state, which the app makes again
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 3c576213..34260f7d 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -158675,108 +158675,108 @@
}
}
},
- "The App Store doesn’t give a Mac version of %@ that Peel can compare. It lists some apps under one entry for all the devices they run on, with the iPhone’s version, and nothing for an app it doesn’t sell in this region. The App Store app itself knows when there is an update." : {
+ "The App Store gives Peel no version of %@ to compare, as for an app it doesn’t sell in your Mac’s region or doesn’t sell anymore. The App Store app itself knows when there is an update." : {
"localizations" : {
"cs" : {
"stringUnit" : {
"state" : "translated",
- "value" : "U aplikace %@ neudává App Store žádnou verzi pro Mac, kterou by Peel dokázal porovnat. App Store uvádí některé aplikace pod jednou položkou pro všechna zařízení, na kterých běží, s verzí pro iPhone a u aplikace, kterou v této oblasti neprodává, neuvádí nic. Kdy je k dispozici aktualizace, ví sama aplikace App Store."
+ "value" : "U aplikace %@ neudává App Store žádnou verzi, kterou by Peel dokázal porovnat, jako u aplikace, kterou v oblasti vašeho Macu neprodává nebo už neprodává. Kdy je k dispozici aktualizace, ví sama aplikace App Store."
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Der App Store gibt keine Mac-Version von „%@“ an, mit der Peel vergleichen kann. Er führt einige Apps mit der Version des iPhone unter einem Eintrag für alle Geräte, auf denen sie laufen, und eine App, die er in dieser Region nicht verkauft, führt er gar nicht. Die App „App Store“ selbst weiß, wann es ein Update gibt."
+ "value" : "Der App Store gibt keine Version von „%@“ an, mit der Peel vergleichen kann, etwa bei einer App, die er in der Region deines Mac nicht oder nicht mehr verkauft. Die App „App Store“ selbst weiß, wann es ein Update gibt."
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
- "value" : "App Store no indica una versión de %@ para Mac que Peel pueda comparar. Muestra algunas apps en una sola ficha para todos los dispositivos en los que funcionan, con la versión del iPhone, y no muestra nada de una app que no vende en esta región. La propia app App Store sabe cuándo hay una actualización."
+ "value" : "App Store no indica ninguna versión de %@ que Peel pueda comparar, como en el caso de una app que no vende en la región de tu Mac o que ya no vende. La propia app App Store sabe cuándo hay una actualización."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
- "value" : "L’App Store n’indique pas de version Mac de %@ que Peel puisse comparer. Il répertorie certaines apps sous une seule fiche pour tous les appareils sur lesquels elles fonctionnent, avec la version de l’iPhone, et n’a aucune fiche pour une app qu’il ne vend pas dans cette région. L’app App Store elle-même sait quand une mise à jour est disponible."
+ "value" : "L’App Store n’indique pas de version de %@ que Peel puisse comparer, comme c’est le cas pour une app qu’il ne vend pas dans la région de votre Mac ou qu’il ne vend plus. L’app App Store elle-même sait quand une mise à jour est disponible."
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
- "value" : "App Store non riporta una versione per Mac di %@ che Peel possa confrontare. Alcune app sono elencate in un’unica scheda per tutti i dispositivi su cui funzionano, con la versione per iPhone, e un’app che non è in vendita in questa zona non ha nessuna scheda. È l’app App Store a sapere quando c’è un aggiornamento."
+ "value" : "App Store non riporta nessuna versione di %@ che Peel possa confrontare, come accade per un’app che non è in vendita nella zona del Mac o che non è più in vendita. È l’app App Store a sapere quando c’è un aggiornamento."
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
- "value" : "App Storeは、“%@”について、Peelが比較できるMac版のバージョンを示していません。一部のアプリについては、対応するすべてのデバイス共通の1つの項目として掲載してiPhone版のバージョンを示し、この地域では販売していないアプリについては何も掲載していません。アップデートがあるかどうかは、App Storeアプリ自体が把握しています。"
+ "value" : "App Storeは、“%@”について、Peelが比較できるバージョンを示していません。Macの地域では販売していないアプリや、販売を終了したアプリの場合と同様です。アップデートがあるかどうかは、App Storeアプリ自体が把握しています。"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
- "value" : "App Store는 ‘%@’에 대해 Peel이 비교할 수 있는 Mac용 버전을 알려 주지 않습니다. 일부 앱을 실행되는 모든 기기에 대해 하나의 항목으로 표시하면서 iPhone용 버전을 알려 주고, 이 지역에서 판매하지 않는 앱에 대해서는 아무것도 표시하지 않습니다. 업데이트가 있는지는 App Store 앱이 알고 있습니다."
+ "value" : "App Store는 ‘%@’에 대해 Peel이 비교할 수 있는 버전을 알려 주지 않습니다. Mac의 지역에서 판매하지 않거나 더 이상 판매하지 않는 앱의 경우가 그렇습니다. 업데이트가 있는지는 App Store 앱이 알고 있습니다."
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Voor %@ vermeldt de App Store geen Mac-versie die Peel kan vergelijken. De App Store toont sommige apps als één onderdeel voor alle apparaten waarop ze werken, met de versie voor de iPhone, en niets voor een app die hij in deze regio niet verkoopt. De App Store-app zelf weet wanneer er een update is."
+ "value" : "Voor %@ vermeldt de App Store geen versie die Peel kan vergelijken, zoals bij een app die hij in de regio van je Mac niet verkoopt of niet meer verkoopt. De App Store-app zelf weet wanneer er een update is."
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
- "value" : "App Store nie podaje wersji aplikacji %@ dla Maca, którą Peel mógłby porównać z zainstalowaną. Wyświetla niektóre aplikacje jako jedną pozycję dla wszystkich urządzeń, na których działają, podając wersję dla iPhone’a, a dla aplikacji, której nie sprzedaje w tym regionie, nie wyświetla nic. Sama aplikacja App Store wie, kiedy jest dostępne uaktualnienie."
+ "value" : "App Store nie podaje wersji aplikacji %@, którą Peel mógłby porównać z zainstalowaną, jak w przypadku aplikacji, której nie sprzedaje w regionie Twojego Maca lub już nie sprzedaje. Sama aplikacja App Store wie, kiedy jest dostępne uaktualnienie."
}
},
"pt" : {
"stringUnit" : {
"state" : "translated",
- "value" : "A App Store não informa uma versão de %@ para Mac que o Peel consiga comparar. Ela lista alguns apps em uma única entrada para todos os dispositivos em que eles funcionam, com a versão do iPhone, e não lista nada para um app que ela não vende nesta região. O próprio app App Store sabe quando há uma atualização."
+ "value" : "A App Store não informa nenhuma versão de %@ para o Peel comparar, como no caso de um app que ela não vende na região do seu Mac ou que não vende mais. O próprio app App Store sabe quando há uma atualização."
}
},
"ro" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Pentru %@, App Store nu indică nicio versiune pentru Mac pe care Peel să o poată compara. Listează unele aplicații sub o singură intrare pentru toate dispozitivele pe care rulează, cu versiunea pentru iPhone, iar pentru o aplicație pe care nu o vinde în această regiune nu listează nimic. Aplicația App Store însăși știe când există o actualizare."
+ "value" : "Pentru %@, App Store nu indică nicio versiune pe care Peel să o poată compara, ca în cazul unei aplicații pe care nu o vinde în regiunea Mac‑ului dvs. sau nu o mai vinde. Aplicația App Store însăși știe când există o actualizare."
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
- "value" : "App Store не сообщает версию приложения «%@» для Mac, которую Peel мог бы сравнить с установленной. Некоторые приложения указаны там одной записью для всех устройств, на которых они работают, и версия в ней относится к iPhone, а для приложения, которое не продается в этом регионе, нет никакой записи. Само приложение App Store знает, когда выходит обновление."
+ "value" : "App Store не сообщает версию приложения «%@», которую Peel мог бы сравнить с установленной, как бывает с приложением, которое не продается в регионе Вашего Mac или больше не продается. Само приложение App Store знает, когда выходит обновление."
}
},
"sv" : {
"stringUnit" : {
"state" : "translated",
- "value" : "App Store anger ingen version av %@ för Mac som Peel kan jämföra med. Den listar vissa appar under en och samma post för alla enheter som de fungerar på, med versionen för iPhone, och har ingenting för en app som den inte säljer i den här regionen. Appen App Store vet själv när det finns en uppdatering."
+ "value" : "App Store anger ingen version av %@ som Peel kan jämföra med, till exempel för en app som den inte säljer i datorns region eller inte längre säljer. Appen App Store vet själv när det finns en uppdatering."
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
- "value" : "App Store, %@ uygulaması için Peel’in karşılaştırabileceği bir Mac sürümü vermiyor. Bazı uygulamaları çalıştıkları tüm aygıtlar için tek bir kayıt altında, iPhone sürümüyle listeler; bu bölgede satmadığı bir uygulama için ise hiçbir şey listelemez. Ne zaman güncelleme olduğunu App Store uygulamasının kendisi bilir."
+ "value" : "App Store, Mac’inizin bölgesinde satmadığı veya artık satmadığı bir uygulama için olduğu gibi, %@ uygulaması için de Peel’in karşılaştırabileceği bir sürüm vermiyor. Ne zaman güncelleme olduğunu App Store uygulamasının kendisi bilir."
}
},
"uk" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Для програми «%@» App Store не повідомляє версії для Mac, яку Peel може порівняти. App Store показує деякі програми одним записом для всіх пристроїв, на яких вони працюють, і повідомляє версію для iPhone, а для програми, яку не продає в цьому регіоні, не показує нічого. Про наявність оновлення знає сама програма App Store."
+ "value" : "Для програми «%@» App Store не повідомляє версії, яку Peel може порівняти, як буває з програмою, яку App Store не продає в регіоні вашого Mac або більше не продає. Про наявність оновлення знає сама програма App Store."
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "App Store没有给出“%@”Mac版的版本号供Peel比较。它对某些App支持的所有设备只列出一个条目,给出的版本号是iPhone版的;对于它在此地区不销售的App,则不列出任何条目。App Store App本身知道何时有更新。"
+ "value" : "App Store没有给出“%@”的版本号供Peel比较,例如它在你的Mac所设置的地区不销售或已不再销售的App就是如此。App Store App本身知道何时有更新。"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
- "value" : "App Store沒有提供Peel能比對的「%@」Mac版本。它會將某些App在其支援的所有裝置上列為同一個項目,而提供的版本是iPhone版;對於未在此地區販售的App,則不會列出任何項目。App Store App本身才知道何時有更新。"
+ "value" : "App Store沒有提供Peel能比對的「%@」版本,就像對於它未在你的Mac所設定的地區販售或已不再販售的App一樣。App Store App本身才知道何時有更新。"
}
}
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/AppStoreLookup.swift b/Packages/PeelCore/Sources/PeelCore/Updates/AppStoreLookup.swift
index 29bac1af..8bff0412 100644
--- a/Packages/PeelCore/Sources/PeelCore/Updates/AppStoreLookup.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Updates/AppStoreLookup.swift
@@ -6,32 +6,31 @@ enum AppStoreLookup {
/// as `artistName` gives it ("Apple" for Apple's own apps, where `sellerName` gives "Apple Inc."), and what
/// is new in that version, as plain text.
case listed(version: String, page: URL?, developer: String?, notes: ReleaseNotes? = nil)
- /// Apple answered, but with no record of the listing asked. An app sold as one purchase for iPhone, iPad,
- /// and Mac answers the Mac's question with a single record of kind "software" that carries the iPhone
- /// version, which cannot be compared with the Mac app's. Apple also answers with no record at all for an
- /// app the store doesn't sell in this region, or doesn't sell anymore. Neither is a failed lookup.
+ /// Apple answered, but with no record of the listing asked, as for an app the store doesn't sell in this
+ /// region, or doesn't sell anymore. That is not a failed lookup.
case notListed
case unreadable
}
- static func url(bundleIdentifier: String, country: String) -> URL? {
+ static func url(bundleIdentifier: String, country: String, for listing: AppStoreListing) -> URL? {
var components = URLComponents(string: "https://itunes.apple.com/lookup")
components?.queryItems = [
URLQueryItem(name: "bundleId", value: bundleIdentifier),
URLQueryItem(name: "country", value: country),
]
+ if listing == .mac {
+ components?.queryItems?.append(URLQueryItem(name: "entity", value: "desktopSoftware"))
+ }
return components?.url
}
static func answer(in data: Data, for listing: AppStoreListing) -> Answer {
guard let results = (try? JSONDecoder().decode(Response.self, from: data))?.results else { return .unreadable }
- let kind = switch listing {
- case .mac: "mac-software"
- case .iPhoneAndiPad: "software"
- }
- guard let record = results.first(where: { $0.kind == kind }), let version = record.version else {
- return .notListed
+ let isListed: (Response.Result) -> Bool = switch listing {
+ case .mac: { $0.kind == "mac-software" || ($0.kind == "software" && $0.namesOnlyTheMac) }
+ case .iPhoneAndiPad: { $0.kind == "software" }
}
+ guard let record = results.first(where: isListed), let version = record.version else { return .notListed }
return .listed(
version: version,
page: record.trackViewUrl.flatMap(URL.init(string:)),
@@ -47,6 +46,14 @@ enum AppStoreLookup {
let trackViewUrl: String?
let artistName: String?
let releaseNotes: String?
+ let supportedDevices: [String]?
+
+ /// An app sold once for iPhone, iPad, and Mac answers the desktop question with a record of kind
+ /// "software" for the Mac alone, whose version can differ from the iPhone's.
+ var namesOnlyTheMac: Bool {
+ guard let devices = supportedDevices, devices.contains("MacDesktop-MacDesktop") else { return false }
+ return !devices.contains { $0.hasPrefix("iPhone") || $0.hasPrefix("iPad") || $0.hasPrefix("iPod") }
+ }
}
let results: [Result]
diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift
index 8e595633..8ace896a 100644
--- a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift
@@ -147,13 +147,13 @@ public struct UpdateChecker: Sendable {
guard app.isFromAppStore, let installed = app.version, let identifier = app.bundleIdentifier else {
return UpdateAnswer(status: .unsupported)
}
- var reply = await lookup(identifier, in: country)
+ let listing: AppStoreListing = if case .appStore(let listing) = app.updateFeed { listing } else { .mac }
+ var reply = await lookup(identifier, in: country, for: listing)
// A two-letter region with no store, such as Antarctica (AQ), is also refused with HTTP 400.
if reply.status == 400, country != "us" {
- reply = await lookup(identifier, in: "us")
+ reply = await lookup(identifier, in: "us", for: listing)
}
guard let data = reply.data else { return UpdateAnswer(status: .failed) }
- let listing: AppStoreListing = if case .appStore(let listing) = app.updateFeed { listing } else { .mac }
switch AppStoreLookup.answer(in: data, for: listing) {
case .unreadable:
return UpdateAnswer(status: .failed)
@@ -171,8 +171,10 @@ public struct UpdateChecker: Sendable {
}
}
- private func lookup(_ identifier: String, in country: String) async -> Reply {
- guard let url = AppStoreLookup.url(bundleIdentifier: identifier, country: country) else { return Reply() }
+ private func lookup(_ identifier: String, in country: String, for listing: AppStoreListing) async -> Reply {
+ guard let url = AppStoreLookup.url(bundleIdentifier: identifier, country: country, for: listing) else {
+ return Reply()
+ }
return await fetchReply(url)
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift
index 81ad15eb..a552df36 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift
@@ -13,6 +13,7 @@ private final class CannedProtocol: URLProtocol, @unchecked Sendable {
static let replies = Mutex<[String: Reply]>([:])
static let asked = Mutex<[String]>([])
+ static let addresses = Mutex<[String]>([])
override class func canInit(with request: URLRequest) -> Bool { true }
override class func canonicalRequest(for request: URLRequest) -> URLRequest { request }
@@ -21,6 +22,7 @@ private final class CannedProtocol: URLProtocol, @unchecked Sendable {
override func startLoading() {
let host = request.url?.host() ?? ""
Self.asked.withLock { $0.append(host) }
+ Self.addresses.withLock { $0.append(request.url?.absoluteString ?? "") }
guard let reply = Self.replies.withLock({ $0[host] }), let url = request.url,
let response = HTTPURLResponse(
url: url, statusCode: reply.status, httpVersion: "HTTP/1.1", headerFields: reply.headers
@@ -159,11 +161,7 @@ private final class CannedProtocol: URLProtocol, @unchecked Sendable {
#expect(await checker.status(for: fed, preference: .automatic, casks: [current]) == .upToDate)
}
- /// An app sold once for iPhone, iPad, and Mac has one record, of kind "software", whose version is the
- /// iPhone's. For an app the store doesn't sell in this region, or anymore, Apple answers with no record at
- /// all. Neither is a failed check: there is no Mac version to read, so the app is `.unsupported` and is asked
- /// about again in a week, rather than read as a feed that is down and asked again every few hours.
- @Test func aUniversalPurchaseIsNotAFailedCheck() async {
+ @Test func aMacAppReadsNoIPhoneRecord() async {
let sold = InstalledApp(
url: URL(filePath: "/Applications/Notes Pro.app"),
bundleIdentifier: "com.example.notes",
@@ -173,7 +171,7 @@ private final class CannedProtocol: URLProtocol, @unchecked Sendable {
updateFeed: .appStore(.mac)
)
- reply("itunes.apple.com", #"{"resultCount":1,"results":[{"kind":"software","version":"3.6.7","trackViewUrl":"https://apps.apple.com/app/id1"}]}"#)
+ reply("itunes.apple.com", #"{"resultCount":1,"results":[{"kind":"software","version":"3.6.7","supportedDevices":["MacDesktop-MacDesktop","iPhone5s-iPhone5s","iPadAir-iPadAir"],"trackViewUrl":"https://apps.apple.com/app/id1"}]}"#)
#expect(await checker.status(for: sold) == .unsupported)
reply("itunes.apple.com", #"{"resultCount":1,"results":[{"kind":"mac-software","version":"2.0","trackViewUrl":"https://apps.apple.com/app/id1"}]}"#)
@@ -193,6 +191,24 @@ private final class CannedProtocol: URLProtocol, @unchecked Sendable {
#expect(await checker.status(for: sold) == .failed, "an answer Peel can't read is still a failed check")
}
+ @Test func asksTheMacListingOfAMacAppSoldWithItsIPhoneVersion() async {
+ let notes = { (version: String) in
+ InstalledApp(
+ url: URL(filePath: "/Applications/Notes.app"), bundleIdentifier: "org.example.notes", name: "Notes",
+ version: version, isFromAppStore: true, updateFeed: .appStore(.mac)
+ )
+ }
+ CannedProtocol.addresses.withLock { $0 = [] }
+ reply("itunes.apple.com", #"{"resultCount":1,"results":[{"kind":"software","version":"7.1.30","supportedDevices":["MacDesktop-MacDesktop"],"trackViewUrl":"https://apps.apple.com/app/id1"}]}"#)
+ #expect(
+ await checker.status(for: notes("7.1.27"))
+ == .updateAvailable(version: "7.1.30", source: .appStore, releaseNotes: URL(string: "https://apps.apple.com/app/id1"))
+ )
+ #expect(await checker.status(for: notes("7.1.30")) == .upToDate)
+ let addresses = CannedProtocol.addresses.withLock { $0 }
+ #expect(addresses.count == 2 && addresses.allSatisfy { $0.contains("entity=desktopSoftware") })
+ }
+
@Test func checksAnIPhoneOrIPadAppOnTheMacAgainstItsOwnListing() async {
let wrapped = { (version: String) in
InstalledApp(
@@ -200,6 +216,7 @@ private final class CannedProtocol: URLProtocol, @unchecked Sendable {
name: "Weather", version: version, isFromAppStore: true, updateFeed: .appStore(.iPhoneAndiPad)
)
}
+ CannedProtocol.addresses.withLock { $0 = [] }
reply("itunes.apple.com", #"{"resultCount":1,"results":[{"kind":"software","version":"6.9.2","trackViewUrl":"https://apps.apple.com/app/id1","artistName":"Example LLC"}]}"#)
#expect(
await checker.status(for: wrapped("6.9.1"))
@@ -207,6 +224,7 @@ private final class CannedProtocol: URLProtocol, @unchecked Sendable {
)
#expect(await checker.answer(for: wrapped("6.9.1")).developer == "Example LLC")
#expect(await checker.status(for: wrapped("6.9.2")) == .upToDate)
+ #expect(CannedProtocol.addresses.withLock { $0 }.allSatisfy { !$0.contains("entity=") })
reply("itunes.apple.com", #"{"resultCount":1,"results":[{"kind":"mac-software","version":"7.0","trackViewUrl":"https://apps.apple.com/app/id1"}]}"#)
#expect(await checker.status(for: wrapped("6.9.2")) == .unsupported, "a Mac record says nothing of an iPad build")
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UpdateTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UpdateTests.swift
index f1436ad3..8fcc5324 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/UpdateTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/UpdateTests.swift
@@ -292,6 +292,12 @@ struct AppStoreLookupTests {
let iPhone = #"{"resultCount":1,"results":[{"kind":"software","version":"26.36.74"}]}"#
#expect(AppStoreLookup.answer(in: Data(iPhone.utf8), for: .mac) == .notListed)
+ let sharedWithTheIPhone = #"{"resultCount":1,"results":[{"kind":"software","version":"16.13.2","supportedDevices":["MacDesktop-MacDesktop","iPhone5s-iPhone5s","iPadAir-iPadAir"]}]}"#
+ #expect(AppStoreLookup.answer(in: Data(sharedWithTheIPhone.utf8), for: .mac) == .notListed)
+ let theMacs = #"{"resultCount":1,"results":[{"kind":"software","version":"16.13.1","supportedDevices":["MacDesktop-MacDesktop","Watch4-Watch4"]}]}"#
+ #expect(
+ AppStoreLookup.answer(in: Data(theMacs.utf8), for: .mac) == .listed(version: "16.13.1", page: nil, developer: nil)
+ )
// No record at all: the store doesn't sell the app in this region, or anymore. That is an answer too.
#expect(AppStoreLookup.answer(in: Data(#"{"resultCount":0,"results":[]}"#.utf8), for: .mac) == .notListed)
@@ -310,8 +316,13 @@ struct AppStoreLookupTests {
}
@Test func encodesLookupURL() {
- let url = AppStoreLookup.url(bundleIdentifier: "com.shazam.mac.Shazam", country: "ro")
- #expect(url?.absoluteString == "https://itunes.apple.com/lookup?bundleId=com.shazam.mac.Shazam&country=ro")
+ let mac = AppStoreLookup.url(bundleIdentifier: "com.shazam.mac.Shazam", country: "ro", for: .mac)
+ #expect(
+ mac?.absoluteString
+ == "https://itunes.apple.com/lookup?bundleId=com.shazam.mac.Shazam&country=ro&entity=desktopSoftware"
+ )
+ let iPad = AppStoreLookup.url(bundleIdentifier: "org.example.weather", country: "de", for: .iPhoneAndiPad)
+ #expect(iPad?.absoluteString == "https://itunes.apple.com/lookup?bundleId=org.example.weather&country=de")
}
}
diff --git a/Peel/Views/UpdateStatusBadge.swift b/Peel/Views/UpdateStatusBadge.swift
index d38d56b5..de49133b 100644
--- a/Peel/Views/UpdateStatusBadge.swift
+++ b/Peel/Views/UpdateStatusBadge.swift
@@ -64,7 +64,7 @@ struct UpdateStatusBadge: View {
} else if app.version == nil {
Text("\(app.name) doesn’t say which version it is, so Peel has nothing to compare an update with. Look for an update inside the app.")
} else if app.isFromAppStore {
- Text("The App Store doesn’t give a Mac version of \(app.name) that Peel can compare. It lists some apps under one entry for all the devices they run on, with the iPhone’s version, and nothing for an app it doesn’t sell in this region. The App Store app itself knows when there is an update.")
+ Text("The App Store gives Peel no version of \(app.name) to compare, as for an app it doesn’t sell in your Mac’s region or doesn’t sell anymore. The App Store app itself knows when there is an update.")
} else {
Text("\(app.name) doesn’t say where it updates from in a way Peel can read. Peel reads an app’s update feed from the app’s own files, and asking Apple about every app instead would send Apple a list of what is installed on this Mac. Look for an update inside the app.")
}