Commit ea918cd9 authored by Luke Redpath's avatar Luke Redpath

Add -fobjc-arc to OTHER_LD_FLAGS if any pods require ARC (closes #142)

parent 5384e9f6
......@@ -4,6 +4,7 @@ module Pod
include Config::Mixin
attr_reader :podfile, :project, :target_definition, :target
attr_accessor :requires_arc
def initialize(podfile, project, target_definition)
@podfile, @project, @target_definition = podfile, project, target_definition
......@@ -16,7 +17,7 @@ module Pod
'ALWAYS_SEARCH_USER_PATHS' => 'YES', # needed to make EmbedReader build
# This makes categories from static libraries work, which many libraries
# require, so we add these by default.
'OTHER_LDFLAGS' => '-ObjC -all_load',
'OTHER_LDFLAGS' => default_ld_flags,
})
end
......@@ -61,6 +62,8 @@ module Pod
# TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support.
def install!(pods, sandbox)
self.requires_arc = pods.any? { |pod| pod.requires_arc? }
# First add the target to the project
@target = @project.targets.new_static_library(@target_definition.lib_name)
......@@ -112,6 +115,12 @@ module Pod
def quoted(strings)
strings.map { |s| "\"#{s}\"" }
end
def default_ld_flags
flags = %w{-ObjC -all_load}
flags << '-fobjc-arc' if self.requires_arc
flags.join(" ")
end
end
end
end
......
......@@ -75,6 +75,10 @@ module Pod
end
end
def requires_arc?
specification.requires_arc
end
private
def implementation_files
......
......@@ -44,5 +44,10 @@ describe Pod::Installer::TargetInstaller do
do_install!
@installer.xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include("\"#{@sandbox.header_search_paths.join(" ")}\"")
end
it 'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc (to support non-ARC projects on iOS 4.0)' do
@specification.stubs(:requires_arc).returns(true)
do_install!
@installer.xcconfig.to_hash['OTHER_LDFLAGS'].split(" ").should.include("-fobjc-arc")
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment