Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --use-static-frameworks lint option #9632

Merged
merged 2 commits into from May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions CHANGELOG.md
Expand Up @@ -17,6 +17,14 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Juanjo López](https://github.com/juanjonol)
[#9232](https://github.com/CocoaPods/CocoaPods/issues/9232)

* Option to lint a specified set of test_specs
[Paul Beusterien](https://github.com/paulb777)
[#9392](https://github.com/CocoaPods/CocoaPods/pull/9392)

* Add --use-static-frameworks lint option
[Paul Beusterien](https://github.com/paulb777)
[#9632](https://github.com/CocoaPods/CocoaPods/pull/9632)

##### Bug Fixes

* Fix crash when targets missing in Podfile
Expand Down Expand Up @@ -91,10 +99,6 @@ To install release candidates run `[sudo] gem install cocoapods --pre`

##### Enhancements

* Option to lint a specified set of test_specs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, #9392 is in master and not 1.9.1

[Paul Beusterien](https://github.com/paulb777)
[#9392](https://github.com/CocoaPods/CocoaPods/pull/9392)

##### Bug Fixes

* Apply correct `SYSTEM_FRAMEWORK_SEARCH_PATHS` for `XCTUnwrap` fix.
Expand Down
3 changes: 3 additions & 0 deletions lib/cocoapods/command/lib/lint.rb
Expand Up @@ -22,6 +22,7 @@ def self.options
['--fail-fast', 'Lint stops on the first failing platform or subspec'],
['--use-libraries', 'Lint uses static libraries to install the spec'],
['--use-modular-headers', 'Lint uses modular headers during installation'],
['--use-static-frameworks', 'Lint uses static frameworks during installation'],
["--sources=#{Pod::TrunkSource::TRUNK_REPO_URL}", 'The sources from which to pull dependent pods ' \
"(defaults to #{Pod::TrunkSource::TRUNK_REPO_URL}). Multiple sources must be comma-delimited"],
['--platforms=ios,macos', 'Lint against specific platforms (defaults to all platforms supported by the ' \
Expand All @@ -48,6 +49,7 @@ def initialize(argv)
@only_subspec = argv.option('subspec')
@use_frameworks = !argv.flag?('use-libraries')
@use_modular_headers = argv.flag?('use-modular-headers')
@use_static_frameworks = argv.flag?('use-static-frameworks')
@source_urls = argv.option('sources', Pod::TrunkSource::TRUNK_REPO_URL).split(',')
@platforms = argv.option('platforms', '').split(',')
@private = argv.flag?('private', false)
Expand Down Expand Up @@ -79,6 +81,7 @@ def run
validator.only_subspec = @only_subspec
validator.use_frameworks = @use_frameworks
validator.use_modular_headers = @use_modular_headers
validator.use_static_frameworks = @use_static_frameworks
validator.ignore_public_only_results = @private
validator.swift_version = @swift_version
validator.skip_import_validation = @skip_import_validation
Expand Down
3 changes: 3 additions & 0 deletions lib/cocoapods/command/spec/lint.rb
Expand Up @@ -24,6 +24,7 @@ def self.options
['--fail-fast', 'Lint stops on the first failing platform or subspec'],
['--use-libraries', 'Lint uses static libraries to install the spec'],
['--use-modular-headers', 'Lint uses modular headers during installation'],
['--use-static-frameworks', 'Lint uses static frameworks during installation'],
["--sources=#{Pod::TrunkSource::TRUNK_REPO_URL}", 'The sources from which to pull dependent pods ' \
"(defaults to #{Pod::TrunkSource::TRUNK_REPO_URL}). Multiple sources must be comma-delimited"],
['--platforms=ios,macos', 'Lint against specific platforms (defaults to all platforms supported by the ' \
Expand All @@ -47,6 +48,7 @@ def initialize(argv)
@only_subspec = argv.option('subspec')
@use_frameworks = !argv.flag?('use-libraries')
@use_modular_headers = argv.flag?('use-modular-headers')
@use_static_frameworks = argv.flag?('use-static-frameworks')
@source_urls = argv.option('sources', Pod::TrunkSource::TRUNK_REPO_URL).split(',')
@platforms = argv.option('platforms', '').split(',')
@private = argv.flag?('private', false)
Expand All @@ -72,6 +74,7 @@ def run
validator.only_subspec = @only_subspec
validator.use_frameworks = @use_frameworks
validator.use_modular_headers = @use_modular_headers
validator.use_static_frameworks = @use_static_frameworks
validator.ignore_public_only_results = @private
validator.swift_version = @swift_version
validator.skip_import_validation = @skip_import_validation
Expand Down
14 changes: 11 additions & 3 deletions lib/cocoapods/validator.rb
Expand Up @@ -257,6 +257,10 @@ def failure_reason
#
attr_accessor :use_modular_headers

# @return [Boolean] Whether static frameworks should be used for the installation.
#
attr_accessor :use_static_frameworks

# @return [Boolean] Whether attributes that affect only public sources
# Bool be skipped.
#
Expand Down Expand Up @@ -561,7 +565,7 @@ def deployment_target

def download_pod
test_spec_names = consumer.spec.test_specs.select { |ts| ts.supported_on_platform?(consumer.platform_name) }.map(&:name)
podfile = podfile_from_spec(consumer.platform_name, deployment_target, use_frameworks, test_spec_names, use_modular_headers)
podfile = podfile_from_spec(consumer.platform_name, deployment_target, use_frameworks, test_spec_names, use_modular_headers, use_static_frameworks)
sandbox = Sandbox.new(config.sandbox_root)
@installer = Installer.new(sandbox, podfile)
@installer.use_default_plugins = false
Expand Down Expand Up @@ -967,7 +971,7 @@ def initialize(type, attribute_name, message, public_only = false)
# @note The generated podfile takes into account whether the linter is
# in local mode.
#
def podfile_from_spec(platform_name, deployment_target, use_frameworks = true, test_spec_names = [], use_modular_headers = false)
def podfile_from_spec(platform_name, deployment_target, use_frameworks = true, test_spec_names = [], use_modular_headers = false, use_static_frameworks = false)
name = subspec_name || spec.name
podspec = file.realpath
local = local?
Expand All @@ -982,7 +986,11 @@ def podfile_from_spec(platform_name, deployment_target, use_frameworks = true, t
inhibit_all_warnings!
urls.each { |u| source(u) }
target 'App' do
use_frameworks!(use_frameworks)
if use_static_frameworks
use_frameworks!(:linkage => :static)
else
use_frameworks!(use_frameworks)
end
use_modular_headers! if use_modular_headers
platform(platform_name, deployment_target)
if local
Expand Down
24 changes: 12 additions & 12 deletions spec/functional/command/repo/push_spec.rb
Expand Up @@ -204,10 +204,10 @@ module Pod
end

it 'validates specs as frameworks by default' do
Validator.any_instance.expects(:podfile_from_spec).with(:ios, '8.0', true, [], false).times(3).returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:osx, nil, true, [], false).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:watchos, nil, true, [], false).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:tvos, nil, true, [], false).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:ios, '8.0', true, [], false, nil).times(3).returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:osx, nil, true, [], false, nil).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:watchos, nil, true, [], false, nil).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:tvos, nil, true, [], false, nil).twice.returns(stub('Podfile'))

cmd = command('repo', 'push', 'master')
# Git push will throw an exception here since this is a local custom git repo. All we care is the validator
Expand All @@ -218,10 +218,10 @@ module Pod
end

it 'validates specs as libraries if requested' do
Validator.any_instance.expects(:podfile_from_spec).with(:ios, nil, false, [], false).times(3).returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:osx, nil, false, [], false).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:watchos, nil, false, [], false).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:tvos, nil, false, [], false).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:ios, nil, false, [], false, nil).times(3).returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:osx, nil, false, [], false, nil).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:watchos, nil, false, [], false, nil).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:tvos, nil, false, [], false, nil).twice.returns(stub('Podfile'))

cmd = command('repo', 'push', 'master', '--use-libraries')
# Git push will throw an exception here since this is a local custom git repo. All we care is the validator
Expand All @@ -232,10 +232,10 @@ module Pod
end

it 'validates specs with modular headers if requested' do
Validator.any_instance.expects(:podfile_from_spec).with(:ios, nil, false, [], true).times(3).returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:osx, nil, false, [], true).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:watchos, nil, false, [], true).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:tvos, nil, false, [], true).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:ios, nil, false, [], true, nil).times(3).returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:osx, nil, false, [], true, nil).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:watchos, nil, false, [], true, nil).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:tvos, nil, false, [], true, nil).twice.returns(stub('Podfile'))

cmd = command('repo', 'push', 'master', '--use-libraries', '--use-modular-headers')
# Git push will throw an exception here since this is a local custom git repo. All we care is the validator
Expand Down
38 changes: 23 additions & 15 deletions spec/unit/validator_spec.rb
Expand Up @@ -400,8 +400,8 @@ def podspec_path(name = 'JSONKit', version = '1.4')
end
Installer.any_instance.stubs(:aggregate_targets).returns([])
Installer.any_instance.stubs(:pod_targets).returns([])
validator.expects(:podfile_from_spec).with(:osx, nil, false, [], nil).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:ios, nil, false, ['JSONKit/Tests'], nil).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:osx, nil, false, [], nil, nil).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:ios, nil, false, ['JSONKit/Tests'], nil, nil).once.returns(stub('Podfile'))
validator.validate
end

Expand Down Expand Up @@ -590,11 +590,11 @@ def podspec_path(name = 'JSONKit', version = '1.4')
s.ios.deployment_target = '7.0'
end
validator.spec.stubs(:subspecs).returns([subspec])
validator.expects(:podfile_from_spec).with(:osx, nil, false, [], nil).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:ios, nil, false, [], nil).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:ios, '7.0', false, [], nil).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:tvos, nil, false, [], nil).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:watchos, nil, false, [], nil).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:osx, nil, false, [], nil, nil).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:ios, nil, false, [], nil, nil).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:ios, '7.0', false, [], nil, nil).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:tvos, nil, false, [], nil, nil).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:watchos, nil, false, [], nil, nil).once.returns(stub('Podfile'))
validator.send(:perform_extensive_analysis, validator.spec)

validator.results_message.strip.should.be.empty
Expand Down Expand Up @@ -632,6 +632,14 @@ def podspec_path(name = 'JSONKit', version = '1.4')
podfile = @validator.send(:podfile_from_spec, :ios, '5.0', false, [], true)
target_definition = podfile.target_definitions['App']
target_definition.use_modular_headers_hash['all'].should.be.true
target_definition.uses_frameworks?.should == false
end

it 'validates with --use-static-frameworks' do
podfile = @validator.send(:podfile_from_spec, :ios, '5.0', false, [], false, true)
target_definition = podfile.target_definitions['App']
target_definition.uses_frameworks?.should == true
target_definition.use_frameworks!.should == { :linkage => :dynamic, :packaging => :framework }
end

it 'inhibits warnings for all pods except the one being validated' do
Expand Down Expand Up @@ -1129,10 +1137,10 @@ def setup_validator

setup_validator

@validator.expects(:podfile_from_spec).with(:osx, nil, true, [], nil).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:ios, '8.0', true, [], nil).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:tvos, nil, true, [], nil).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:watchos, nil, true, [], nil).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:osx, nil, true, [], nil, nil).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:ios, '8.0', true, [], nil, nil).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:tvos, nil, true, [], nil, nil).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:watchos, nil, true, [], nil, nil).once.returns(stub('Podfile'))
@validator.send(:perform_extensive_analysis, @validator.spec)

@validator.results_message.strip.should.be.empty
Expand All @@ -1143,10 +1151,10 @@ def setup_validator

setup_validator

@validator.expects(:podfile_from_spec).with(:osx, nil, false, [], nil).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:ios, nil, false, [], nil).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:tvos, nil, false, [], nil).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:watchos, nil, false, [], nil).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:osx, nil, false, [], nil, nil).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:ios, nil, false, [], nil, nil).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:tvos, nil, false, [], nil, nil).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:watchos, nil, false, [], nil, nil).once.returns(stub('Podfile'))
@validator.send(:perform_extensive_analysis, @validator.spec)

@validator.results_message.strip.should.be.empty
Expand Down