Skip to content

Commit

Permalink
Merge pull request #765 from CocoaPods/amorde/visionos-case-sensitivity
Browse files Browse the repository at this point in the history
Accept visionOS (in addition to visionos)  as a valid platform
  • Loading branch information
amorde committed Feb 6, 2024
2 parents 60a28c9 + 8cc23cc commit 4aeacec
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 22 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Expand Up @@ -8,8 +8,9 @@

##### Bug Fixes

* None.

* Accept any casing for platform names in `Platform.new`.
[Eric Amorde](https://github.com/amorde)
[#765](https://github.com/CocoaPods/Core/pull/765)

## 1.15.0 (2024-01-28)

Expand Down
24 changes: 13 additions & 11 deletions lib/cocoapods-core/platform.rb
Expand Up @@ -45,17 +45,19 @@ def initialize(input, target = nil)
@symbolic_name = input.name
@deployment_target = input.deployment_target
else
# Allow `Platform.new('macos')` to be equivalent to `Platform.macos`
if input == 'macos'
input = 'osx'
elsif input == 'xros'
# To address the issue of the mismatch between the platform: xros in the XCFramework and the platform:
# visionos in Cocoapods.
#
# This will ensure proper alignment between the platform information in the XCFramework and Cocoapods.
input = 'visionos'
end
@symbolic_name = input.to_sym
input = input.to_s.downcase

name = case input
when 'macos'
# Allow `Platform.new('macos')` to be equivalent to `Platform.macos`
'osx'
when 'xros'
# Compatibility with older references to 'xrOS'
'visionos'
else
input
end
@symbolic_name = name.to_sym
target = target[:deployment_target] if target.is_a?(Hash)
@deployment_target = Version.create(target)
end
Expand Down
33 changes: 24 additions & 9 deletions spec/platform_spec.rb
Expand Up @@ -30,15 +30,30 @@ module Pod
@platform.name.should == :ios
end

it 'can be initialized with a string symbolic name' do
platform = Platform.new('ios')
platform.name.should == :ios
end
it 'can be initialized with a string' do
Platform.new('MACOS').should == Platform.macos
Platform.new('macOS').should == Platform.macos
Platform.new('macos').should == Platform.macos

Platform.new('iOS').should == Platform.ios
Platform.new('IOS').should == Platform.ios
Platform.new('ios').should == Platform.ios

Platform.new('tvos').should == Platform.tvos
Platform.new('tvOS').should == Platform.tvos
Platform.new('TVOS').should == Platform.tvos

Platform.new('watchOS').should == Platform.watchos
Platform.new('WATCHOS').should == Platform.watchos
Platform.new('watchos').should == Platform.watchos

it 'can be initialized with a string representing macOS' do
platform = Platform.new('macos')
platform.name.should == :osx
platform.string_name.should == 'macOS'
Platform.new('visionos').should == Platform.visionos
Platform.new('VISIONOS').should == Platform.visionos
Platform.new('visionOS').should == Platform.visionos
# Recognizes xrOS
Platform.new('xros').should == Platform.visionos
Platform.new('XROS').should == Platform.visionos
Platform.new('xrOS').should == Platform.visionos
end

it 'exposes its name as string' do
Expand Down Expand Up @@ -83,7 +98,7 @@ module Pod
Platform.new(:tvos, '9.0').to_s.should == 'tvOS 9.0'
end

it 'uses its name as its symbold version' do
it 'uses its name as its symbol version' do
@platform.to_sym.should == :ios
end

Expand Down

0 comments on commit 4aeacec

Please sign in to comment.