Fastlane: proper way to add a device to provisioning?

17,317

Solution 1

Since fastlane version 2.8 there is a new way to add a device via the command line

fastlane run register_device udid:"1234…890" name:"My new iPhone"

To refresh e.g. the the developer provision profile to include this device run:

fastlane match development --force


To get the udid(serial number) of a connected phone simply run the command system_profiler SPUSBDataType | grep -A 11 -w "iPad\|iPhone\|iPad"

Solution 2

You call fastlane command for registering new device

# Simply provide a list of devices as a Hash
register_devices(
  devices: {
    'Luka iPhone 6' => '1234567890123456789012345678901234567890',
    'Felix iPad Air 2' => 'abcdefghijklmnopqrstvuwxyzabcdefghijklmn',
  }
)

# Alternatively provide a standard UDID export .txt file, see the Apple Sample (https://devimages.apple.com.edgekey.net/downloads/devices/Multiple-Upload-Samples.zip)
register_devices(
  devices_file: './devices.txt'
)

# Advanced
register_devices(
  devices_file: './devices.txt', # You must pass in either `devices_file` or `devices`.
  team_id: 'XXXXXXXXXX',         # Optional, if you're a member of multiple teams, then you need to pass the team ID here.
  username: '[email protected]'   # Optional, lets you override the Apple Member Center username.
)

And after you need to call

match development --force_for_new_devices

By using the force_for_new_devices parameter, match will check if the device count has changed since the last time you ran match, and automatically re-generate the provisioning profile if necessary. You can also use force: true to re-generate the provisioning profile on each run.

UPDATE 20.12.2016 Or more intuitive way

 desc "Register new device"
  lane :register_new_device do  |options|
      device_name = prompt(text: "Enter the device name: ")
      device_udid = prompt(text: "Enter the device UDID: ")
      device_hash = {}
      device_hash[device_name] = device_udid
      register_devices(
                       devices: device_hash
                       )
    refresh_profiles
  end

Solution 3

Update: If you're trying to add an iPhone XS or XS Max (or newer), you'll need to add a dash after the eighth digit or else it will not successfully add (since the format is changed for these two devices, and presumably 2018 iPad Pros as well). Example, if your UDID/Serial Number is "123456789123456789123456" you'll want to add it as "12345678-9123456789123456".

So, to add these devices you can run:

fastlane run register_device udid:"12345678-9123456789123456" name:"Bob's iPhone XS Max"

Solution 4

Just ran into this problem... the 'refresh_profiles' command threw an error. Might be deprecated? This script worked perfectly for me:

desc "Register new devices"
lane :register do
  device_name = prompt(text: "Enter the device name: ")
  device_udid = prompt(text: "Enter the device UDID: ")
  device_hash = {}
  device_hash[device_name] = device_udid
  register_devices(devices: device_hash)
  match(force: true)
end
Share:
17,317
zumzum
Author by

zumzum

Updated on June 15, 2022

Comments

  • zumzum
    zumzum almost 2 years

    I am using fastlane to handle provisioning.

    This is what I did:

    match nuke development 
    match nuke distribution
    

    then in a lane I have this for each bundleId I need to provision for:

    match(type: "development", app_identifier: "com.myCompany.myApp", force_for_new_devices: true)
    

    When I want to download the provisioning I have a lane that does this:

    match(type: "development", app_identifier: "com.myCompany.myApp", readonly: true)
    

    All this lets me work and build fine on devices that were ALREADY in the portal at the time of nuke.

    How do I update provisioning correctly if I want to add a device?

    I tried this:

    match development --force_for_new_devices true -a com.myCompany.myApp
    

    It does not work.

    I get this error:

    Provisioning profile '82afbd5b-9f19-4c78-b3ac-56a3565ce3f2' is not available on the Developer Portal
    

    The only thing that works every time I have to add a device is to nuke everything and start fresh.

    What's the proper way to add a device without having to nuke??

    I am using Xcode 8, I disabled the automatic provisioning like suggested by fastlane.