Commit 0177008a authored by Ben Asher's avatar Ben Asher Committed by GitHub

Merge pull request #6016 from CocoaPods/dani_embedd

Only use EMBEDDED_CONTAINT_CONTAINS_SWIFT on Swift <= 2.3
parents b1094a8a f675f036
...@@ -44,6 +44,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -44,6 +44,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Stephen Hayes](https://github.com/schayes04) [Stephen Hayes](https://github.com/schayes04)
[#5713](https://github.com/CocoaPods/CocoaPods/issues/5713) [#5713](https://github.com/CocoaPods/CocoaPods/issues/5713)
* Update EMBEDDED_CONTENT_CONTAINS_SWIFT flag behaviour based on xcode version.
[codymoorhouse](https://github.com/codymoorhouse)
[#5732](https://github.com/CocoaPods/CocoaPods/issues/5732)
##### Bug Fixes ##### Bug Fixes
* Remove special handling for messages apps * Remove special handling for messages apps
......
...@@ -60,20 +60,8 @@ module Pod ...@@ -60,20 +60,8 @@ module Pod
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1', 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) ', 'FRAMEWORK_SEARCH_PATHS' => '$(inherited) ',
'LIBRARY_SEARCH_PATHS' => '$(inherited) ', 'LIBRARY_SEARCH_PATHS' => '$(inherited) ',
} }.merge(embedded_content_settings)
# For embedded targets, which live in a host target, CocoaPods
# copies all of the embedded target's pod_targets its host
# target. Therefore, this check will properly require the Swift
# libs in the host target, if the embedded target has any pod targets
# that use Swift. Setting this for the embedded target would
# cause an App Store rejection because frameworks cannot be embedded
# in embedded targets.
if !target.requires_host_target? && pod_targets.any?(&:uses_swift?)
config['EMBEDDED_CONTENT_CONTAINS_SWIFT'] = 'YES'
config['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'
else
config['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'NO'
end
@xcconfig = Xcodeproj::Config.new(config) @xcconfig = Xcodeproj::Config.new(config)
@xcconfig.merge!(merged_user_target_xcconfigs) @xcconfig.merge!(merged_user_target_xcconfigs)
...@@ -100,6 +88,41 @@ module Pod ...@@ -100,6 +88,41 @@ module Pod
protected protected
def target_swift_version
settings = target.native_target.resolved_build_setting('SWIFT_VERSION') unless target.native_target.nil?
settings.values.compact.uniq.first unless settings.nil?
end
EMBED_STANDARD_LIBRARIES_MINIMUM_VERSION = Gem::Version.new('2.3')
# @return [Hash<String, String>] the build settings necessary for Swift
# targets to be correctly embedded in their host.
#
def embedded_content_settings
# For embedded targets, which live in a host target, CocoaPods
# copies all of the embedded target's pod_targets its host
# target. Therefore, this check will properly require the Swift
# libs in the host target, if the embedded target has any pod targets
# that use Swift. Setting this for the embedded target would
# cause an App Store rejection because frameworks cannot be embedded
# in embedded targets.
swift_version = Gem::Version.new(target_swift_version)
should_embed = !target.requires_host_target? && pod_targets.any?(&:uses_swift?)
embed_value = should_embed ? 'YES' : 'NO'
config = {
'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES' => embed_value,
'EMBEDDED_CONTENT_CONTAINS_SWIFT' => embed_value,
}
if swift_version >= EMBED_STANDARD_LIBRARIES_MINIMUM_VERSION || !should_embed
config.delete('EMBEDDED_CONTENT_CONTAINS_SWIFT')
end
config
end
# @return [Hash<String, String>] the build settings necessary to import # @return [Hash<String, String>] the build settings necessary to import
# the pod targets. # the pod targets.
# #
......
...@@ -241,37 +241,55 @@ module Pod ...@@ -241,37 +241,55 @@ module Pod
@xcconfig.to_hash['OTHER_SWIFT_FLAGS'].should.include '$(inherited) "-D" "COCOAPODS"' @xcconfig.to_hash['OTHER_SWIFT_FLAGS'].should.include '$(inherited) "-D" "COCOAPODS"'
end end
it 'sets EMBEDDED_CONTENT_CONTAINS_SWIFT when there is swift' do it 'sets EMBEDDED_CONTENT_CONTAINS_SWIFT when the target_swift_version is < 2.3' do
@generator.send(:pod_targets).first.stubs(:uses_swift?).returns(true) @generator.send(:pod_targets).first.stubs(:uses_swift?).returns(true)
@generator.stubs(:target_swift_version).returns('2.2')
@generator.generate.to_hash['EMBEDDED_CONTENT_CONTAINS_SWIFT'].should == 'YES' @generator.generate.to_hash['EMBEDDED_CONTENT_CONTAINS_SWIFT'].should == 'YES'
end end
it 'does not set EMBEDDED_CONTENT_CONTAINS_SWIFT when there is no swift' do it 'does not set EMBEDDED_CONTENT_CONTAINS_SWIFT when there is no swift' do
@generator.send(:pod_targets).each { |pt| pt.stubs(:uses_swift?).returns(false) } @generator.send(:pod_targets).each { |pt| pt.stubs(:uses_swift?).returns(false) }
@generator.stubs(:target_swift_version).returns('2.2')
@generator.generate.to_hash['EMBEDDED_CONTENT_CONTAINS_SWIFT'].should.be.nil @generator.generate.to_hash['EMBEDDED_CONTENT_CONTAINS_SWIFT'].should.be.nil
end end
it 'does not set EMBEDDED_CONTENT_CONTAINS_SWIFT when there is swift, but the target is an extension' do it 'does not set EMBEDDED_CONTENT_CONTAINS_SWIFT when there is swift, but the target is an extension' do
@target.stubs(:requires_host_target?).returns(true) @target.stubs(:requires_host_target?).returns(true)
@generator.stubs(:target_swift_version).returns('2.2')
@generator.send(:pod_targets).first.stubs(:uses_swift?).returns(true) @generator.send(:pod_targets).first.stubs(:uses_swift?).returns(true)
@generator.generate.to_hash['EMBEDDED_CONTENT_CONTAINS_SWIFT'].should.be.nil @generator.generate.to_hash['EMBEDDED_CONTENT_CONTAINS_SWIFT'].should.be.nil
end end
it 'sets ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to YES when there is swift' do it 'sets EMBEDDED_CONTENT_CONTAINS_SWIFT when the target_swift_version is nil' do
@generator.send(:pod_targets).first.stubs(:uses_swift?).returns(true) @generator.send(:pod_targets).first.stubs(:uses_swift?).returns(true)
@generator.stubs(:target_swift_version).returns(nil)
@generator.generate.to_hash['EMBEDDED_CONTENT_CONTAINS_SWIFT'].should == 'YES'
end
it 'sets ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to YES when there is swift >= 2.3' do
@generator.send(:pod_targets).first.stubs(:uses_swift?).returns(true)
@generator.stubs(:target_swift_version).returns('2.3')
@generator.generate.to_hash['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'].should == 'YES' @generator.generate.to_hash['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'].should == 'YES'
end end
it 'sets ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to NO when there is no swift' do it 'sets ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to NO when there is no swift' do
@generator.send(:pod_targets).first.stubs(:uses_swift?).returns(false) @generator.send(:pod_targets).first.stubs(:uses_swift?).returns(false)
@generator.stubs(:target_swift_version).returns(nil)
@generator.generate.to_hash['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'].should == 'NO' @generator.generate.to_hash['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'].should == 'NO'
end end
it 'sets ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to NO when there is swift, but the target is an extension' do it 'sets ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to NO when there is swift, but the target is an extension' do
@target.stubs(:requires_host_target?).returns(true) @target.stubs(:requires_host_target?).returns(true)
@generator.stubs(:target_swift_version).returns('2.3')
@generator.send(:pod_targets).first.stubs(:uses_swift?).returns(true) @generator.send(:pod_targets).first.stubs(:uses_swift?).returns(true)
@generator.generate.to_hash['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'].should == 'NO' @generator.generate.to_hash['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'].should == 'NO'
end end
it 'does not set EMBEDDED_CONTENT_CONTAINS_SWIFT when there is swift 2.3 or higher' do
@generator.send(:pod_targets).first.stubs(:uses_swift?).returns(true)
@generator.stubs(:target_swift_version).returns('2.3')
@generator.generate.to_hash.key?('EMBEDDED_CONTENT_CONTAINS_SWIFT').should == false
end
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