2015-08-27 106 views
4

我總新Ruby,但設法改變在Xcode基於項目的代碼簽名身份和供給曲線,像這樣:Xcode的變化代碼簽名身份xcodeproj

#!/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 

我的問題是根據目標代碼簽名標識和配置文件將覆蓋基於項目的配置文件。但我找不到一種方法來直接設置基於目標的方法。希望有人能幫到這裏。由於

回答

-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"

0

您可以訪問該項目的目標通過在project上呼叫native_targets,如下所示:

#!/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