codemagic-ci-cd / cli-tools

Various utilities to managing Android and iOS app builds, code signing, and deployment.
https://codemagic.io/start/
GNU General Public License v3.0
265 stars 42 forks source link

Improvement: Show error message if devices are not provided on development or ad-hoc profile creation #256

Closed VeArnold closed 2 years ago

VeArnold commented 2 years ago

When creating development and ad hoc provisioning profiles, Apple requires the existence of suitable test devices on the Apple Developer Portal.

Previous implementations did not check whether appropriate devices were included in the API call.

This lead to 409 responses from App Store Connect API Create Profile endpoint. For example a POST request to the https://api.appstoreconnect.apple.com/v1/profiles endpoint with the following content:

{
   "data":{
      "type":"profiles",
      "attributes":{
         "name":"profile name",
         "profileType":"IOS_APP_DEVELOPMENT"
      },
      "relationships":{
         "certificates":{
            "data":[
               {
                  "id":"13CO2HS7YE",
                  "type":"certificates"
               }
            ]
         },
         "devices":{},
         "bundleId":{
            "data":{
               "type":"bundleIds",
               "id":"22JL9M6NPV"
            }
         }
      }
   }
}

Results in the following response:

{
  "errors" : [ {
    "id" : "97c1dc61-f853-43c1-9996-36997eff095d",
    "status" : "409",
    "code" : "ENTITY_ERROR.RELATIONSHIP.REQUIRED",
    "title" : "Relationship is required but was not provided.",
    "detail" : "The relationship 'devices' is required but was not provided with this request.",
    "source" : {
      "pointer" : "data/relationships/devices"
    }
  } ]
}