app-store-version-check
Skill1 starsChanged 7 months agoMITView on GitHub
Add or fix in-app update checking for Apple platform apps, especially SwiftUI About pages that should show whether a newer App Store version exists and let users open the App Store or Mac App Store update page. Use when the user asks for "check latest version", "About page update button", "App Store version lookup", "Mac App Store update", "iTunes Lookup API", or when an attempted custom version endpoint returns 404.
In this repository12 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- cohosted-frontend-backendSkill
- dotnet-cpmSkill
- gitmojiSkill
- markdown-outputSkill
- oidc-integrationSkill
- ponytail-workspace-agentsSkill
- repo-memorySkill
- skoruba-adminui-on-duendeSkill
- specflow-to-reqnrollSkill
- tddSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
25 rules. About 0 are common, 20 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈20
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Use this skill when adding update visibility to an iOS, iPadOS, or macOS app.
- Very specific: line 27
Instead, scrape the App Store product page HTML.
- Distinctive: line 41
Only use iTunes Lookup when:
- Distinctive: line 48
Use a custom static JSON endpoint only when the app needs non-App-Store channels such as TestFlight, enterprise distribution, staged …
- Distinctive: line 54
When implementing in a codebase that expects TDD, follow red-green-refactor:
- Distinctive: line 56
Write pure logic tests first.
- Distinctive: line 57
Verify they fail for the missing implementation.
- Distinctive: line 60
Add view-model or UI state tests.
- Distinctive: line 63
Run the focused tests and a platform build.
- Distinctive: line 77
Keep network out of unit tests.
- Distinctive: line 82
Create a small service with pure static helpers and one network method:
- Very specific: line 159
Create a @MainActor observable view model for SwiftUI:
- Distinctive: line 206
Keep current version and build rows.
- Distinctive: line 207
Add a "latest version" or "update" row below them.
- Very specific: line 208
Start the check with .task { await viewModel.checkForUpdates() }.
- Distinctive: line 218
Do not implement direct binary update installation for App Store apps.
- Distinctive: line 223
When adding this feature, platform-specific compile errors elsewhere can block validation.
- Very specific: line 232
If withUnsafeBytes warns that the result is unused, assign to _ = when the side effect is intentional.
- Distinctive: line 235
Keep these fixes separate from the version-check behavior unless they are needed only to restore the same focused build.
- Distinctive: line 240
Run focused tests first:
- Distinctive: line 270
If the requested simulator name is unavailable, inspect Xcode's available destinations and rerun with an existing simulator.
- Very specific: line 296
Check both ?platform=iphone and ?platform=mac pages before implementing.
- Distinctive: line 298
If the app has both TestFlight and App Store channels, explain the distinction: the App Store page reports the public App Store version, …
- Distinctive: line 300
Use custom metadata only if TestFlight/latest-beta visibility is explicitly required.
- Distinctive: line 310
Always use the App Store product page HTML scraping approach: when you need accurate per-platform versions.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
App Store Version Check
Use this skill when adding update visibility to an iOS, iPadOS, or macOS app. The common goal is: show the current app version, check whether the App Store has a newer public version, and let the user open the App Store or Mac App Store page from the About screen.
Core Decision
Do NOT use the iTunes Lookup API for universal apps that ship separate iOS and
Mac App Store builds. The iTunes Lookup API (itunes.apple.com/lookup) only
returns the iOS App Store version, even for universal apps that have a different
(often older) version on the Mac App Store. The entity=macSoftware parameter
does not fix this.
Instead, scrape the App Store product page HTML. The page contains a
Version X.Y.Z string in the "What's New" section that reflects the correct
per-platform version.
| Platform | URL |
| iOS | https://apps.apple.com/us/app/<name>/id<APP_ID>?platform=iphone |
| macOS | https://apps.apple.com/us/app/<name>/id<APP_ID>?platform=mac |
The platform query parameter selects the correct storefront. The HTML reliably
contains Version X.Y.Z (e.g. Version 1.0.6 for Mac, Version 1.1.10 for iOS).
When iTunes Lookup IS acceptable
Only use iTunes Lookup when:
- The app is iOS-only (no Mac App Store listing).
- The iOS and Mac App Store versions are always identical (rare for universal apps).
- You only need the iOS version and don't care about Mac App Store accuracy.
When to use a custom endpoint
Use a custom static JSON endpoint only when the app needs non-App-Store channels such as TestFlight, enterprise distribution, staged rollout metadata, forced minimum version, or release notes not available from Apple.
TDD Workflow
When implementing in a codebase that expects TDD, follow red-green-refactor:
- Write pure logic tests first.
- Verify they fail for the missing implementation.
- Implement the smallest service code.
- Verify tests pass.
- Add view-model or UI state tests.
- Verify they fail.
- Implement the About page integration.
- Run the focused tests and a platform build.
Good first tests:
- Version comparison:
1.2.0is newer than1.1.11. - Same version is not newer.
- Older App Store version is not an update.
- Two-part and four-part versions compare correctly.
storePageURL(platform:)returns correctplatform=iphone/platform=macURL.parseVersionFromHTML(data:)extracts"1.0.6"from HTML containingVersion 1.0.6.parseVersionFromHTML(data:)extracts from localized labels such as版本 1.0.6.parseVersionFromHTML(data:)extracts from metadata fields like"versionDisplay":"1.0.6".parseVersionFromHTML(data:)returnsnilwhen no version string is present.parseVersionFromHTML(data:)throwsmalformedResponseon invalid UTF-8 data.
Keep network out of unit tests. Test parsing with HTML string fixtures and inject a mockable service protocol into the view model.
Recommended Swift Structure
Create a small service with pure static helpers and one network method:
struct AppStoreVersionInfo: Equatable {
let latestVersion: String
let storeURL: URL
}
enum AppStorePlatform {
case iOS
case macOS
}
protocol VersionCheckServiceProtocol: AnyObject {
func fetchLatestVersion() async throws -> AppStoreVersionInfo
}
final class VersionCheckService: VersionCheckServiceProtocol {
static let appStoreAppId = "<APP_ID>"
let platform: AppStorePlatform
#if os(macOS)
private static var defaultPlatform: AppStorePlatform { .macOS }
#else
private static var defaultPlatform: AppStorePlatform { .iOS }
#endif
/// Builds the App Store product-page URL for the given platform.
static func storePageURL(platform: AppStorePlatform) -> URL {
let param = platform == .iOS ? "iphone" : "mac"
return URL(string: "https://apps.apple.com/us/app/<name>/id\(appStoreAppId)?platform=\(param)")!
}
/// Extracts the version string from an App Store product-page HTML body.
/// Tries multiple patterns seen on App Store pages:
/// `Version X.Y.Z`, `版本 X.Y.Z`, and metadata such as `versionDisplay`.
static func parseVersionFromHTML(data: Data) throws -> String? {
guard let html = String(data: data, encoding: .utf8) else {
throw VersionCheckError.malformedResponse
}
let patterns = [
"(?:Version|版本)\\s*[::]?\\s*(\\d+(?:\\.\\d+){1,3})",
"\\\"versionDisplay\\\"\\s*:\\s*\\\"(\\d+(?:\\.\\d+){1,3})\\\"",
"\\\"softwareVersion\\\"\\s*:\\s*\\\"(\\d+(?:\\.\\d+){1,3})\\\""
]
let range = NSRange(html.startIndex..., in: html)
for pattern in patterns {
guard let regex = try? NSRegularExpression(pattern: pattern, options: [.caseInsensitive]) else {
continue
}
if let match = regex.firstMatch(in: html, range: range),
match.numberOfRanges >= 2,
let versionRange = Range(match.range(at: 1), in: html) {
return String(html[versionRange])
}
}
return nil
}
static func isVersion(_ latest: String, newerThan current: String) -> Bool {
let latestParts = latest.split(separator: ".").compactMap { Int($0) }
let currentParts = current.split(separator: ".").compactMap { Int($0) }
let count = max(latestParts.count, currentParts.count)
for index in 0..<count {
let latestPart = index < latestParts.count ? latestParts[index] : 0
let currentPart = index < currentParts.count ? currentParts[index] : 0
if latestPart > currentPart { return true }
if latestPart < currentPart { return false }
}
return false
}
}Create a @MainActor observable view model for SwiftUI:
enum VersionCheckState: Equatable {
case idle
case checking
case upToDate(latestVersion: String)
case updateAvailable(info: AppStoreVersionInfo)
case failed(String)
}
@MainActor
final class VersionCheckViewModel: ObservableObject {
@Published var state: VersionCheckState = .idle
var service: VersionCheckServiceProtocol
var currentVersion: String
var updateURL: URL? {
if case .updateAvailable(let info) = state {
return info.storeURL
}
return nil
}
init(currentVersion: String, service: VersionCheckServiceProtocol) {
self.currentVersion = currentVersion
self.service = service
}
func checkForUpdates() async {
state = .checking
do {
let info = try await service.fetchLatestVersion()
state = VersionCheckService.isVersion(info.latestVersion, newerThan: currentVersion)
? .updateAvailable(info: info)
: .upToDate(latestVersion: info.latestVersion)
} catch {
state = .failed(error.localizedDescription)
}
}
}SwiftUI About Page Pattern
On the About page:
- Keep current version and build rows.
- Add a "latest version" or "update" row below them.
- Start the check with
.task { await viewModel.checkForUpdates() }. - For
.checking, show a progress indicator or "checking..." text. - For
.updateAvailable, show the latest version and an "Update" button. - Open
trackViewUrlvia@Environment(\.openURL). - For
.upToDate, show a neutral "No update available" message. If the local version is ahead of App Store (common after local/TestFlight builds), avoid saying "latest App Store version" in a misleading way. - For
.failed, show a short non-blocking error reason (for example429) and a retry button on the same row. Keep the message concise with truncation.
Do not implement direct binary update installation for App Store apps. Opening Apple's store URL is the correct fallback and usually the right behavior.
Platform Build Pitfalls
When adding this feature, platform-specific compile errors elsewhere can block validation. Fix them narrowly when they are real platform API issues:
FileManager.default.homeDirectoryForCurrentUseris unavailable on iOS. Use a sandbox-safe fallback such as Application Support on iOS, and keephomeDirectoryForCurrentUserbehind#if os(macOS)if needed.SecCertificateCopyValues,kSecOIDX509V1ValidityNotAfter, andkSecPropertyKeyValueare macOS-oriented Security APIs. Guard certificate value parsing with#if os(macOS)or provide an iOS-safe alternative.- If
withUnsafeByteswarns that the result is unused, assign to_ =when the side effect is intentional.
Keep these fixes separate from the version-check behavior unless they are needed only to restore the same focused build.
Validation
Run focused tests first:
xcodebuild test \
-scheme <SCHEME> \
-project <PROJECT>.xcodeproj \
-destination 'platform=macOS' \
-only-testing:<TestTarget>/VersionCheckServiceTestsThen run About/view-model tests:
xcodebuild test \
-scheme <SCHEME> \
-project <PROJECT>.xcodeproj \
-destination 'platform=macOS' \
-only-testing:<TestTarget>/AboutViewVersionCheckTestsFinally run at least one target platform build, usually iOS Simulator for a universal app:
xcodebuild build \
-scheme <SCHEME> \
-project <PROJECT>.xcodeproj \
-destination 'platform=iOS Simulator,name=<AVAILABLE_DEVICE>'If the requested simulator name is unavailable, inspect Xcode's available destinations and rerun with an existing simulator.
For a live sanity check of the per-platform version:
# iOS App Store version
curl -fsSL 'https://apps.apple.com/us/app/<name>/id<APP_ID>?platform=iphone' | grep -oE 'Version [0-9]+\.[0-9]+\.[0-9]+' | head -1
# Mac App Store version
curl -fsSL 'https://apps.apple.com/us/app/<name>/id<APP_ID>?platform=mac' | grep -oE 'Version [0-9]+\.[0-9]+\.[0-9]+' | head -1Confirm the two platforms return different versions if the app ships separate builds.
Source of Truth Checklist
Before coding, locate:
- App Store app ID in CI config, marketing metadata, or App Store links.
- Bundle current version from
CFBundleShortVersionString. - Bundle build number from
CFBundleVersion. - Existing About page implementation.
- Existing test style and platform destinations.
Critical: verify per-platform versions independently. For universal apps,
the iOS App Store and Mac App Store often have different version numbers.
Check both ?platform=iphone and ?platform=mac pages before implementing.
If the app has both TestFlight and App Store channels, explain the distinction: the App Store page reports the public App Store version, not TestFlight. Use custom metadata only if TestFlight/latest-beta visibility is explicitly required.
Key Lesson: iTunes Lookup API Limitation
The iTunes Lookup API (itunes.apple.com/lookup) is not reliable for Mac App
Store version checking on universal apps. It returns the iOS App Store version
regardless of the entity parameter. The entity=macSoftware parameter does
not fix this.
Always use the App Store product page HTML scraping approach when you need
accurate per-platform versions. The platform=mac vs platform=iphone query
parameter on the App Store web page is the only reliable way to get the correct
version for each platform.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

