Skip to content

Commit

Permalink
[match][sigh] add support for Apple Silicon Macs in iOS/iPadOS provis…
Browse files Browse the repository at this point in the history
…ioning profiles (#20676)

* Add support for Apple Silicon Macs for iOS profiles

* fix rubocop offenses

* Update match/lib/match/options.rb

Update match ENV name

Co-authored-by: Roger Oba <rogerluan.oba@gmail.com>

* update runner specs

* remove unnecessary test statements

* Added comment about APPLE_SILICON_MAC not being an official ASC value

Co-authored-by: Philipp Pinkernelle <pppinki@icloud.com>
Co-authored-by: Roger Oba <rogerluan.oba@gmail.com>
Co-authored-by: Josh Holtz <me@joshholtz.com>
  • Loading branch information
4 people committed Nov 12, 2022
1 parent e59bb1c commit 56db40b
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 3 deletions.
1 change: 1 addition & 0 deletions match/lib/match/generator.rb
Expand Up @@ -90,6 +90,7 @@ def self.generate_provisioning_profile(params: nil, prov_type: nil, certificate_
template_name: params[:template_name],
fail_on_name_taken: params[:fail_on_name_taken],
include_all_certificates: params[:include_all_certificates],
include_mac_in_profiles: params[:include_mac_in_profiles],
}

values[:platform] = params[:platform]
Expand Down
5 changes: 5 additions & 0 deletions match/lib/match/options.rb
Expand Up @@ -253,6 +253,11 @@ def self.available_options
description: "Renew the provisioning profiles if the device count on the developer portal has changed. Ignored for profile types 'appstore' and 'developer_id'",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :include_mac_in_profiles,
env_name: "MATCH_INCLUDE_MAC_IN_PROFILES",
description: "Include Apple Silicon Mac devices in provisioning profiles for iOS/iPadOS apps",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :include_all_certificates,
env_name: "MATCH_INCLUDE_ALL_CERTIFICATES",
description: "Include all matching certificates in the provisioning profile. Works only for the 'development' provisioning profile type",
Expand Down
7 changes: 5 additions & 2 deletions match/lib/match/runner.rb
Expand Up @@ -336,7 +336,7 @@ def should_force_include_all_devices(params: nil, prov_type: nil, profile: nil,

prov_types_without_devices = [:appstore, :developer_id]
if !prov_types_without_devices.include?(prov_type) && !params[:force]
force = device_count_different?(profile: profile, keychain_path: keychain_path, platform: params[:platform].to_sym)
force = device_count_different?(profile: profile, keychain_path: keychain_path, platform: params[:platform].to_sym, include_mac_in_profiles: params[:include_mac_in_profiles])
else
# App Store provisioning profiles don't contain device identifiers and
# thus shouldn't be renewed if the device count has changed.
Expand All @@ -347,7 +347,7 @@ def should_force_include_all_devices(params: nil, prov_type: nil, profile: nil,
return force
end

def device_count_different?(profile: nil, keychain_path: nil, platform: nil)
def device_count_different?(profile: nil, keychain_path: nil, platform: nil, include_mac_in_profiles: false)
return false unless profile

parsed = FastlaneCore::ProvisioningProfile.parse(profile, keychain_path)
Expand Down Expand Up @@ -379,6 +379,9 @@ def device_count_different?(profile: nil, keychain_path: nil, platform: nil)
else
[]
end
if platform == :ios && include_mac_in_profiles
device_classes += [Spaceship::ConnectAPI::Device::DeviceClass::APPLE_SILICON_MAC]
end

devices = Spaceship::ConnectAPI::Device.all
unless device_classes.empty?
Expand Down
13 changes: 13 additions & 0 deletions match/spec/runner_spec.rb
Expand Up @@ -386,6 +386,19 @@
runner = Match::Runner.new
expect(runner.device_count_different?(profile: profile_file, platform: :ios)).to be(true)
end

it "device is apple silicon mac" do
expect(FastlaneCore::ProvisioningProfile).to receive(:parse).twice.and_return(parsed_profile)
expect(Spaceship::ConnectAPI::Profile).to receive(:all).twice.and_return([profile])
expect(Spaceship::ConnectAPI::Device).to receive(:all).twice.and_return([profile_device])

expect(profile_device).to receive(:device_class).twice.and_return(Spaceship::ConnectAPI::Device::DeviceClass::APPLE_SILICON_MAC)
expect(profile_device).to receive(:enabled?).and_return(true)

runner = Match::Runner.new
expect(runner.device_count_different?(profile: profile_file, platform: :ios, include_mac_in_profiles: false)).to be(true)
expect(runner.device_count_different?(profile: profile_file, platform: :ios, include_mac_in_profiles: true)).to be(false)
end
end
end
end
5 changes: 5 additions & 0 deletions sigh/lib/sigh/options.rb
Expand Up @@ -47,6 +47,11 @@ def self.available_options
is_string: false,
short_option: "-f",
default_value: false),
FastlaneCore::ConfigItem.new(key: :include_mac_in_profiles,
env_name: "SIGH_INCLUDE_MAC_IN_PROFILES",
description: "Include Apple Silicon Mac devices in provisioning profiles for iOS/iPadOS apps",
is_string: false,
default_value: false),
FastlaneCore::ConfigItem.new(key: :app_identifier,
short_option: "-a",
env_name: "SIGH_APP_IDENTIFIER",
Expand Down
4 changes: 3 additions & 1 deletion sigh/lib/sigh/runner.rb
Expand Up @@ -289,7 +289,9 @@ def devices_to_use
when 'macos', 'catalyst'
[Spaceship::ConnectAPI::Device::DeviceClass::MAC]
end

if Sigh.config[:platform].to_s == 'ios' && Sigh.config[:include_mac_in_profiles]
device_classes += [Spaceship::ConnectAPI::Device::DeviceClass::APPLE_SILICON_MAC]
end
if Spaceship::ConnectAPI.token
return Spaceship::ConnectAPI::Device.all.select do |device|
device_classes.include?(device.device_class)
Expand Down
10 changes: 10 additions & 0 deletions sigh/spec/runner_spec.rb
Expand Up @@ -151,6 +151,16 @@
expect(devices.size).to eq(1)
end

it "devices for development with apple silicon" do
options = { development: true, include_mac_in_profiles: true }
Sigh.config = FastlaneCore::Configuration.create(Sigh::Options.available_options, options)

expect(Spaceship::ConnectAPI::Device).to receive(:all).and_return(["ios_device", "as_device"])

devices = fake_runner.devices_to_use
expect(devices.size).to eq(2)
end

it "devices for adhoc" do
options = { adhoc: true }
Sigh.config = FastlaneCore::Configuration.create(Sigh::Options.available_options, options)
Expand Down
3 changes: 3 additions & 0 deletions spaceship/lib/spaceship/connect_api/models/device.rb
Expand Up @@ -29,6 +29,9 @@ module DeviceClass
IPOD = "IPOD"
APPLE_TV = "APPLE_TV"
MAC = "MAC"

# As of 2022-11-12, this is not officially supported by App Store Connect API
APPLE_SILICON_MAC = "APPLE_SILICON_MAC"
end

module Status
Expand Down

0 comments on commit 56db40b

Please sign in to comment.