Skip to content

Commit

Permalink
Merge pull request #745 from gabrieldonadel/visionOS
Browse files Browse the repository at this point in the history
Add `visionos` as a new platform
  • Loading branch information
dnkoutso authored Jun 27, 2023
2 parents 8428ea5 + 74ecc4a commit 034be3e
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 10 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

##### Enhancements

* None.
* Add `visionOS` as a new platform.
[Gabriel Donadel](https://github.com/gabrieldonadel)
[Core#745](https://github.com/CocoaPods/Core/pull/745)

##### Bug Fixes

Expand Down
11 changes: 10 additions & 1 deletion lib/cocoapods-core/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ def self.tvos
new :tvos
end

# Convenience method to initialize a visionOS platform.
#
# @return [Platform] a visionOS platform.
#
def self.visionos
new :visionos
end

# Convenience method to initialize a watchOS platform.
#
# @return [Platform] a watchOS platform.
Expand All @@ -100,7 +108,7 @@ def self.watchos
# @return [Array<Platform>] list of platforms.
#
def self.all
[ios, osx, watchos, tvos]
[ios, osx, watchos, visionos, tvos]
end

# Checks if a platform is equivalent to another one or to a symbol
Expand Down Expand Up @@ -239,6 +247,7 @@ def self.string_name(symbolic_name)
when :osx then 'macOS'
when :watchos then 'watchOS'
when :tvos then 'tvOS'
when :visionos then 'visionOS'
else symbolic_name.to_s
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/cocoapods-core/podfile/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -566,15 +566,15 @@ def inherit!(inheritance)
# Specifies the platform for which a static library should be built.
#
# CocoaPods provides a default deployment target if one is not specified.
# The current default values are `4.3` for iOS, `10.6` for OS X, `9.0` for tvOS
# and `2.0` for watchOS.
# The current default values are `4.3` for iOS, `10.6` for OS X, `9.0` for tvOS,
# `1.0` for visionOS and `2.0` for watchOS.
#
# If the deployment target requires it (iOS < `4.3`), `armv6`
# architecture will be added to `ARCHS`.
#
# @param [Symbol] name
# the name of platform, can be either `:osx` for OS X, `:ios`
# for iOS, `:tvos` for tvOS, or `:watchos` for watchOS.
# for iOS, `:tvos` for tvOS, `:visionos` for visionOS, or `:watchos` for watchOS.
#
# @param [String, Version] target
# The optional deployment. If not provided a default value
Expand Down
6 changes: 3 additions & 3 deletions lib/cocoapods-core/podfile/target_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def set_use_modular_headers_for_pod(pod_name, flag)

#--------------------------------------#

PLATFORM_DEFAULTS = { :ios => '4.3', :osx => '10.6', :tvos => '9.0', :watchos => '2.0' }.freeze
PLATFORM_DEFAULTS = { :ios => '4.3', :osx => '10.6', :tvos => '9.0', :visionos => '1.0', :watchos => '2.0' }.freeze

# @return [Platform] the platform of the target definition.
#
Expand Down Expand Up @@ -648,9 +648,9 @@ def platform
#
def set_platform(name, target = nil)
name = :osx if name == :macos
unless [:ios, :osx, :tvos, :watchos].include?(name)
unless [:ios, :osx, :tvos, :visionos, :watchos].include?(name)
raise StandardError, "Unsupported platform `#{name}`. Platform " \
'must be `:ios`, `:osx`, `:macos`, `:tvos`, or `:watchos`.'
'must be `:ios`, `:osx`, `:macos`, `:tvos`, :visionos, or `:watchos`.'
end

if target
Expand Down
13 changes: 12 additions & 1 deletion lib/cocoapods-core/specification/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ module DSL

# The names of the platforms supported by the specification class.
#
PLATFORMS = [:osx, :ios, :tvos, :watchos].freeze
PLATFORMS = [:osx, :ios, :tvos, :visionos, :watchos].freeze

# @todo This currently is not used in the Ruby DSL.
#
Expand Down Expand Up @@ -1880,6 +1880,17 @@ def tvos
PlatformProxy.new(self, :tvos)
end

# Provides support for specifying visionOS attributes.
#
# @example
# spec.visionos.source_files = 'Classes/visionos/**/*.{h,m}'
#
# @return [PlatformProxy] the proxy that will set the attributes.
#
def visionos
PlatformProxy.new(self, :visionos)
end

# Provides support for specifying watchOS attributes.
#
# @example
Expand Down
12 changes: 12 additions & 0 deletions spec/platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ module Pod
Platform.ios.should == Platform.new(:ios)
Platform.osx.should == Platform.new(:osx)
Platform.tvos.should == Platform.new(:tvos)
Platform.visionos.should == Platform.new(:visionos)
Platform.watchos.should == Platform.new(:watchos)
Platform.all.should.include? Platform.new(:ios)
Platform.all.should.include? Platform.new(:osx)
Platform.all.should.include? Platform.new(:tvos)
Platform.all.should.include? Platform.new(:visionos)
Platform.all.should.include? Platform.new(:watchos)
end

Expand Down Expand Up @@ -43,13 +45,15 @@ module Pod
Platform.ios.string_name.should == 'iOS'
Platform.osx.string_name.should == 'macOS'
Platform.tvos.string_name.should == 'tvOS'
Platform.visionos.string_name.should == 'visionOS'
Platform.watchos.string_name.should == 'watchOS'
end

it 'exposes a safe variant of its name as string' do
Platform.ios.safe_string_name.should == 'iOS'
Platform.osx.safe_string_name.should == 'macOS'
Platform.tvos.safe_string_name.should == 'tvOS'
Platform.visionos.safe_string_name.should == 'visionOS'
Platform.watchos.safe_string_name.should == 'watchOS'
end

Expand All @@ -69,10 +73,12 @@ module Pod
it 'presents an accurate string representation' do
@platform.to_s.should == 'iOS'
Platform.new(:osx).to_s.should == 'macOS'
Platform.new(:visionos).to_s.should == 'visionOS'
Platform.new(:watchos).to_s.should == 'watchOS'
Platform.new(:tvos).to_s.should == 'tvOS'
Platform.new(:ios, '5.0.0').to_s.should == 'iOS 5.0.0'
Platform.new(:osx, '10.7').to_s.should == 'macOS 10.7'
Platform.new(:visionos, '1.0').to_s.should == 'visionOS 1.0'
Platform.new(:watchos, '2.0').to_s.should == 'watchOS 2.0'
Platform.new(:tvos, '9.0').to_s.should == 'tvOS 9.0'
end
Expand Down Expand Up @@ -110,6 +116,7 @@ module Pod
it 'returns whether it requires legacy iOS architectures' do
Platform.new(:ios, '4.0').requires_legacy_ios_archs?.should.be.true
Platform.new(:ios, '5.0').requires_legacy_ios_archs?.should.be.false
Platform.new(:visionos, '1.0').requires_legacy_ios_archs?.should.be.false
Platform.new(:watchos, '2.0').requires_legacy_ios_archs?.should.be.false
Platform.new(:tvos, '9.0').requires_legacy_ios_archs?.should.be.false
end
Expand Down Expand Up @@ -140,6 +147,11 @@ module Pod
Platform.new(:ios, '8.1').should.supports_dynamic_frameworks
end

it 'supports dynamic frameworks on visionOS' do
Platform.visionos.should.supports_dynamic_frameworks
Platform.new(:visionos, '1.0').should.supports_dynamic_frameworks
end

it 'supports dynamic frameworks on watchOS' do
Platform.watchos.should.supports_dynamic_frameworks
Platform.new(:watchos, '2.0').should.supports_dynamic_frameworks
Expand Down
10 changes: 10 additions & 0 deletions spec/specification/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ module Pod
e.message.should.match /declared only per platform/
end

it 'allows to specify visionOS as supported platform' do
@spec.platform = :visionos
@spec.attributes_hash['platforms'].should == { 'visionos' => nil }
end

it 'allows to specify a deployment target for the visionOS platform' do
@spec.visionos.deployment_target = '1.0'
@spec.attributes_hash['platforms']['visionos'].should == '1.0'
end

it 'allows to specify watchOS as supported platform' do
@spec.platform = :watchos
@spec.attributes_hash['platforms'].should == { 'watchos' => nil }
Expand Down
2 changes: 2 additions & 0 deletions spec/specification/json_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module Pod
'osx' => nil,
'ios' => nil,
'tvos' => nil,
'visionos'=> nil,
'watchos' => nil,
},
}
Expand Down Expand Up @@ -53,6 +54,7 @@ module Pod
'osx' => nil,
'ios' => nil,
'tvos' => nil,
'visionos'=> nil,
'watchos' => nil,
},
}
Expand Down
2 changes: 1 addition & 1 deletion spec/specification/linter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module Pod
@linter.lint
@linter.results.count.should == 1
@linter.results.first.platforms.map(&:to_s).sort.should ==
%w(ios osx tvos watchos)
%w(ios osx tvos visionos watchos)
end

before do
Expand Down

0 comments on commit 034be3e

Please sign in to comment.