diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c3c0f22..144dc8f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/cocoapods-core/platform.rb b/lib/cocoapods-core/platform.rb index d3803127..c1318115 100644 --- a/lib/cocoapods-core/platform.rb +++ b/lib/cocoapods-core/platform.rb @@ -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 diff --git a/spec/platform_spec.rb b/spec/platform_spec.rb index 20da4c0a..3f8fb088 100644 --- a/spec/platform_spec.rb +++ b/spec/platform_spec.rb @@ -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 @@ -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