Commit 16e5b431 authored by Kyle Fuller's avatar Kyle Fuller

Merge pull request #3178 from CocoaPods/explicit_use_frameworks

Require explicit use of `use_frameworks!`
parents de7e16e2 681eb76a
...@@ -56,6 +56,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -56,6 +56,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
[#2685](https://github.com/CocoaPods/CocoaPods/issues/2685) [#2685](https://github.com/CocoaPods/CocoaPods/issues/2685)
* Require explicit use of `use_frameworks!` for Pods written in Swift.
[Boris Bügling](https://github.com/neonichu)
[#3029](https://github.com/CocoaPods/CocoaPods/issues/3029)
##### Bug Fixes ##### Bug Fixes
* Added support for .tpp C++ header files in specs (previously were getting * Added support for .tpp C++ header files in specs (previously were getting
......
...@@ -92,6 +92,7 @@ module Pod ...@@ -92,6 +92,7 @@ module Pod
determine_dependency_product_types determine_dependency_product_types
verify_no_duplicate_framework_names verify_no_duplicate_framework_names
verify_no_static_framework_transitive_dependencies verify_no_static_framework_transitive_dependencies
verify_framework_usage
generate_pods_project generate_pods_project
integrate_user_project if config.integrate_targets? integrate_user_project if config.integrate_targets?
perform_post_install_actions perform_post_install_actions
...@@ -369,6 +370,22 @@ module Pod ...@@ -369,6 +370,22 @@ module Pod
end end
end end
def verify_framework_usage
aggregate_targets.each do |aggregate_target|
next if aggregate_target.requires_frameworks?
aggregate_target.user_build_configurations.keys.each do |config|
pod_targets = aggregate_target.pod_targets_for_build_configuration(config)
if pod_targets.any?(&:uses_swift?)
raise Informative, 'Pods written in Swift can only be integrated as frameworks; this ' \
'feature is still in beta. Add `use_frameworks!` to your Podfile or target to opt ' \
'into using it.'
end
end
end
end
# Performs any post-installation actions # Performs any post-installation actions
# #
# @return [void] # @return [void]
......
...@@ -91,13 +91,8 @@ module Pod ...@@ -91,13 +91,8 @@ module Pod
# @return [Boolean] whether the generated target needs to be implemented # @return [Boolean] whether the generated target needs to be implemented
# as a framework # as a framework
# #
# @note This applies either if Swift was used by the host, which was checked
# eagerly by the analyzer before, or in the given target or its
# dependents, which can only be checked after the specs were been
# fetched.
#
def requires_frameworks? def requires_frameworks?
host_requires_frameworks? || uses_swift? host_requires_frameworks? || false
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
......
...@@ -123,6 +123,10 @@ module Pod ...@@ -123,6 +123,10 @@ module Pod
fixture_spec('orange-framework/OrangeFramework.podspec') fixture_spec('orange-framework/OrangeFramework.podspec')
end end
before do
Target.any_instance.stubs(:requires_frameworks?).returns(true)
end
behaves_like 'AggregateXCConfig' behaves_like 'AggregateXCConfig'
it 'sets the PODS_FRAMEWORK_BUILD_PATH build variable' do it 'sets the PODS_FRAMEWORK_BUILD_PATH build variable' do
......
...@@ -51,6 +51,7 @@ module Pod ...@@ -51,6 +51,7 @@ module Pod
@installer.stubs(:determine_dependency_product_types) @installer.stubs(:determine_dependency_product_types)
@installer.stubs(:verify_no_duplicate_framework_names) @installer.stubs(:verify_no_duplicate_framework_names)
@installer.stubs(:verify_no_static_framework_transitive_dependencies) @installer.stubs(:verify_no_static_framework_transitive_dependencies)
@installer.stubs(:verify_framework_usage)
@installer.stubs(:generate_pods_project) @installer.stubs(:generate_pods_project)
@installer.stubs(:integrate_user_project) @installer.stubs(:integrate_user_project)
@installer.stubs(:run_plugins_post_install_hooks) @installer.stubs(:run_plugins_post_install_hooks)
...@@ -125,6 +126,7 @@ module Pod ...@@ -125,6 +126,7 @@ module Pod
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
platform :ios, '8.0' platform :ios, '8.0'
xcodeproj 'SampleProject/SampleProject' xcodeproj 'SampleProject/SampleProject'
use_frameworks!
pod 'BananaLib', :path => (fixture_path + 'banana-lib').to_s pod 'BananaLib', :path => (fixture_path + 'banana-lib').to_s
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
pod 'monkey', :path => (fixture_path + 'monkey').to_s pod 'monkey', :path => (fixture_path + 'monkey').to_s
...@@ -177,6 +179,7 @@ module Pod ...@@ -177,6 +179,7 @@ module Pod
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
platform :ios, '8.0' platform :ios, '8.0'
xcodeproj 'SampleProject/SampleProject' xcodeproj 'SampleProject/SampleProject'
use_frameworks!
pod 'BananaLib', :path => (fixture_path + 'banana-lib').to_s pod 'BananaLib', :path => (fixture_path + 'banana-lib').to_s
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
pod 'monkey', :path => (fixture_path + 'monkey').to_s pod 'monkey', :path => (fixture_path + 'monkey').to_s
...@@ -191,6 +194,25 @@ module Pod ...@@ -191,6 +194,25 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe '#verify_framework_usage' do
it 'raises when Swift pods are used without explicit `use_frameworks!`' do
fixture_path = ROOT + 'spec/fixtures'
config.repos_dir = fixture_path + 'spec-repos'
podfile = Pod::Podfile.new do
platform :ios, '8.0'
xcodeproj 'SampleProject/SampleProject'
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
end
lockfile = generate_lockfile
config.integrate_targets = false
@installer = Installer.new(config.sandbox, podfile, lockfile)
should.raise(Informative) { @installer.install! }.message.should.match /use_frameworks/
end
end
#-------------------------------------------------------------------------#
describe 'Dependencies Resolution' do describe 'Dependencies Resolution' do
describe '#analyze' do describe '#analyze' do
it 'prints a warning if the version of the Lockfile is higher than the one of the executable' do it 'prints a warning if the version of the Lockfile is higher than the one of the executable' do
......
...@@ -202,6 +202,7 @@ module Pod ...@@ -202,6 +202,7 @@ module Pod
before do before do
@pod_target = fixture_pod_target('orange-framework/OrangeFramework.podspec', :ios, Podfile::TargetDefinition.new('iOS Example', nil)) @pod_target = fixture_pod_target('orange-framework/OrangeFramework.podspec', :ios, Podfile::TargetDefinition.new('iOS Example', nil))
@target = AggregateTarget.new(@pod_target.target_definition, config.sandbox) @target = AggregateTarget.new(@pod_target.target_definition, config.sandbox)
@target.stubs(:requires_frameworks?).returns(true)
@target.pod_targets = [@pod_target] @target.pod_targets = [@pod_target]
end end
......
...@@ -178,6 +178,7 @@ module Pod ...@@ -178,6 +178,7 @@ module Pod
describe 'With frameworks' do describe 'With frameworks' do
before do before do
@pod_target = fixture_pod_target('orange-framework/OrangeFramework.podspec') @pod_target = fixture_pod_target('orange-framework/OrangeFramework.podspec')
@pod_target.host_requires_frameworks = true
end end
it 'returns that it uses swift' do it 'returns that it uses swift' do
......
...@@ -448,6 +448,7 @@ module Pod ...@@ -448,6 +448,7 @@ module Pod
podspec.gsub!(/.*license.*$/, '"license": "Public Domain",') podspec.gsub!(/.*license.*$/, '"license": "Public Domain",')
file = write_podspec(podspec) file = write_podspec(podspec)
Podfile::TargetDefinition.any_instance.stubs(:uses_frameworks?).returns(true)
Pod::Sandbox::FileAccessor.any_instance.stubs(:source_files).returns([Pathname.new('/Foo.swift')]) Pod::Sandbox::FileAccessor.any_instance.stubs(:source_files).returns([Pathname.new('/Foo.swift')])
validator = Validator.new(file, SourcesManager.master.map(&:url)) validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.stubs(:build_pod) validator.stubs(:build_pod)
......
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