5

I'm totally new to Ruby but managed to change the project based code signing identity and provisioning profile in xcode like so:

#!/usr/bin/env ruby

require 'xcodeproj'

xcproj = Xcodeproj::Project.open("MyProject.xcodeproj")

xcproj.build_configurations.each do |item|
    item.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = "iOS Development: xxxxxx xxxx (xxxxxxxxx)"
end

xcproj.build_configurations.each do |item|
    item.build_settings['PROVISIONING_PROFILE[sdk=iphoneos*]'] = "628352b1-9b78-xxxx-xxxx-xxxxxxxxx"
end

xcproj.save

My problem is the target based code signing identity and provisioning profile will override the project based one. But I can't find a method to directly set the target based one. Hope someone can help here. Thanks

4

2 回答 2

1

您可以使用该xcodebuild工具更改代码签名标识和配置文件,而不是直接编辑项目 (.xcodeproj) 文件:

xcodebuild -sdk <iphoneos> -target <target_name> -configuration <Debug> CODE_SIGN_IDENTITY="iOS Development: xxxxxx xxxx (xxxxxxxxx)" PROVISIONING_PROFILE="628352b1-9b78-xxxx-xxxx-xxxxxxxxx"

于 2015-08-27T05:52:50.550 回答
1

您可以通过调用来访问项目的目标native_targetsproject如下所示:

#!/usr/bin/env ruby

require 'xcodeproj'

xcproj = Xcodeproj::Project.open("MyProject.xcodeproj")
target = xcproj.native_targets.detect { |target| target.name == "MyTarget" }

target.build_configurations.each do |item|
  item.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = "iOS Development: xxxxxx xxxx (xxxxxxxxx)"
end

target.build_configurations.each do |item|
  item.build_settings['PROVISIONING_PROFILE[sdk=iphoneos*]'] = "628352b1-9b78-xxxx-xxxx-xxxxxxxxx"
end

xcproj.save
于 2017-10-12T22:14:53.313 回答