Swift实现iOS设备应用基础信息获取:应用清理工具开发问询
Great question—this is such a common roadblock for folks trying to build app cleanup tools on iOS, thanks to Apple’s strict privacy and security guardrails. Let’s break down what’s possible (and what’s not) when working with Swift:
What You Can’t Do (For Public App Store Apps)
- Get a full list of installed apps: There’s no public API that lets third-party apps enumerate every app installed on the device. Private frameworks like
LSApplicationWorkspacehave methods likeallInstalledApplications()that could do this, but using private APIs guarantees your app gets rejected during App Store review. - Access other apps’ usage data: Apple locks down metrics like last used time or total usage duration for any app besides your own. This is a core part of iOS’s privacy model—users expect their app activity to stay private, so Apple doesn’t expose this data to other apps.
What You Can Do (For Your Own App)
If you’re only tracking your app’s own usage, you have a couple solid options:
- Track active time manually: Use
UIApplicationDelegatemethods likeapplicationDidBecomeActive(_:)andapplicationWillResignActive(_:)to log when your app starts and stops. You can calculate total usage duration from these timestamps and store the data inUserDefaultsor a local database. - Leverage App Store Connect Analytics: For aggregate usage data across all your app’s users, you can access metrics like active sessions and total usage time through App Store Connect’s dashboard. But this is for your own developer insights, not something you can pull into the app itself for users.
Workarounds for Enterprise/Internal Apps
If you’re building an app strictly for internal enterprise use (not for the App Store), you might be able to use private APIs like LSApplicationWorkspace to list installed apps, or UsageStatsManager to pull usage data. But a big heads-up:
- These APIs are undocumented and can break with any iOS update.
- They violate Apple’s developer guidelines, so they’re completely off-limits for any app that needs to pass App Store review.
At the end of the day, Apple’s top priority is user privacy, so any tool that requires accessing other apps’ data or enumerating the full installed app list won’t make it through the App Store review process. You’ll need to adjust your app’s scope to work within these constraints.
内容的提问来源于stack exchange,提问作者D. Childs

