Skip to content

Commit

Permalink
"[Specification] Allow to require_arc in subspecs."
Browse files Browse the repository at this point in the history
Closes #464.
  • Loading branch information
fabiopelosin committed Aug 20, 2012
1 parent 7c5ed22 commit 38eaf22
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
25 changes: 22 additions & 3 deletions lib/cocoapods/specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion spec/unit/specification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@

fss.subspec 'SecondSubSpec' do |sss|
sss.source_files = 'subsubspec.m'
sss.requires_arc = false
end
end
end
Expand All @@ -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
Expand All @@ -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'
Expand Down

0 comments on commit 38eaf22

Please sign in to comment.