超级签名 - spaceship处理描述文件

前提

Mac 成功安装 fastlane!!!

spaceship文档

  • Spaceship对象文档
  • Developer Portal API
    所有的操作里面都是example代码范例

登录 & 选择关联开发组

Spaceship.login('[email protected]', 'xxxxx')

#选择关联开发组(个别账号关联多个开发组)
Spaceship.client.select_team(team_id:'N5235XXXX',team_name:'XXXXXXXX Network Technology Co., Ltd.')

同时也可以这么写(跟上面是等效的)

Spaceship::Portal.login("[email protected]", "XXXX")

创建App & 证书 & 描述文件

# 新建app
#app = Spaceship.app.create!(bundle_id: "com.yk.testing.ios", name: "SpaceshipTestApp")

#获取证书: apple_distribution xcode11之前用:production
cert = Spaceship.certificate.apple_distribution.all.first
#cert = Spaceship.certificate.apple_development.all.first

puts "certName: + #{cert}"

# 创建描述文件(不能重复创建名字相同的证书)
# ad_hoc:开发,app_store:发布赠书
# app.bundle_id = "com.yk.testing.ios"
profile = Spaceship.provisioning_profile.ad_hoc.create!(name:"testDevProFile",bundle_id: "com.yk.testing.ios",                                                         certificate: cert)

                                                           
puts("Created Profile " + profile.name)

# 下载描述文件
File.write("/Users/mac/Desktop/spaceship/aaa/#{profile.name}.mobileprovision", profile.download)

设备信息

disabled_devices = Spaceship::Portal.device.all(include_disabled: true).select do |device|
  
  puts "设备: #{device.name} UDID: #{device.udid}"
end

添加设备

# 获取所有设备
all_devices = Spaceship::Portal.device.all

# 查找设备
device = Spaceship::Portal.device.find_by_udid("4b4eb514629e8e486b....", include_disabled: true)

puts "设备: #{device}"

# 新增设备
#Spaceship::Portal.device.create!(name: "Private iPhone 6", udid: "5814abb3...")

描述文件更新设备

 # 证书更新设备
    profile.devices = Spaceship::Portal.device.all
    profile.update!

下载 & 更新PP证书范例

保存为 a.rb
执行:cd到指定目录 然后执行:ruby a.rb

require "spaceship"

#目标应用id
bundle_id = "com.dd.xxx.ios"
#pp证书下载路径
path = "/Users/mac/Desktop/spaceship/aaa/"
#账号密码(首次会进行双重认证)
Spaceship.login('[email protected]', 'xxxxxx')
#选择关联的开发组
Spaceship.client.select_team(team_id:'N5235XXXXX',team_name:'XXXXX Network Technology Co., Ltd.')

# 获取所有的development的描述文件

#downloadProfiles = Array.new
##downloadProfiles += Spaceship.provisioning_profile.app_store.all
#downloadProfiles += Spaceship.provisioning_profile.ad_hoc.all
#downloadProfiles += Spaceship.provisioning_profile.development.all
#
#downloadProfiles.each do |p|
#    puts "描述文件:  #{p.name} - 应用包名:  #{p.app.bundle_id}"
#    #打印所有证书名字
#    if p.app.bundle_id == bundle_id
#        File.write("#{path}#{p.name}.mobileprovision", p.download)
#        puts "\033[34m操作成功"
#        return
#    end
#end

# 获取指定bundld的描述证书

profile = Spaceship::Portal.provisioning_profile.ad_hoc.all.find { |p| p.app.bundle_id == bundle_id }
if profile == nil
    profile = Spaceship::Portal.provisioning_profile.development.all.find { |p| p.app.bundle_id == bundle_id }
end

if profile != nil
    # 证书更新设备
    profile.devices = Spaceship::Portal.device.all
    profile.update!
    
    File.write("#{path}#{profile.name}.mobileprovision", profile.download)
    puts "\033[34m操作成功"
    return
end



#获取证书: apple_distribution xcode11之前用:production
cert = Spaceship.certificate.apple_distribution.all.first
#cert = Spaceship.certificate.apple_development.all.first

puts "证书名字: #{cert}"

# 创建描述文件(不能重复创建名字相同的证书)
# 打包的方式。方式分别为 development, ad_hoc, app_store,in_house
# app.bundle_id = "com.yk.testing.ios"
profile = Spaceship.provisioning_profile.ad_hoc.create!(name:bundle_id,bundle_id: bundle_id,                                                         certificate: cert)

# 证书更新设备
profile.devices = Spaceship::Portal.device.all
profile.update!

puts("创建描述文件: " + profile.name)

# 下载描述文件
File.write("#{path}#{profile.name}.mobileprovision", profile.download)

puts "\033[34m操作成功"


你可能感兴趣的:(超级签名 - spaceship处理描述文件)