Commit 19203fc0 authored by Danielle Tomlinson's avatar Danielle Tomlinson Committed by GitHub

Merge pull request #6811 from paulb777/static_framework

Add support for source static library frameworks
parents ef57aecc bf7a2e66
...@@ -12,6 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -12,6 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
dependency resolution. dependency resolution.
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
* Add support for source static library frameworks
[Paul Beusterien](https://github.com/paulb777)
[#6811](https://github.com/CocoaPods/CocoaPods/pull/6811)
##### Bug Fixes ##### Bug Fixes
* None. * None.
...@@ -111,7 +115,6 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -111,7 +115,6 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
## 1.3.0.beta.2 (2017-06-22) ## 1.3.0.beta.2 (2017-06-22)
##### Enhancements ##### Enhancements
* Add inputs and outputs for resources script phase * Add inputs and outputs for resources script phase
[Dimitris Koutsogiorgas](https://github.com/dnkoutso) [Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#6806](https://github.com/CocoaPods/CocoaPods/pull/6806) [#6806](https://github.com/CocoaPods/CocoaPods/pull/6806)
......
...@@ -225,12 +225,13 @@ module Pod ...@@ -225,12 +225,13 @@ module Pod
aggregate_target.native_target.add_dependency(pod_target.native_target) aggregate_target.native_target.add_dependency(pod_target.native_target)
configure_app_extension_api_only_for_target(pod_target) if is_app_extension configure_app_extension_api_only_for_target(pod_target) if is_app_extension
unless pod_target.static_framework?
add_dependent_targets_to_native_target(pod_target.dependent_targets, pod_target.native_target, is_app_extension, pod_target.requires_frameworks?, frameworks_group) add_dependent_targets_to_native_target(pod_target.dependent_targets, pod_target.native_target, is_app_extension, pod_target.requires_frameworks?, frameworks_group)
add_pod_target_test_dependencies(pod_target, frameworks_group) add_pod_target_test_dependencies(pod_target, frameworks_group)
end end
end end
end end
end
# @param [String] pod The root name of the development pod. # @param [String] pod The root name of the development pod.
# #
......
...@@ -25,7 +25,9 @@ module Pod ...@@ -25,7 +25,9 @@ module Pod
create_xcconfig_file create_xcconfig_file
create_test_xcconfig_files if target.contains_test_specifications? create_test_xcconfig_files if target.contains_test_specifications?
if target.requires_frameworks? if target.requires_frameworks?
unless target.static_framework?
create_info_plist_file create_info_plist_file
end
create_module_map create_module_map
create_umbrella_header do |generator| create_umbrella_header do |generator|
file_accessors = target.file_accessors file_accessors = target.file_accessors
...@@ -39,6 +41,9 @@ module Pod ...@@ -39,6 +41,9 @@ module Pod
end end
end end
create_build_phase_to_symlink_header_folders create_build_phase_to_symlink_header_folders
if target.static_framework?
create_build_phase_to_move_static_framework_archive
end
end end
create_prefix_header create_prefix_header
create_dummy_source create_dummy_source
...@@ -388,6 +393,22 @@ module Pod ...@@ -388,6 +393,22 @@ module Pod
eos eos
end end
# Creates a build phase to put the static framework archive in the appropriate framework location
# Since Xcode does not provide template support for static library frameworks, we've built a static library
# of the form lib{LibraryName}.a. We need to move that to the framework location -
# {LibraryName}.framework/{LibraryName}.
#
# @return [void]
#
def create_build_phase_to_move_static_framework_archive
build_phase = native_target.new_shell_script_build_phase('Setup Static Framework Archive')
build_phase.shell_script = <<-eos.strip_heredoc
mkdir -p "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework/Modules"
cp "${BUILT_PRODUCTS_DIR}/lib${PRODUCT_NAME}.a" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework/${PRODUCT_NAME}"
cp "${MODULEMAP_FILE}" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework/Modules/module.modulemap"
eos
end
# Creates a prefix header file which imports `UIKit` or `Cocoa` according # Creates a prefix header file which imports `UIKit` or `Cocoa` according
# to the platform of the target. This file also include any prefix header # to the platform of the target. This file also include any prefix header
# content reported by the specification of the pods. # content reported by the specification of the pods.
......
...@@ -81,7 +81,11 @@ module Pod ...@@ -81,7 +81,11 @@ module Pod
end end
if target.requires_frameworks? if target.requires_frameworks?
settings['PRODUCT_NAME'] = target.product_module_name framework_name = target.product_module_name
settings['PRODUCT_NAME'] = framework_name
if target.static_framework?
settings['PUBLIC_HEADERS_FOLDER_PATH'] = framework_name + '.framework' + '/Headers'
end
else else
settings.merge!('OTHER_LDFLAGS' => '', 'OTHER_LIBTOOLFLAGS' => '') settings.merge!('OTHER_LDFLAGS' => '', 'OTHER_LIBTOOLFLAGS' => '')
end end
......
...@@ -73,7 +73,7 @@ module Pod ...@@ -73,7 +73,7 @@ module Pod
aggregate_target.user_build_configurations.keys.each do |config| aggregate_target.user_build_configurations.keys.each do |config|
pod_targets = aggregate_target.pod_targets_for_build_configuration(config) pod_targets = aggregate_target.pod_targets_for_build_configuration(config)
dependencies = pod_targets.select(&:should_build?).flat_map(&:dependencies) dependencies = pod_targets.select(&:should_build?).reject(&:static_framework?).flat_map(&:dependencies)
depended_upon_targets = pod_targets.select { |t| dependencies.include?(t.pod_name) && !t.should_build? } depended_upon_targets = pod_targets.select { |t| dependencies.include?(t.pod_name) && !t.should_build? }
static_libs = depended_upon_targets.flat_map(&:file_accessors).flat_map(&:vendored_static_artifacts) static_libs = depended_upon_targets.flat_map(&:file_accessors).flat_map(&:vendored_static_artifacts)
......
...@@ -72,7 +72,7 @@ module Pod ...@@ -72,7 +72,7 @@ module Pod
# #requires_frameworks?. # #requires_frameworks?.
# #
def product_type def product_type
requires_frameworks? ? :framework : :static_library requires_frameworks? && !static_framework? ? :framework : :static_library
end end
# @return [String] A string suitable for debugging. # @return [String] A string suitable for debugging.
...@@ -90,6 +90,12 @@ module Pod ...@@ -90,6 +90,12 @@ module Pod
host_requires_frameworks? || false host_requires_frameworks? || false
end end
# @return [Boolean] Whether the target should build a static framework.
#
def static_framework?
!is_a?(Pod::AggregateTarget) && specs.any? && specs.all?(&:static_framework)
end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
# @!group Information storage # @!group Information storage
......
...@@ -219,7 +219,7 @@ module Pod ...@@ -219,7 +219,7 @@ module Pod
end end
frameworks << framework frameworks << framework
end end
if should_build? && requires_frameworks? if should_build? && requires_frameworks? && !static_framework?
frameworks << { :name => product_name, frameworks << { :name => product_name,
:input_path => build_product_path('${BUILT_PRODUCTS_DIR}'), :input_path => build_product_path('${BUILT_PRODUCTS_DIR}'),
:output_path => "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{product_name}" } :output_path => "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{product_name}" }
......
...@@ -207,6 +207,16 @@ module Pod ...@@ -207,6 +207,16 @@ module Pod
script.read.should.not.include?('BananaLib.framework') script.read.should.not.include?('BananaLib.framework')
end end
it 'does not add pods to the embed frameworks script if they are static' do
@pod_target.stubs(:static_framework? => true)
@pod_target.stubs(:requires_frameworks? => true)
@target.stubs(:requires_frameworks? => true)
@installer.install!
support_files_dir = config.sandbox.target_support_files_dir('Pods-SampleProject')
script = support_files_dir + 'Pods-SampleProject-frameworks.sh'
script.read.should.not.include?('BananaLib.framework')
end
it 'creates the acknowledgements files ' do it 'creates the acknowledgements files ' do
@installer.install! @installer.install!
support_files_dir = config.sandbox.target_support_files_dir('Pods-SampleProject') support_files_dir = config.sandbox.target_support_files_dir('Pods-SampleProject')
......
...@@ -603,6 +603,18 @@ module Pod ...@@ -603,6 +603,18 @@ module Pod
end end
build_phase.should.not.be.nil build_phase.should.not.be.nil
end end
it 'creates a build phase to set up a static library framework' do
@pod_target.stubs(:static_framework?).returns(true)
@installer.install!
target = @project.native_targets.first
build_phase = target.shell_script_build_phases.find do |bp|
bp.name == 'Setup Static Framework Archive'
end
build_phase.should.not.be.nil
end
end end
it "doesn't create a build phase to symlink header folders by default on OS X" do it "doesn't create a build phase to symlink header folders by default on OS X" do
......
...@@ -60,6 +60,18 @@ module Pod ...@@ -60,6 +60,18 @@ module Pod
'AppStore' => nil, 'AppStore' => nil,
} }
end end
it 'verify header path for a static library framework' do
@pod_target.stubs(:requires_frameworks?).returns(true)
@pod_target.stubs(:static_framework?).returns(true)
@installer.send(:add_target)
@installer.send(:native_target).resolved_build_setting('PUBLIC_HEADERS_FOLDER_PATH').should == {
'Release' => 'BananaLib.framework/Headers',
'Debug' => 'BananaLib.framework/Headers',
'Test' => 'BananaLib.framework/Headers',
'AppStore' => 'BananaLib.framework/Headers',
}
end
end end
end end
end end
......
...@@ -133,6 +133,7 @@ module Pod ...@@ -133,6 +133,7 @@ module Pod
project 'SampleProject/SampleProject' project 'SampleProject/SampleProject'
use_frameworks! use_frameworks!
pod 'BananaLib', :path => (fixture_path + 'banana-lib').to_s pod 'BananaLib', :path => (fixture_path + 'banana-lib').to_s
pod 'CoconutLib', :path => (fixture_path + 'coconut-lib').to_s
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s pod 'matryoshka', :path => (fixture_path + 'matryoshka').to_s
pod 'monkey', :path => (fixture_path + 'monkey').to_s pod 'monkey', :path => (fixture_path + 'monkey').to_s
...@@ -148,6 +149,11 @@ module Pod ...@@ -148,6 +149,11 @@ module Pod
end end
it 'detects transitive static dependencies which are linked directly to the user target' do it 'detects transitive static dependencies which are linked directly to the user target' do
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.raise(Informative) { @validator.validate! }.message.should.match /transitive.*monkey.a/
end
it 'detects transitive static dependencies which are linked directly to the user target with stubbing' do
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing]) Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing])
@validator = create_validator(config.sandbox, @podfile, @lockfile) @validator = create_validator(config.sandbox, @podfile, @lockfile)
should.raise(Informative) { @validator.validate! }.message.should.match /transitive.*libThing/ should.raise(Informative) { @validator.validate! }.message.should.match /transitive.*libThing/
...@@ -166,6 +172,13 @@ module Pod ...@@ -166,6 +172,13 @@ module Pod
@validator = create_validator(config.sandbox, @podfile, @lockfile) @validator = create_validator(config.sandbox, @podfile, @lockfile)
should.not.raise(Informative) { @validator.validate! } should.not.raise(Informative) { @validator.validate! }
end end
it 'allows transitive static dependencies when building a static framework' do
PodTarget.any_instance.stubs(:static_framework? => true)
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@lib_thing])
@validator = create_validator(config.sandbox, @podfile, @lockfile)
should.not.raise(Informative) { @validator.validate! }
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