Skip to content

Commit

Permalink
Expand use_frameworks! DSL to accept linkage style.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnkoutso committed Aug 11, 2019
1 parent 0a6dea9 commit d5f6a30
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 306 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

##### Enhancements

* Expand `use_frameworks!` DSL to accept linkage style.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#XXX](https://github.com/CocoaPods/Core/pull/XXX)

* Extend `script_phase` DSL to support dependency file.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#579](https://github.com/CocoaPods/Core/pull/579)
Expand Down
4 changes: 2 additions & 2 deletions lib/cocoapods-core/podfile/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,8 @@ def use_modular_headers!
#
# This attribute is inherited by child target definitions.
#
def use_frameworks!(flag = true)
current_target_definition.use_frameworks!(flag)
def use_frameworks!(options = true)
current_target_definition.use_frameworks!(options)
end

# Specifies the Swift version requirements this target definition supports.
Expand Down
41 changes: 31 additions & 10 deletions lib/cocoapods-core/podfile/target_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,25 +365,46 @@ def set_inhibit_warnings_for_pod(pod_name, should_inhibit)

#--------------------------------------#

# Sets whether the target definition should build a framework.
# The (desired) build type for the pods integrated in this target definition. Defaults to static libraries and can
# only be overridden through TargetDefinition#use_frameworks!.
#
# @param [Bool] flag
# Whether a framework should be built.
# @return [Hash]
#
def build_type
if root?
get_hash_value('build_type', :linkage => :static, :packaging => :library)
else
get_hash_value('build_type', parent.build_type)
end
end

# Sets whether the target definition's pods should be built as frameworks.
#
# @param [Bool,Hash] option
# Whether pods that are integrated in this target should be built as frameworks. If this option is a
# boolean then the value affects both packaging and linkage styles. If set to true then dynamic frameworks
# are used and if the value is set to false then static libraries are used. If the value is a hash then
# `:framework` packaging is implied and the user configures the `:linkage` style to use.
#
# @return [void]
#
def use_frameworks!(flag = true)
set_hash_value('uses_frameworks', flag)
def use_frameworks!(option = true)
value = case option
when true, false
{ :linkage => option ? :dynamic : :static, :packaging => option ? :framework : :library }
when Hash
option.merge(:packaging => :framework)
end
set_hash_value('build_type', value)
end

# @return [Bool] whether the target definition should build
# a framework.
# @return [Bool] whether the target definition pods should be built as frameworks.
#
def uses_frameworks?
if internal_hash['uses_frameworks'].nil?
if internal_hash['build_type'].nil?
root? ? false : parent.uses_frameworks?
else
get_hash_value('uses_frameworks')
build_type[:packaging] == :framework
end
end

Expand Down Expand Up @@ -790,7 +811,7 @@ def store_script_phase(options)
script_phases
children
configuration_pod_whitelist
uses_frameworks
build_type
swift_version_requirements
inheritance
abstract
Expand Down
146 changes: 0 additions & 146 deletions spec/fixtures/vcr_cassettes/Source_fetch.yml

This file was deleted.

146 changes: 0 additions & 146 deletions spec/fixtures/vcr_cassettes/Source_nofetch.yml

This file was deleted.

Loading

0 comments on commit d5f6a30

Please sign in to comment.