Commit 5af5828e authored by Jeremy Slater's avatar Jeremy Slater

Add default_ld_flags method

The -fobjc-arc flag should only be added when explicitly requested in 
the Podfile and the spec requires arc.
parent 35c15847
...@@ -40,6 +40,19 @@ module Pod ...@@ -40,6 +40,19 @@ module Pod
private private
# @return [String] the default linker flags. `-ObjC` is always included
# while `-fobjc-arc` is included only if requested in the
# Podfile.
#
def default_ld_flags
ld_flags = '-ObjC'
if target.target_definition.podfile.set_arc_compatibility_flag? and
target.spec_consumers.any? { |consumer| consumer.requires_arc? }
ld_flags << ' -fobjc-arc'
end
ld_flags
end
# Converts an array of strings to a single string where the each string # Converts an array of strings to a single string where the each string
# is surrounded by double quotes and separated by a space. Used to # is surrounded by double quotes and separated by a space. Used to
# represent strings in a xcconfig file. # represent strings in a xcconfig file.
......
...@@ -14,14 +14,9 @@ module Pod ...@@ -14,14 +14,9 @@ module Pod
# @return [Xcodeproj::Config] # @return [Xcodeproj::Config]
# #
def generate def generate
ld_flags = '-ObjC'
if target.target_definition.podfile.set_arc_compatibility_flag?
ld_flags << ' -fobjc-arc'
end
config = { config = {
'ALWAYS_SEARCH_USER_PATHS' => 'YES', 'ALWAYS_SEARCH_USER_PATHS' => 'YES',
'OTHER_LDFLAGS' => ld_flags, 'OTHER_LDFLAGS' => default_ld_flags,
'HEADER_SEARCH_PATHS' => quote(sandbox.public_headers.search_paths), 'HEADER_SEARCH_PATHS' => quote(sandbox.public_headers.search_paths),
'PODS_ROOT' => target.relative_pods_root, 'PODS_ROOT' => target.relative_pods_root,
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1', 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
......
...@@ -13,14 +13,9 @@ module Pod ...@@ -13,14 +13,9 @@ module Pod
# @return [Xcodeproj::Config] # @return [Xcodeproj::Config]
# #
def generate def generate
ld_flags = '-ObjC'
if target.consumer.requires_arc?
ld_flags << ' -fobjc-arc'
end
config = { config = {
'ALWAYS_SEARCH_USER_PATHS' => 'YES', 'ALWAYS_SEARCH_USER_PATHS' => 'YES',
'OTHER_LDFLAGS' => ld_flags, 'OTHER_LDFLAGS' => default_ld_flags,
'PODS_ROOT' => '${SRCROOT}', 'PODS_ROOT' => '${SRCROOT}',
'HEADER_SEARCH_PATHS' => quote(target.build_headers.search_paths) + ' ' + quote(sandbox.public_headers.search_paths), 'HEADER_SEARCH_PATHS' => quote(target.build_headers.search_paths) + ' ' + quote(sandbox.public_headers.search_paths),
'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1', 'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1',
......
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