Module: Pindo::XcodeCertHelper
- Included in:
- Command::Deploy::Cert, Command::Deploy::Configproj, Command::Deploy::Getitcinfo, Command::Deploy::Itcinfo, Command::Dev::Debug, Command::Dev::Pgyercert, Command::Utils::Renewcert
- Defined in:
- lib/pindo/module/cert/xcodecerthelper.rb
Instance Method Summary collapse
- #config_infoplist_cert(new_proj_name: nil, new_project_dir: nil, icloud_id: nil, group_id: nil, provisioning_info_array: nil) ⇒ Object
- #config_project_cert(new_proj_name: nil, new_project_dir: nil, cert_type: nil, platform_type: nil, team_id_vaule: nil, provisioning_info_array: nil) ⇒ Object
- #create_provisioning_info_array(build_type: nil, platform_type: nil) ⇒ Object
- #create_upload_cert_info(apple_id: nil, cert_type: nil, platform_type: nil) ⇒ Object
- #create_upload_provisioning_info(apple_id: nil, cert_type: nil, platform_type: nil, provisioning_info_array: nil) ⇒ Object
- #get_target_name_map ⇒ Object
- #modify_entitlements_plist(entitlements_plist_path: nil, group_id: nil, icloud_id: nil) ⇒ Object
- #modify_info_plist_icloud(plist_file_name: nil, icloud_id: nil) ⇒ Object
Instance Method Details
#config_infoplist_cert(new_proj_name: nil, new_project_dir: nil, icloud_id: nil, group_id: nil, provisioning_info_array: nil) ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/pindo/module/cert/xcodecerthelper.rb', line 201 def config_infoplist_cert(new_proj_name:nil, new_project_dir:nil, icloud_id:nil, group_id:nil, provisioning_info_array:nil) new_proj_fullname = File.join(new_project_dir, new_proj_name) + ".xcodeproj" project_obj = Xcodeproj::Project.open(new_proj_fullname) entitlements_plist_path = File.join(new_project_dir, new_proj_name + ".entitlements") project_obj.targets.each do |target| if target.product_type.include?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:framework]) || target.product_type.include?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:dynamic_library]) || target.product_type.include?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:static_library]) || target.product_type.include?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:bundle]) next end temp_entitlements_file = target.build_configurations.first.build_settings['CODE_SIGN_ENTITLEMENTS'] if !temp_entitlements_file.nil? && !temp_entitlements_file.empty? entitlements_plist_path = File.join(new_project_dir, temp_entitlements_file) if !File.exist?(entitlements_plist_path) raise Informative, "Target: #{target.name.to_s} 找不到文件 #{entitlements_plist_path}" end if !group_id.nil? modify_entitlements_plist(entitlements_plist_path:entitlements_plist_path, group_id:group_id) end if target.product_type.to_s.eql?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:application]) then add_swark_entitlement(entitlements_plist_path:entitlements_plist_path, bundle_id_dict:provisioning_info_array) if !icloud_id.nil? modify_entitlements_plist(entitlements_plist_path:entitlements_plist_path, icloud_id:icloud_id) end end end temp_info = target.build_configurations.first.build_settings['INFOPLIST_FILE'] if !temp_info.nil? && !temp_info.empty? info_plist_path = File.join(new_project_dir, temp_info) if !File.exist?(info_plist_path) raise Informative, "Missing Target #{target.name.to_s} Info.plist!!! #{info_plist_path} Modify Info.plist Error !!!" end if target.product_type.to_s.eql?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:application]) then if !icloud_id.nil? modify_info_plist_icloud(plist_file_name:info_plist_path, icloud_id:icloud_id) else modify_info_plist_icloud(plist_file_name:info_plist_path, icloud_id:nil) end end end end end |
#config_project_cert(new_proj_name: nil, new_project_dir: nil, cert_type: nil, platform_type: nil, team_id_vaule: nil, provisioning_info_array: nil) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/pindo/module/cert/xcodecerthelper.rb', line 60 def config_project_cert(new_proj_name:nil, new_project_dir:nil, cert_type:nil, platform_type:nil, team_id_vaule:nil, provisioning_info_array:nil) new_proj_fullname = File.join(new_project_dir, new_proj_name) + ".xcodeproj" new_project_obj = Xcodeproj::Project.open(new_proj_fullname) new_project_obj.root_object.build_configuration_list.set_setting('CODE_SIGN_IDENTITY[sdk=iphoneos*]', "Apple Distribution") new_project_obj.root_object.build_configuration_list.set_setting('CODE_SIGN_IDENTITY*', "Apple Distribution") if !platform_type.nil? && platform_type.downcase.eql?("macos") # new_project_obj.root_object.build_configuration_list.set_setting('CODE_SIGN_IDENTITY[sdk=iphoneos*]', nil) new_project_obj.root_object.build_configuration_list.build_configurations.each do |config| config.build_settings.delete('CODE_SIGN_IDENTITY[sdk=iphoneos*]') if config.build_settings.key?('CODE_SIGN_IDENTITY[sdk=iphoneos*]') end if cert_type.downcase.eql?("development") new_project_obj.root_object.build_configuration_list.set_setting('CODE_SIGN_IDENTITY[sdk=macosx*]', "Apple Development") new_project_obj.root_object.build_configuration_list.set_setting('CODE_SIGN_IDENTITY*', "Apple Development") elsif cert_type.downcase.eql?("appstore") new_project_obj.root_object.build_configuration_list.set_setting('CODE_SIGN_IDENTITY[sdk=macosx*]', "Apple Distribution") new_project_obj.root_object.build_configuration_list.set_setting('CODE_SIGN_IDENTITY*', "Apple Distribution") else new_project_obj.root_object.build_configuration_list.set_setting('CODE_SIGN_IDENTITY[sdk=macosx*]', "Developer ID Application") new_project_obj.root_object.build_configuration_list.set_setting('CODE_SIGN_IDENTITY*', "Developer ID Application") end else new_project_obj.root_object.build_configuration_list.build_configurations.each do |config| config.build_settings.delete('CODE_SIGN_IDENTITY[sdk=macosx*]') if config.build_settings.key?('CODE_SIGN_IDENTITY[sdk=macosx*]') end if cert_type.downcase.eql?("development") new_project_obj.root_object.build_configuration_list.set_setting('CODE_SIGN_IDENTITY[sdk=iphoneos*]', "Apple Development") new_project_obj.root_object.build_configuration_list.set_setting('CODE_SIGN_IDENTITY*', "Apple Development") else new_project_obj.root_object.build_configuration_list.set_setting('CODE_SIGN_IDENTITY[sdk=iphoneos*]', "Apple Distribution") new_project_obj.root_object.build_configuration_list.set_setting('CODE_SIGN_IDENTITY*', "Apple Distribution") end end new_project_obj.root_object.attributes['TargetAttributes'] = new_project_obj.root_object.attributes['TargetAttributes'] || {} target_atts_obj = new_project_obj.root_object.attributes['TargetAttributes'] target_map = get_target_name_map new_project_obj.targets.each do |target| if target.product_type.include?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:framework]) || target.product_type.include?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:dynamic_library]) || target.product_type.include?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:static_library]) || target.product_type.include?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:bundle]) next end provisioning_info = nil if target.product_type.include?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:application]) bundle_id_map_key = target_map["MainTarget"] provisioning_info = provisioning_info_array.select { |s| s["type"].to_s.eql?(bundle_id_map_key.to_s) }.first else target_map.each do |k, v| if target.name.to_s.end_with?(k) bundle_id_map_key = v.to_s provisioning_info = provisioning_info_array.select { |s| s["type"].to_s.eql?(bundle_id_map_key.to_s) }.first end end end # puts "=====1 target name: #{target.name.to_s} bundle_id_map_key: #{bundle_id_map_key} provisioning_info: #{provisioning_info}" if !provisioning_info.nil? target.build_configurations.each do |config| target_atts_obj[target.uuid] = target_atts_obj[target.uuid] || {} target_atts_obj[target.uuid]['DevelopmentTeam'] = team_id_vaule target_atts_obj[target.uuid]['ProvisioningStyle'] = "Manual" config.build_settings['DEVELOPMENT_TEAM'] = team_id_vaule config.build_settings['CODE_SIGN_STYLE'] = "Manual" config.build_settings['CODE_SIGN_IDENTITY'] = "Apple Distribution" config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = "Apple Distribution" if !platform_type.nil? && platform_type.downcase.eql?("macos") config.build_settings['DEVELOPMENT_TEAM[sdk=macosx*]'] = team_id_vaule # config.build_settings['DEVELOPMENT_TEAM[sdk=iphoneos*]'] = nil # config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = nil # config.build_settings['PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]'] = nil config.build_settings.delete('DEVELOPMENT_TEAM[sdk=iphoneos*]') if config.build_settings.key?('DEVELOPMENT_TEAM[sdk=iphoneos*]') config.build_settings.delete('CODE_SIGN_IDENTITY[sdk=iphoneos*]') if config.build_settings.key?('CODE_SIGN_IDENTITY[sdk=iphoneos*]') config.build_settings.delete('PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]') if config.build_settings.key?('PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]') if cert_type.downcase.eql?("development") config.build_settings['CODE_SIGN_IDENTITY'] = "Apple Development" config.build_settings['CODE_SIGN_IDENTITY[sdk=macosx*]'] = "Apple Development" elsif cert_type.downcase.eql?("appstore") config.build_settings['CODE_SIGN_IDENTITY'] = "Apple Distribution" config.build_settings['CODE_SIGN_IDENTITY[sdk=macosx*]'] = "Apple Distribution" else config.build_settings['CODE_SIGN_IDENTITY'] = "Developer ID Application" config.build_settings['CODE_SIGN_IDENTITY[sdk=macosx*]'] = "Developer ID Application" end if !provisioning_info.nil? config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = provisioning_info["bundle_id"] config.build_settings['PROVISIONING_PROFILE_SPECIFIER'] = provisioning_info['profile_name'] config.build_settings['PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]'] = provisioning_info['profile_name'] end else config.build_settings['DEVELOPMENT_TEAM[sdk=iphoneos*]'] = team_id_vaule # config.build_settings['DEVELOPMENT_TEAM[sdk=macosx*]'] = "" # config.build_settings['CODE_SIGN_IDENTITY[sdk=macosx*]'] = "" # config.build_settings['PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]'] = "" config.build_settings.delete('DEVELOPMENT_TEAM[sdk=macosx*]') if config.build_settings.key?('DEVELOPMENT_TEAM[sdk=macosx*]') config.build_settings.delete('CODE_SIGN_IDENTITY[sdk=macosx*]') if config.build_settings.key?('CODE_SIGN_IDENTITY[sdk=macosx*]') config.build_settings.delete('PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]') if config.build_settings.key?('PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]') if cert_type.downcase.eql?("development") config.build_settings['CODE_SIGN_IDENTITY'] = "Apple Development" config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = "Apple Development" else config.build_settings['CODE_SIGN_IDENTITY'] = "Apple Distribution" config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = "Apple Distribution" end if !provisioning_info.nil? config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = provisioning_info["bundle_id"] config.build_settings['PROVISIONING_PROFILE_SPECIFIER'] = provisioning_info['profile_name'] config.build_settings['PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]'] = provisioning_info['profile_name'] end end end end end new_project_obj.save end |
#create_provisioning_info_array(build_type: nil, platform_type: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/pindo/module/cert/xcodecerthelper.rb', line 27 def create_provisioning_info_array(build_type:nil, platform_type:nil) provisioning_info_array = [] bundle_id_map = get_bundle_id_map bundle_id_map.each do |type, bundle_id_temp| provisioning_info = {} provisioning_info['type'] = type provisioning_info['bundle_id'] = bundle_id_temp match_build_type = build_type if platform_type.downcase.include?("macos") && match_build_type.downcase.include?("adhoc") match_build_type = "developer_id" end name_temp = Match::Utils.environment_variable_name_profile_name(app_identifier: bundle_id_temp, type: match_build_type, platform:platform_type) provisioning_info['profile_name'] = ENV[name_temp] path_temp = Match::Utils.environment_variable_name_profile_path(app_identifier:bundle_id_temp,type: match_build_type, platform:platform_type) provisioning_info['profile_path'] = ENV[path_temp] signing_identity_key=Match::Utils.environment_variable_name_certificate_name(app_identifier: bundle_id_temp,type: match_build_type, platform:platform_type) provisioning_info["signing_identity"] = ENV[signing_identity_key] team_id_key = Match::Utils.environment_variable_name_team_id(app_identifier: bundle_id_temp,type:match_build_type, platform:platform_type) provisioning_info["team_id"] = ENV[team_id_key] provisioning_info_array << provisioning_info end return provisioning_info_array end |
#create_upload_cert_info(apple_id: nil, cert_type: nil, platform_type: nil) ⇒ Object
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
# File 'lib/pindo/module/cert/xcodecerthelper.rb', line 304 def create_upload_cert_info(apple_id:nil, cert_type:nil, platform_type:nil) cert_dest_dir = File.join(Dir.pwd, "cert") if !File.exist?(cert_dest_dir) FileUtils.mkdir_p(cert_dest_dir) end cert_type_temp = cert_type cert_sub_dir = cert_type.downcase if platform_type.downcase.eql?("macos") if cert_type.downcase.include?("development") cert_sub_dir = "development" elsif cert_type.downcase.eql?("appstore") cert_sub_dir = "distribution" else cert_type_temp = "developer_id" cert_sub_dir = "developer_id_application" end else if !cert_type.downcase.include?("development") cert_sub_dir = "distribution" end end cert_git_url = pindo_single_config.deploy_cert_giturl if apple_id.eql?(pindo_single_config.demo_apple_id) cert_git_url = pindo_single_config.dev_cert_giturl end cert_reponame = cert_git_url.split("/").last.chomp(".git") certs_dir = getcode_to_dir(reponame:cert_reponame, remote_url:cert_git_url, path: pindo_single_config.pindo_dir, new_branch:apple_id) keys = Dir[File.join(certs_dir, "certs", cert_sub_dir, "*.p12")] decrypt_password = AESHelper.fetch_password(keychain_name:cert_git_url) output_dir = Dir.mktmpdir key_path = AESHelper.decrypt_specific_file(src_file: keys.first, password:decrypt_password, output_dir: output_dir) if key_path.nil? || key_path.empty? || !File.exist?(key_path) AESHelper.delete_password(keychain_name:cert_git_url) raise Informative, "证书解析失败,密码错误!" end FileUtils.copy(key_path, File.join(cert_dest_dir, "#{cert_type_temp}.p12")) end |
#create_upload_provisioning_info(apple_id: nil, cert_type: nil, platform_type: nil, provisioning_info_array: nil) ⇒ Object
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/pindo/module/cert/xcodecerthelper.rb', line 348 def create_upload_provisioning_info(apple_id:nil, cert_type:nil, platform_type:nil, provisioning_info_array:nil) cert_dir = File.join(Dir.pwd, "cert") cert_json_file = File.join(cert_dir, "certs.json") if !File.exist?(cert_dir) FileUtils.mkdir_p(cert_dir) end cert_json = [] begin cert_json = JSON.parse(File.read(cert_json_file)) if File.exist?(cert_json_file) cert_json = cert_json || [] rescue StandardError => e cert_json = [] end bundle_id = provisioning_info_array.select { |s| s["type"].to_s.eql?("bundle_id") }.first["bundle_id"] team_id_vaule = provisioning_info_array.first["team_id"] bundle_id_signing_identity = provisioning_info_array.first["signing_identity"] account_cert_set = {} select_result= cert_json.select { |x| x["account_name"].eql?(apple_id) }.first if select_result.nil? account_cert_set = {} else account_cert_set = select_result cert_json.delete_if { |x| x["account_name"].eql?(apple_id) } end account_cert_set["account_name"] = apple_id account_cert_set["team_id"] = team_id_vaule account_cert_set["certs"] = account_cert_set["certs"] || [] cert_item = {} cert_item_result = account_cert_set["certs"].select { |x| x["cert_id"].eql?(bundle_id_signing_identity)}.first if cert_item_result.nil? cert_item = {} else cert_item = cert_item_result account_cert_set["certs"].delete_if { |x| x["cert_id"].eql?(bundle_id_signing_identity)} end provision_start_name = "Development" cert_type_temp = cert_type if platform_type.downcase.include?("macos") if cert_type.downcase.include?("development") provision_start_name = "development" elsif cert_type.downcase.eql?("appstore") provision_start_name = "appstore" else cert_type_temp = "developer_id" provision_start_name = "direct" end else if cert_type.downcase.include?("development") provision_start_name = "development" elsif cert_type.downcase.include?("adhoc") provision_start_name = "adhoc" else provision_start_name = "appstore" end end cert_item["cert_id"] = cert_item["cert_id"] || bundle_id_signing_identity cert_item["password"] = "goodcert1" cert_item["cert_file"] = "#{cert_type_temp}.p12" cert_item["cert_type"] = cert_type_temp cert_item["cert_provisioning_group"] = cert_item["cert_provisioning_group"] || [] cert_provisioning_group_item = {} provisioning_group_id = [cert_type_temp, platform_type, bundle_id].join("_") provisioning_group_result = cert_item["cert_provisioning_group"].select { |x| x["provisioning_group_id"].eql?(provisioning_group_id)}.first if provisioning_group_result.nil? cert_provisioning_group_item = {} else cert_provisioning_group_item = provisioning_group_result cert_item["cert_provisioning_group"].delete_if { |x| x["provisioning_group_id"].eql?(provisioning_group_id)} end cert_provisioning_group_item["provisioning_group_id"] = provisioning_group_id cert_provisioning_group_item["platform_type"] = platform_type cert_provisioning_group_item["provisioning_main_bundle_id"] = bundle_id cert_provisioning_group_item["provisioning_items"] = [] group_id = [provision_start_name, platform_type, bundle_id].join("_") provisioning_info_array.each do |provisioning_info| bundle_id_temp = provisioning_info['bundle_id'] provisioning_id = [provision_start_name, bundle_id_temp].join("_") real_path = provisioning_info["profile_path"] extname = File.extname(real_path) cert_provisioning_group_item["provisioning_items"] << { "bundle_id" => bundle_id_temp, "provisioning_id" => provisioning_id, "group_id" => group_id, "provisioning_file" => provisioning_id + extname } FileUtils.cp_r(real_path, File.join(cert_dir, provisioning_id + extname)) end cert_item["cert_provisioning_group"] << cert_provisioning_group_item account_cert_set["certs"] << cert_item cert_json << account_cert_set File.open(cert_json_file, "w") do |f| f.write(JSON.pretty_generate(cert_json.compact)) end return account_cert_set end |
#get_target_name_map ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pindo/module/cert/xcodecerthelper.rb', line 9 def get_target_name_map return { "MainTarget" => "bundle_id", "Content" => "bundle_id_pushcontent", "Service" => "bundle_id_pushservice", "Keyboard" => "bundle_id_keyboard", "iMessage" => "bundle_id_imessage", "Siri" => "bundle_id_siri", "SiriUI" => "bundle_id_siriui", "Widget" => "bundle_id_widget", "Extension" => "bundle_id_extension", "ExtensionAd" => "bundle_id_extensionad", "ExtensionPorn" => "bundle_id_extensionporn", "WatchApp" => "bundle_id_watchapp", "WatchAppComplication" => "bundle_id_watchapp_extension" } end |
#modify_entitlements_plist(entitlements_plist_path: nil, group_id: nil, icloud_id: nil) ⇒ Object
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/pindo/module/cert/xcodecerthelper.rb', line 256 def modify_entitlements_plist(entitlements_plist_path:nil, group_id:nil, icloud_id:nil) if File.exist?(entitlements_plist_path) entitlements_plist_dict = Xcodeproj::Plist.read_from_path(entitlements_plist_path) if !group_id.nil? && !entitlements_plist_dict['com.apple.security.application-groups'].nil? entitlements_plist_dict['com.apple.security.application-groups'] = [group_id] end if !icloud_id.nil? entitlements_plist_dict['com.apple.developer.icloud-container-identifiers'] = [icloud_id] entitlements_plist_dict['com.apple.developer.ubiquity-container-identifiers'] = [icloud_id] end Xcodeproj::Plist.write_to_path(entitlements_plist_dict, entitlements_plist_path) end end |
#modify_info_plist_icloud(plist_file_name: nil, icloud_id: nil) ⇒ Object
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/pindo/module/cert/xcodecerthelper.rb', line 275 def modify_info_plist_icloud(plist_file_name:nil, icloud_id:nil) if ! File.exist? (plist_file_name) raise Informative, "修改Info.list 路径错误!!! #{plist_file_name}" end if File.exist?(plist_file_name) info_plist_dict = Xcodeproj::Plist.read_from_path(plist_file_name) if !icloud_id.nil? temp_value = {} if !info_plist_dict['NSUbiquitousContainers'].nil? && info_plist_dict['NSUbiquitousContainers'].is_a?(Hash) info_plist_dict['NSUbiquitousContainers'].each do |key, value| if key.include?("iCloud.") temp_value = value break; end end end info_plist_dict['NSUbiquitousContainers'] = {} info_plist_dict['NSUbiquitousContainers'][icloud_id] = temp_value || {} else info_plist_dict['NSUbiquitousContainers'] = nil end Xcodeproj::Plist.write_to_path(info_plist_dict, plist_file_name) end end |