Search code examples
iosshelljenkinsprovisioning-profileios-provisioning

Command line way to test iOS mobile provisioning profile is still valid?


One reason a profile may be invalid according to Developer.Apple.com is that the certificate is now obsolete. Checking for the cert is covered in this post: Validate certificate and provisioning profile

I am interested more generally, how to test if the profile is now stale. Right now I find out with a very long delay, so it is impossible to decipher the cause of the invalidation. If I could run this command, say each time my build job runs on Jenkins, then I could be better able to failure analyze by noting exactly when the shift occurred from valid to invalid.


Solution

  • With a simple gem install, this can be achieved using fastlane's spaceship api, and the Developer portal doc shows an exact example.

    broken_profiles = Spaceship.provisioning_profile.all.find_all do |profile|
      # the below could be replaced with `!profile.valid?`, which takes longer but also verifies the code signing identity
      (profile.status == "Invalid" or profile.status == "Expired")
    end
    

    https://github.com/fastlane/fastlane/blob/master/spaceship/docs/DeveloperPortal.md