From 9d0fc89bff807e0fe7abefc6edd1f448ea0801cf Mon Sep 17 00:00:00 2001 From: henteko Date: Thu, 20 Oct 2016 18:16:37 +0900 Subject: [PATCH] get automatically manage ProvisioningProfile team --- lib/deploygate/commands/deploy/build.rb | 4 ++- lib/deploygate/xcode/analyze.rb | 38 ++++++++++++++++++++++--- lib/deploygate/xcode/export.rb | 11 ++++--- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/lib/deploygate/commands/deploy/build.rb b/lib/deploygate/commands/deploy/build.rb index 47ea16f..d97a895 100644 --- a/lib/deploygate/commands/deploy/build.rb +++ b/lib/deploygate/commands/deploy/build.rb @@ -33,7 +33,9 @@ def ios(workspaces, options) bundle_identifier = analyze.target_bundle_identifier xcode_provisioning_profile_uuid = analyze.target_xcode_setting_provisioning_profile_uuid - target_provisioning_profile = DeployGate::Xcode::Export.provisioning_profile(bundle_identifier, xcode_provisioning_profile_uuid) + + provisioning_team = analyze.provisioning_team + target_provisioning_profile = DeployGate::Xcode::Export.provisioning_profile(bundle_identifier, xcode_provisioning_profile_uuid, provisioning_team) method = DeployGate::Xcode::Export.method(target_provisioning_profile) diff --git a/lib/deploygate/xcode/analyze.rb b/lib/deploygate/xcode/analyze.rb index 769e7c0..8e66da8 100644 --- a/lib/deploygate/xcode/analyze.rb +++ b/lib/deploygate/xcode/analyze.rb @@ -85,14 +85,13 @@ def target_xcode_setting_provisioning_profile_uuid end def provisioning_style - main_target = target_project_setting - main_target_uuid = main_target && main_target.uuid + target = target_provisioning_info style = PROVISIONING_STYLE_MANUAL - if main_target_uuid + if target # Manual or Automatic or nil (Xcode7 below) begin - style = target_project.root_object.attributes['TargetAttributes'][main_target_uuid]['ProvisioningStyle'] + style = target['ProvisioningStyle'] rescue # Not catch error end @@ -101,8 +100,39 @@ def provisioning_style style end + def provisioning_team + target = target_provisioning_info + + team = nil + if target + begin + team = target['DevelopmentTeam'] + rescue + # Not catch error + end + end + + team + end + private + def target_provisioning_info + main_target = target_project_setting + main_target_uuid = main_target && main_target.uuid + + target = nil + if main_target_uuid + begin + target = target_project.root_object.attributes['TargetAttributes'][main_target_uuid] + rescue + # Not catch error + end + end + + target + end + def target_build_configration target_project_setting.build_configuration_list.build_configurations.reject{|conf| conf.name != BUILD_CONFIGRATION}.first end diff --git a/lib/deploygate/xcode/export.rb b/lib/deploygate/xcode/export.rb index fd17701..6062284 100644 --- a/lib/deploygate/xcode/export.rb +++ b/lib/deploygate/xcode/export.rb @@ -10,11 +10,11 @@ class << self # @param [String] bundle_identifier # @param [String] uuid + # @param [String] provisioning_team # @return [String] - def provisioning_profile(bundle_identifier, uuid = nil) - local_teams = DeployGate::Xcode::Export.find_local_data(bundle_identifier, uuid) + def provisioning_profile(bundle_identifier, uuid = nil, provisioning_team = nil) + local_teams = DeployGate::Xcode::Export.find_local_data(bundle_identifier, uuid, provisioning_team) - target_provisioning_profile = nil case local_teams.teams_count when 0 target_provisioning_profile = create_provisioning(bundle_identifier, uuid) @@ -30,8 +30,9 @@ def provisioning_profile(bundle_identifier, uuid = nil) # @param [String] bundle_identifier # @param [String] uuid + # @param [String] provisioning_team # @return [LocalTeams] - def find_local_data(bundle_identifier, uuid = nil) + def find_local_data(bundle_identifier, uuid = nil, provisioning_team = nil) local_teams = LocalTeams.new profile_paths = load_profile_paths @@ -44,6 +45,8 @@ def find_local_data(bundle_identifier, uuid = nil) entities = profile['Entitlements'] unless entities['get-task-allow'] team_id = entities['com.apple.developer.team-identifier'] + next if provisioning_team != nil && team_id != provisioning_team + application_id = entities['application-identifier'] application_id.slice!(/^#{team_id}\./) application_id = '.' + application_id if application_id == '*'