spaceship/lib/spaceship/portal/provisioning_profile.rb in fastlane-2.19.0.beta.20170228010016 vs spaceship/lib/spaceship/portal/provisioning_profile.rb in fastlane-2.19.0.beta.20170301010932

- old
+ new

@@ -1,8 +1,11 @@ module Spaceship module Portal # Represents a provisioning profile of the Apple Dev Portal + # + # NOTE: If the environment variable `SPACESHIP_AVOID_XCODE_API` is present when using this class, all requests will be made via Apple developer portal API. + # In the default case, this class will use the Xcode API for fetching provisioning profiles. This is an optimization that results in 1 query for all Profiles vs 1+N queries. class ProvisioningProfile < PortalBase # @return (String) The ID generated by the Dev Portal # You'll probably not really need this value # @example # "2MAY7NPHAA" @@ -258,20 +261,23 @@ # @return (Array) Returns all profiles registered for this account # If you're calling this from a subclass (like AdHoc), this will # only return the profiles that are of this type # @param mac (Bool) (optional): Pass true to get all Mac provisioning profiles - # @param xcode DEPRECATED + # @param xcode (Bool) (optional): Pass true to include Xcode managed provisioning profiles def all(mac: false, xcode: false) - profiles = client.provisioning_profiles(mac: mac).map do |profile| - self.factory(profile) + if ENV['SPACESHIP_AVOID_XCODE_API'] + profiles = client.provisioning_profiles(mac: mac) + else + profiles = client.provisioning_profiles_via_xcode_api(mac: mac) end + # transform raw data to class instances + profiles.map! { |profile| self.factory(profile) } + # filter out the profiles managed by xcode - if xcode - warn('Apple API no longer returns XCode managed Provisioning Profiles') - else + unless xcode profiles.delete_if(&:managed_by_xcode?) end return profiles if self == ProvisioningProfile @@ -478,10 +484,16 @@ @certificates end def app - App.set_client(client).new(profile_details['appId']) + if raw_data.key?('appId') + app_attributes = raw_data['appId'] + else + app_attributes = profile_details['appId'] + end + + App.set_client(client).new(app_attributes) end # @return (Bool) Is this current provisioning profile adhoc? # AppStore and AdHoc profiles are the same except that AdHoc has devices def is_adhoc?