Fastlane:向配置文件添加设备的正确方法是什么?

39

我正在使用fastlane来处理配置文件。

这是我所做的:

match nuke development 
match nuke distribution

然后在一个通道中,对于我需要提供的每个捆绑标识符,我都有这个:

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

当我想要下载配置文件时,我有一个执行此操作的通道:

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

所有这一切都让我可以在已经存在于门户中的设备上进行良好的工作和构建。

如果我想添加一个设备,我如何正确更新供应?

我尝试过这个:

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

它不起作用。

我收到了这个错误:

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

每次我需要添加设备时,唯一有效的方法就是清空所有内容并重新开始。

有没有不必清空就能添加设备的正确方法呢?

我正在使用Xcode 8,像fastlane建议的那样禁用了自动配置。

4个回答

74
自fastlane 2.8版本以来,有一种新的方式可以通过命令行添加设备。
要添加设备,请运行以下命令:fastlane run register_device udid:"1234…890" name:"My new iPhone" 要刷新开发者证书并包含此设备,请运行以下命令:fastlane match development --force 要获取连接手机的UDID(序列号),请简单运行命令:system_profiler SPUSBDataType | grep -A 11 -w "iPad\|iPhone\|iPad"

19

您需要调用 fastlane 命令来注册新设备

# 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: 'luka@goonbee.com'   # Optional, lets you override the Apple Member Center username.
)

然后你需要打电话

match development --force_for_new_devices

通过使用 force_for_new_devices 参数,match 将检查设备数量是否与上次运行时有所改变,并在必要时自动重新生成配置文件。您还可以使用 force:true 在每次运行时重新生成配置文件。

更新于 2016年12月20日 或者更为直观的方式

 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

2
我应该把这些“register_devices”命令放在哪里?在“Matchfile”中吗? - Hlung
我在Fastfile中有一个lane。在调用此lane之后。 - Jakub Průša
1
关于您的编辑 - 我猜refresh_profiles是一个运行match的通道,就像这个线程中所说的那样?https://github.com/fastlane/fastlane/issues/1999 - CupawnTae
是的,没错。它通过Match刷新所有配置文件:Debug、Adhoc和Appstore。 - Jakub Průša

7
更新:如果您正在尝试添加 iPhone XS 或 XS Max(或更新版本),则需要在第八位数字后添加一个破折号,否则它将无法成功添加(因为这两个设备的格式已更改,很可能 2018 年的 iPad Pro 也是如此)。例如,如果您的 UDID/序列号是"123456789123456789123456",则需要将其添加为"12345678-9123456789123456"
因此,要添加这些设备,您可以运行:
fastlane run register_device udid:"12345678-9123456789123456" name:"Bob's iPhone XS Max"

4

我刚遇到了这个问题... 'refresh_profiles' 命令抛出了一个错误。可能已经停用了?这个脚本之前对我来说完美地运行着:

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接