mirror of
https://github.com/zhigang1992/CocoaPods.git
synced 2026-06-11 23:55:01 +08:00
Add -fobjc-arc to OTHER_LD_FLAGS if any pods require ARC (closes #142)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user