Knowing when your iOS app’s provisioning profile is going to expire

Chris Mash
3 min readDec 20, 2020
The provisioning profile file icon

As iOS devs I’m sure we’ve all come across the problem of the development version of our app suddenly failing to launch for our testers.

For an app that’s actively in development it may not be a hugely common issue as your latest build will always have your latest certificate and profile, so when that gets renewed it goes straight into your app. But if you’re like me and have a number of your own personal apps on your device that aren’t actively in development and will perhaps never make it to the App Store then it can be very annoying when they’re working one day and without warning they stop working because their provisioning profile has expired.

I started wondering if there was a way to get a warning when your profile is getting close to expiring, so you can get it sorted before you get locked out of your app.

If you have a snoop in the .app produced by Xcode you can see there’s a embedded.mobileprovision file, which is the provisioning profile the app was build with. If you open it up in TextEdit (or similar) you’ll see there’s a load of unreadable data but a fair amount of XML and an entry for ExpirationDate.

This file is fully accessible for you to load from your bundle at runtime, so your app can load it and parse out the expiration date.

Note: when running on the simulator the provisioning profile isn’t there (because it’s only required for a real device) so you won’t be able to read it from the app’s bundle unless you’re using a real device.

With an app able to get its profile’s expiry date it can do things like:

  • Display the expiry date somewhere for user’s to check
  • Show a warning alert on launch if the expiry date is within a certain amount of time
  • Schedule a local notification for a certain amount of time before expiry, so user’s don’t even need to run the app to get their warning

I also played around with a Run Script build phase to check the provisioning profile’s expiry date so that a build warning could be generated if it was expiring within a certain number of days. It can be annoying for anyone receiving an ad hoc build of your app to only have a few days to play with it!

Note: when building on the simulator the provisioning profile isn’t there so the warnings won’t appear in Run Script build phases unless you build for a real device or at least the ‘Any iOS Device’ build target.

This all works on iOS, watchOS, tvOS and macOS!

I’ve bundled all this up into a Swift Package on GitHub that you can feel free to use if you see benefit in this!

Feel free to read the follow-up blog I wrote about combining this package with Firebase to keep track of when all your apps are going to expire even more easily!

--

--

Chris Mash

iOS developer since 2012, previously console games developer at Sony and Activision. Twitter: @CJMash