Dmytro
Dmytro

Reputation: 2552

API to get a provisioning profile from Apple dev site

I'm wondering if it's possible to get the latest provisioning profile from Apple Developer Portal using API? I've set up CI for iOS project but I have to update provisioning profile manually every time when it is changed so I'd be glad to automate this process as well. Thanks

Upvotes: 9

Views: 5499

Answers (6)

Akhil
Akhil

Reputation: 126

For anyone looking to download profiles using AppStoreConnect API

  1. Authenticate
  2. Get the profile id
  1. Get the profile information (response will be json) - read_and_download_profile_information
  2. From the profile information json, get the value for ['data']['attributes']['profileContent'] key. This would be base64 string, write to a file or variable.
  3. Decode base64 string to create the profile.
  • shell - base64 --decode path/to/file > profile.mobileprovision
  • python - base64.b64decode(profile_content_string)

Upvotes: 0

blacktide
blacktide

Reputation: 12076

I've found the easiest way to do this is to use sigh which is part of fastlane. On Mac just run the following:

brew install fastlane
fastlane sigh download_all

This will download all of the profiles for your account.

You can also download an individual app by passing in a bundle ID:

fastlane sigh -a com.my.app

It will create one if it doesn't exist and will repair it if it's expired or invalid.

If you want to do this without the "interactive" mode of entering your username and password you can just set the FASTLANE_USER and FASTLANE_PASSWORD environment variables to your Apple account email and password (and FASTLANE_TEAM_ID if you have multiple teams).

Upvotes: 0

dwery
dwery

Reputation: 1116

Spaceship provides access to he developer portal API, no web scraping!

Upvotes: 6

Steven Fransen
Steven Fransen

Reputation: 49

Use cupertino ruby script

There is a branch instead as the main one has not been updated since the portal is changed.

https://github.com/MatthewMaker/cupertino

Upvotes: 4

Dmytro
Dmytro

Reputation: 2552

I came up with the following solution:

  • create a special repo which has only up to date profiles (I know there is still human factor but I have not found better solution at the moment)

  • checout the repo with profiles before a build and copy it to the /User/$USER/Library/Library/MobileDevice/Provisioning Profiles

  • grep to find a profile hash and pass the hash as a build option (e.g

xcodebuild -target ${TargetName} -sdk "${TARGET_SDK}" -configuration "Ad Hoc" "CODE_SIGN_IDENTITY[sdk=iphoneos*]=${PROFILE_NAME}" "PROVISIONING_PROFILE=${grep results}"

)

The solution works for me but still has some issues.

Upvotes: 0

Jim
Jim

Reputation: 73936

I'm afraid not. You should be able to get it done by scraping the HTML, but that's about it. Apple are terrible when it comes to the web (client-side excepted).

Upvotes: 1

Related Questions