Commit 0f5cb708 authored by Ben Asher's avatar Ben Asher

Improved messages when missing host targets in the Podfile

- Add support for framework-only development
parent 8e4d8157
...@@ -284,7 +284,26 @@ module Pod ...@@ -284,7 +284,26 @@ module Pod
end end
end end
unless embedded_targets_missing_hosts.empty? unless embedded_targets_missing_hosts.empty?
raise Informative, "Unable to find host target for #{embedded_targets_missing_hosts.map(&:name).join(', ')}. Please add the host targets for the embedded targets to the Podfile." embedded_targets_missing_hosts_product_types = embedded_targets_missing_hosts.map(&:user_targets).flatten.map(&:symbol_type).uniq
# If the targets missing hosts are only frameworks, then this is likely
# a project for doing framework development. In that case, just warn that
# the frameworks that these targets depend on won't be integrated anywhere
if embedded_targets_missing_hosts_product_types == [:framework]
UI.warn 'The Podfile contains framework targets, for which the Podfile does not contain host targets (where these frameworks would be installed).' \
"\n" \
'If this project is for doing framework development, you can ignore this message or add a test target that embeds these frameworks to make this message go away. Otherwise, please add the frameworks\' host targets to the Podfile.'
else
target_names = embedded_targets_missing_hosts.map do |target|
target.name.sub('Pods-', '') # Make the target names more recognizable to the user
end.join ', '
raise Informative, "Unable to find host target(s) for #{target_names}. Please add the host targets for the embedded targets to the Podfile." \
"\n" \
'Certain kinds of targets require a host target, in which to be embedded. These are example types of targets that need a host target:' \
"\n- Framework" \
"\n- App Extension" \
"\n- Watch OS 1 Extension" \
"\n- Messages Extension (except when used with a Messages Application)"
end
end end
end end
......
...@@ -747,7 +747,22 @@ module Pod ...@@ -747,7 +747,22 @@ module Pod
analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile) analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile)
should.raise Informative do should.raise Informative do
analyzer.analyze analyzer.analyze
end.message.should.match /Unable to find host target for Pods-Today Extension. Please add the host targets for the embedded targets to the Podfile/ end.message.should.match /Unable to find host target\(s\) for Today Extension. Please add the host targets for the embedded targets to the Podfile/
end
it 'warns when using a Podfile for framework-only projects' do
podfile = Pod::Podfile.new do
source SpecHelper.test_repo_url
use_frameworks!
platform :ios, '8.0'
target 'Sample Framework' do
project 'SampleProject/Sample Lib/Sample Lib'
pod 'monkey'
end
end
analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile)
analyzer.analyze
UI.warnings.should.match /The Podfile contains framework targets, for which the Podfile does not contain host targets \(where these frameworks would be installed\)\./
end end
it 'raises when the extension calls use_frameworks!, but the host target does not' do it 'raises when the extension calls use_frameworks!, but the host target does not' do
......
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