Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

"[Specification] Allow to require_arc in subspecs."

Closes #464.
  • Loading branch information...
commit 38eaf22333f2ead49f939c13471fb41250fba9c8 1 parent 7c5ed22
@fabiopelosin fabiopelosin authored
Showing with 31 additions and 4 deletions.
  1. +22 −3 lib/cocoapods/specification.rb
  2. +9 −1 spec/unit/specification_spec.rb
View
25 lib/cocoapods/specification.rb
@@ -51,8 +51,9 @@ def initialize(parent = nil, name = nil)
compiler_flags ].each do |attr|
instance_variable_set( "@#{attr}", { :ios => [], :osx => [] } )
end
- @xcconfig = { :ios => Xcodeproj::Config.new, :osx => Xcodeproj::Config.new }
- @header_dir = { :ios => nil, :osx => nil }
+ @xcconfig = { :ios => Xcodeproj::Config.new, :osx => Xcodeproj::Config.new }
+ @header_dir = { :ios => nil, :osx => nil }
+ @requires_arc = { :ios => nil, :osx => nil }
yield self if block_given?
end
@@ -137,6 +138,7 @@ def initialize(specification, platform)
compiler_flags=
deployment_target=
header_dir=
+ requires_arc
dependency }.each do |method|
define_method(method) do |args|
@specification._on_platform(@platform) do
@@ -194,7 +196,6 @@ def available_platforms
top_attr_accessor :homepage
top_attr_accessor :summary
top_attr_accessor :documentation
- top_attr_accessor :requires_arc
top_attr_accessor :version, lambda { |v| Version.new(v) }
top_attr_reader :description, lambda { |instance, ivar| ivar || instance.summary }
@@ -255,6 +256,24 @@ def available_platforms
alias_method :weak_framework=, :weak_frameworks=
alias_method :library=, :libraries=
+
+ # @!method requires_arc=
+ #
+ # @abstract Wether the `-fobjc-arc' flag should be added to the compiler
+ # flags.
+ #
+ # @param [Bool] Wether the source files require ARC.
+ #
+ platform_attr_writer :requires_arc
+
+ def requires_arc
+ requires_arc = @requires_arc[active_platform]
+ if requires_arc.nil?
+ requires_arc = @parent ? @parent.requires_arc : false
+ end
+ requires_arc
+ end
+
# @!method header_dir=
#
# @abstract The directory where to name space the headers files of
View
10 spec/unit/specification_spec.rb
@@ -305,6 +305,7 @@
fss.subspec 'SecondSubSpec' do |sss|
sss.source_files = 'subsubspec.m'
+ sss.requires_arc = false
end
end
end
@@ -329,7 +330,7 @@
it "automatically forwards top level attributes to the top level parent" do
@spec.activate_platform(:ios)
- [:version, :license, :authors, :requires_arc, :compiler_flags].each do |attr|
+ [:version, :license, :authors, :compiler_flags].each do |attr|
@spec.subspecs.first.send(attr).should == @spec.send(attr)
@spec.subspecs.first.subspecs.first.send(attr).should == @spec.send(attr)
end
@@ -346,6 +347,13 @@
@subsubspec.compiler_flags.should == ' -fobjc-arc -Wdeprecated-implementations'
end
+ it "allows to specify arc settings for subspecs" do
+ @spec.activate_platform(:ios)
+ @spec.requires_arc.should == true
+ @subspec.requires_arc.should == true
+ @subsubspec.requires_arc.should == false
+ end
+
it "returns empty arrays for chained attributes with no value in the chain" do
@spec = Pod::Spec.new do |s|
s.name = 'MainSpec'
Please sign in to comment.
Something went wrong with that request. Please try again.