Commit c8ce4ad1 authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #2461 from mrackwitz/refactorings

Refactorings in Preparation to Framework Support
parents ca511f0f 8f0a245e
...@@ -10,6 +10,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -10,6 +10,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
repo push` in CocoaPods 0.33. repo push` in CocoaPods 0.33.
[Fabio Pelosin](https://github.com/fabiopelosin) [Fabio Pelosin](https://github.com/fabiopelosin)
* Refactorings in preparation to framework support, which could break usages
of the Hooks-API.
[Marius Rackwitz](https://github.com/mrackwitz)
[#2461](https://github.com/CocoaPods/CocoaPods/issues/2461)
## 0.34.4 ## 0.34.4
......
...@@ -56,6 +56,7 @@ module Pod ...@@ -56,6 +56,7 @@ module Pod
autoload :BridgeSupport, 'cocoapods/generator/bridge_support' autoload :BridgeSupport, 'cocoapods/generator/bridge_support'
autoload :CopyResourcesScript, 'cocoapods/generator/copy_resources_script' autoload :CopyResourcesScript, 'cocoapods/generator/copy_resources_script'
autoload :DummySource, 'cocoapods/generator/dummy_source' autoload :DummySource, 'cocoapods/generator/dummy_source'
autoload :Header, 'cocoapods/generator/header'
autoload :PrefixHeader, 'cocoapods/generator/prefix_header' autoload :PrefixHeader, 'cocoapods/generator/prefix_header'
autoload :TargetEnvironmentHeader, 'cocoapods/generator/target_environment_header' autoload :TargetEnvironmentHeader, 'cocoapods/generator/target_environment_header'
autoload :XCConfig, 'cocoapods/generator/xcconfig' autoload :XCConfig, 'cocoapods/generator/xcconfig'
......
module Pod
module Generator
# Generates a header file.
#
# According to the platform the header imports `UIKit/UIKit.h` or
# `Cocoa/Cocoa.h`.
#
class Header
# @return [Symbol] the platform for which the prefix header will be
# generated.
#
attr_reader :platform
# @return [Array<String>] The list of the headers to import.
#
attr_reader :imports
# @param [Symbol] platform
# @see platform
#
def initialize(platform)
@platform = platform
@imports = []
end
# Generates the contents of the header according to the platform.
#
# @note If the platform is iOS an import call to `UIKit/UIKit.h` is
# added to the top of the prefix header. For OS X `Cocoa/Cocoa.h`
# is imported.
#
# @return [String]
#
def generate
result = ""
result << generate_platform_import_header
result << "\n"
imports.each do |import|
result << %|#import "#{import}"\n|
end
result
end
# Generates and saves the header to the given path.
#
# @param [Pathname] path
# The path where the header should be stored.
#
# @return [void]
#
def save_as(path)
path.open('w') { |header| header.write(generate) }
end
#-----------------------------------------------------------------------#
protected
# Generates the contents of the header according to the platform.
#
# @note If the platform is iOS an import call to `UIKit/UIKit.h` is
# added to the top of the header. For OS X `Cocoa/Cocoa.h` is
# imported.
#
# @return [String]
#
def generate_platform_import_header
"#import #{platform == :ios ? '<UIKit/UIKit.h>' : '<Cocoa/Cocoa.h>'}\n"
end
end
end
end
...@@ -6,38 +6,26 @@ module Pod ...@@ -6,38 +6,26 @@ module Pod
# According to the platform the prefix header imports `UIKit/UIKit.h` or # According to the platform the prefix header imports `UIKit/UIKit.h` or
# `Cocoa/Cocoa.h`. # `Cocoa/Cocoa.h`.
# #
class PrefixHeader class PrefixHeader < Header
# @return [Array<FileAccessor>] The file accessors for which to generate # @return [Array<FileAccessor>] The file accessors for which to generate
# the prefix header. # the prefix header.
# #
attr_reader :file_accessors attr_reader :file_accessors
# @return [Platform] the platform for which the prefix header will be # @param [Array<FileAccessor>] file_accessors
# generated. # @see file_accessors
# #
attr_reader :platform # @param [Platform] platform
# @see platform
# @return [Array<String>] The list of the headers to import (with
# quotes).
#
attr_reader :imports
# @param [Platform] platform @see platform
# @param [Array<LocalPod>] consumers @see consumers
# #
def initialize(file_accessors, platform) def initialize(file_accessors, platform)
@file_accessors = file_accessors @file_accessors = file_accessors
@platform = platform super platform
@imports = []
end end
# Generates the contents of the prefix header according to the platform # Generates the contents of the prefix header according to the platform
# and the pods. # and the pods.
# #
# @note If the platform is iOS an import call to `UIKit/UIKit.h` is
# added to the top of the prefix header. For OS X `Cocoa/Cocoa.h`
# is imported.
#
# @note Only unique prefix_header_contents are added to the prefix # @note Only unique prefix_header_contents are added to the prefix
# header. # header.
# #
...@@ -48,20 +36,12 @@ module Pod ...@@ -48,20 +36,12 @@ module Pod
# file_accessor.prefix_header. # file_accessor.prefix_header.
# #
def generate def generate
result = "#ifdef __OBJC__\n" result = super
result << "#import #{platform == :ios ? '<UIKit/UIKit.h>' : '<Cocoa/Cocoa.h>'}\n"
result << "#endif\n"
imports.each do |import|
result << %(\n#import "#{import}")
end
unique_prefix_header_contents = file_accessors.map do |file_accessor| unique_prefix_header_contents = file_accessors.map do |file_accessor|
file_accessor.spec_consumer.prefix_header_contents file_accessor.spec_consumer.prefix_header_contents
end.compact.uniq end.compact.uniq
result << "\n"
unique_prefix_header_contents.each do |prefix_header_contents| unique_prefix_header_contents.each do |prefix_header_contents|
result << prefix_header_contents result << prefix_header_contents
result << "\n" result << "\n"
...@@ -75,15 +55,16 @@ module Pod ...@@ -75,15 +55,16 @@ module Pod
result result
end end
# Generates and saves the prefix header to the given path. protected
#
# @param [Pathname] path # Generates the contents of the header according to the platform.
# the path where the prefix header should be stored.
# #
# @return [void] # @return [String]
# #
def save_as(path) def generate_platform_import_header
path.open('w') { |header| header.write(generate) } result = "#ifdef __OBJC__\n"
result << super
result << "#endif\n"
end end
end end
end end
......
...@@ -69,7 +69,7 @@ module Pod ...@@ -69,7 +69,7 @@ module Pod
# process. # process.
# #
def target def target
library.target library.native_target
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
......
...@@ -418,7 +418,7 @@ module Pod ...@@ -418,7 +418,7 @@ module Pod
pod_targets.sort_by(&:name).each do |pod_target| pod_targets.sort_by(&:name).each do |pod_target|
pod_target.file_accessors.each do |file_accessor| pod_target.file_accessors.each do |file_accessor|
file_accessor.spec_consumer.frameworks.each do |framework| file_accessor.spec_consumer.frameworks.each do |framework|
pod_target.target.add_system_framework(framework) pod_target.native_target.add_system_framework(framework)
end end
end end
end end
...@@ -428,7 +428,7 @@ module Pod ...@@ -428,7 +428,7 @@ module Pod
def set_target_dependencies def set_target_dependencies
aggregate_targets.each do |aggregate_target| aggregate_targets.each do |aggregate_target|
aggregate_target.pod_targets.each do |pod_target| aggregate_target.pod_targets.each do |pod_target|
aggregate_target.target.add_dependency(pod_target.target) aggregate_target.native_target.add_dependency(pod_target.native_target)
pod_target.dependencies.each do |dep| pod_target.dependencies.each do |dep|
unless dep == pod_target.pod_name unless dep == pod_target.pod_name
...@@ -437,7 +437,7 @@ module Pod ...@@ -437,7 +437,7 @@ module Pod
unless pod_dependency_target unless pod_dependency_target
puts "[BUG] DEP: #{dep}" puts "[BUG] DEP: #{dep}"
end end
pod_target.target.add_dependency(pod_dependency_target.target) pod_target.native_target.add_dependency(pod_dependency_target.native_target)
end end
end end
end end
......
...@@ -10,16 +10,16 @@ module Pod ...@@ -10,16 +10,16 @@ module Pod
# #
attr_reader :sandbox attr_reader :sandbox
# @return [Library] The library whose target needs to be generated. # @return [Target] The library whose target needs to be generated.
# #
attr_reader :library attr_reader :target
# @param [Project] project @see project # @param [Project] project @see project
# @param [Library] library @see library # @param [Target] target @see target
# #
def initialize(sandbox, library) def initialize(sandbox, target)
@sandbox = sandbox @sandbox = sandbox
@library = library @target = target
end end
private private
...@@ -36,31 +36,31 @@ module Pod ...@@ -36,31 +36,31 @@ module Pod
# @return [void] # @return [void]
# #
def add_target def add_target
name = library.label name = target.label
platform = library.platform.name platform = target.platform.name
deployment_target = library.platform.deployment_target.to_s deployment_target = target.platform.deployment_target.to_s
@target = project.new_target(:static_library, name, platform, deployment_target) @native_target = project.new_target(:static_library, name, platform, deployment_target)
library.user_build_configurations.each do |bc_name, type| target.user_build_configurations.each do |bc_name, type|
configuration = @target.add_build_configuration(bc_name, type) configuration = @native_target.add_build_configuration(bc_name, type)
end end
settings = { 'OTHER_LDFLAGS' => '', 'OTHER_LIBTOOLFLAGS' => '' } settings = { 'OTHER_LDFLAGS' => '', 'OTHER_LIBTOOLFLAGS' => '' }
if library.archs if target.archs
settings['ARCHS'] = library.archs settings['ARCHS'] = target.archs
end end
@target.build_configurations.each do |configuration| @native_target.build_configurations.each do |configuration|
configuration.build_settings.merge!(settings) configuration.build_settings.merge!(settings)
end end
library.target = @target target.native_target = @native_target
end end
# Creates the directory where to store the support files of the target. # Creates the directory where to store the support files of the target.
# #
def create_support_files_dir def create_support_files_dir
library.support_files_dir.mkdir target.support_files_dir.mkdir
end end
# Generates a dummy source file for each target so libraries that contain # Generates a dummy source file for each target so libraries that contain
...@@ -69,11 +69,11 @@ module Pod ...@@ -69,11 +69,11 @@ module Pod
# @return [void] # @return [void]
# #
def create_dummy_source def create_dummy_source
path = library.dummy_source_path path = target.dummy_source_path
generator = Generator::DummySource.new(library.label) generator = Generator::DummySource.new(target.label)
generator.save_as(path) generator.save_as(path)
file_reference = add_file_to_support_group(path) file_reference = add_file_to_support_group(path)
target.source_build_phase.add_file_reference(file_reference) native_target.source_build_phase.add_file_reference(file_reference)
end end
# @return [PBXNativeTarget] the target generated by the installation # @return [PBXNativeTarget] the target generated by the installation
...@@ -81,7 +81,7 @@ module Pod ...@@ -81,7 +81,7 @@ module Pod
# #
# @note Generated by the {#add_target} step. # @note Generated by the {#add_target} step.
# #
attr_reader :target attr_reader :native_target
private private
...@@ -98,7 +98,7 @@ module Pod ...@@ -98,7 +98,7 @@ module Pod
# @return [TargetDefinition] the target definition of the library. # @return [TargetDefinition] the target definition of the library.
# #
def target_definition def target_definition
library.target_definition target.target_definition
end end
# @return [PBXGroup] the group where the file references to the support # @return [PBXGroup] the group where the file references to the support
......
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
# @return [void] # @return [void]
# #
def install! def install!
UI.message "- Installing target `#{library.name}` #{library.platform}" do UI.message "- Installing target `#{target.name}` #{target.platform}" do
add_target add_target
create_support_files_dir create_support_files_dir
create_suport_files_group create_suport_files_group
...@@ -33,8 +33,8 @@ module Pod ...@@ -33,8 +33,8 @@ module Pod
# #
def create_suport_files_group def create_suport_files_group
parent = project.support_files_group parent = project.support_files_group
name = library.name name = target.name
dir = library.support_files_dir dir = target.support_files_dir
@support_files_group = parent.new_group(name, dir) @support_files_group = parent.new_group(name, dir)
end end
...@@ -43,11 +43,11 @@ module Pod ...@@ -43,11 +43,11 @@ module Pod
# @return [void] # @return [void]
# #
def create_xcconfig_file def create_xcconfig_file
target.build_configurations.each do |configuration| native_target.build_configurations.each do |configuration|
path = library.xcconfig_path(configuration.name) path = target.xcconfig_path(configuration.name)
gen = Generator::XCConfig::AggregateXCConfig.new(library, configuration.name) gen = Generator::XCConfig::AggregateXCConfig.new(target, configuration.name)
gen.save_as(path) gen.save_as(path)
library.xcconfigs[configuration.name] = gen.xcconfig target.xcconfigs[configuration.name] = gen.xcconfig
xcconfig_file_ref = add_file_to_support_group(path) xcconfig_file_ref = add_file_to_support_group(path)
configuration.base_configuration_reference = xcconfig_file_ref configuration.base_configuration_reference = xcconfig_file_ref
end end
...@@ -57,8 +57,8 @@ module Pod ...@@ -57,8 +57,8 @@ module Pod
# pods and the installed specifications of a pod. # pods and the installed specifications of a pod.
# #
def create_target_environment_header def create_target_environment_header
path = library.target_environment_header_path path = target.target_environment_header_path
generator = Generator::TargetEnvironmentHeader.new(library.specs_by_build_configuration) generator = Generator::TargetEnvironmentHeader.new(target.specs_by_build_configuration)
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
end end
...@@ -66,15 +66,15 @@ module Pod ...@@ -66,15 +66,15 @@ module Pod
# Generates the bridge support metadata if requested by the {Podfile}. # Generates the bridge support metadata if requested by the {Podfile}.
# #
# @note The bridge support metadata is added to the resources of the # @note The bridge support metadata is added to the resources of the
# library because it is needed for environments interpreted at # target because it is needed for environments interpreted at
# runtime. # runtime.
# #
# @return [void] # @return [void]
# #
def create_bridge_support_file def create_bridge_support_file
if target_definition.podfile.generate_bridge_support? if target_definition.podfile.generate_bridge_support?
path = library.bridge_support_path path = target.bridge_support_path
headers = target.headers_build_phase.files.map { |bf| sandbox.root + bf.file_ref.path } headers = native_target.headers_build_phase.files.map { |bf| sandbox.root + bf.file_ref.path }
generator = Generator::BridgeSupport.new(headers) generator = Generator::BridgeSupport.new(headers)
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
...@@ -91,15 +91,15 @@ module Pod ...@@ -91,15 +91,15 @@ module Pod
# @return [void] # @return [void]
# #
def create_copy_resources_script def create_copy_resources_script
path = library.copy_resources_script_path path = target.copy_resources_script_path
file_accessors = library.pod_targets.map(&:file_accessors).flatten file_accessors = target.pod_targets.map(&:file_accessors).flatten
resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map { |res| res.relative_path_from(project.path.dirname) } }.flatten resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map { |res| res.relative_path_from(project.path.dirname) } }.flatten
resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map { |name| "${BUILT_PRODUCTS_DIR}/#{name}.bundle" } }.flatten resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map { |name| "${BUILT_PRODUCTS_DIR}/#{name}.bundle" } }.flatten
resources = [] resources = []
resources.concat(resource_paths) resources.concat(resource_paths)
resources.concat(resource_bundles) resources.concat(resource_bundles)
resources << bridge_support_file if bridge_support_file resources << bridge_support_file if bridge_support_file
generator = Generator::CopyResourcesScript.new(resources, library.platform) generator = Generator::CopyResourcesScript.new(resources, target.platform)
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
end end
...@@ -109,10 +109,10 @@ module Pod ...@@ -109,10 +109,10 @@ module Pod
# @return [void] # @return [void]
# #
def create_acknowledgements def create_acknowledgements
basepath = library.acknowledgements_basepath basepath = target.acknowledgements_basepath
Generator::Acknowledgements.generators.each do |generator_class| Generator::Acknowledgements.generators.each do |generator_class|
path = generator_class.path_from_basepath(basepath) path = generator_class.path_from_basepath(basepath)
file_accessors = library.pod_targets.map(&:file_accessors).flatten file_accessors = target.pod_targets.map(&:file_accessors).flatten
generator = generator_class.new(file_accessors) generator = generator_class.new(file_accessors)
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
......
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
# @return [void] # @return [void]
# #
def install! def install!
UI.message "- Installing target `#{library.name}` #{library.platform}" do UI.message "- Installing target `#{target.name}` #{target.platform}" do
add_target add_target
create_support_files_dir create_support_files_dir
add_files_to_build_phases add_files_to_build_phases
...@@ -33,15 +33,15 @@ module Pod ...@@ -33,15 +33,15 @@ module Pod
# @return [void] # @return [void]
# #
def add_files_to_build_phases def add_files_to_build_phases
library.file_accessors.each do |file_accessor| target.file_accessors.each do |file_accessor|
consumer = file_accessor.spec_consumer consumer = file_accessor.spec_consumer
flags = compiler_flags_for_consumer(consumer) flags = compiler_flags_for_consumer(consumer)
all_source_files = file_accessor.source_files all_source_files = file_accessor.source_files
regular_source_files = all_source_files.reject { |sf| sf.extname == '.d' } regular_source_files = all_source_files.reject { |sf| sf.extname == '.d' }
regular_file_refs = regular_source_files.map { |sf| project.reference_for_path(sf) } regular_file_refs = regular_source_files.map { |sf| project.reference_for_path(sf) }
target.add_file_references(regular_file_refs, flags) native_target.add_file_references(regular_file_refs, flags)
other_file_refs = (all_source_files - regular_source_files).map { |sf| project.reference_for_path(sf) } other_file_refs = (all_source_files - regular_source_files).map { |sf| project.reference_for_path(sf) }
target.add_file_references(other_file_refs, nil) native_target.add_file_references(other_file_refs, nil)
end end
end end
...@@ -53,22 +53,22 @@ module Pod ...@@ -53,22 +53,22 @@ module Pod
# @return [void] # @return [void]
# #
def add_resources_bundle_targets def add_resources_bundle_targets
library.file_accessors.each do |file_accessor| target.file_accessors.each do |file_accessor|
file_accessor.resource_bundles.each do |bundle_name, paths| file_accessor.resource_bundles.each do |bundle_name, paths|
# Add a dependency on an existing Resource Bundle target if possible # Add a dependency on an existing Resource Bundle target if possible
if bundle_target = project.targets.find { |target| target.name == bundle_name } if bundle_target = project.targets.find { |target| target.name == bundle_name }
target.add_dependency(bundle_target) native_target.add_dependency(bundle_target)
next next
end end
file_references = paths.map { |sf| project.reference_for_path(sf) } file_references = paths.map { |sf| project.reference_for_path(sf) }
bundle_target = project.new_resources_bundle(bundle_name, file_accessor.spec_consumer.platform_name) bundle_target = project.new_resources_bundle(bundle_name, file_accessor.spec_consumer.platform_name)
bundle_target.add_resources(file_references) bundle_target.add_resources(file_references)
library.user_build_configurations.each do |bc_name, type| target.user_build_configurations.each do |bc_name, type|
bundle_target.add_build_configuration(bc_name, type) bundle_target.add_build_configuration(bc_name, type)
end end
target.add_dependency(bundle_target) native_target.add_dependency(bundle_target)
end end
end end
end end
...@@ -78,17 +78,17 @@ module Pod ...@@ -78,17 +78,17 @@ module Pod
# @return [void] # @return [void]
# #
def create_xcconfig_file def create_xcconfig_file
path = library.xcconfig_path path = target.xcconfig_path
public_gen = Generator::XCConfig::PublicPodXCConfig.new(library) public_gen = Generator::XCConfig::PublicPodXCConfig.new(target)
public_gen.save_as(path) public_gen.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
path = library.xcconfig_private_path path = target.xcconfig_private_path
private_gen = Generator::XCConfig::PrivatePodXCConfig.new(library, public_gen.xcconfig) private_gen = Generator::XCConfig::PrivatePodXCConfig.new(target, public_gen.xcconfig)
private_gen.save_as(path) private_gen.save_as(path)
xcconfig_file_ref = add_file_to_support_group(path) xcconfig_file_ref = add_file_to_support_group(path)
target.build_configurations.each do |c| native_target.build_configurations.each do |c|
c.base_configuration_reference = xcconfig_file_ref c.base_configuration_reference = xcconfig_file_ref
end end
end end
...@@ -100,13 +100,13 @@ module Pod ...@@ -100,13 +100,13 @@ module Pod
# @return [void] # @return [void]
# #
def create_prefix_header def create_prefix_header
path = library.prefix_header_path path = target.prefix_header_path
generator = Generator::PrefixHeader.new(library.file_accessors, library.platform) generator = Generator::PrefixHeader.new(target.file_accessors, target.platform)
generator.imports << library.target_environment_header_path.basename generator.imports << target.target_environment_header_path.basename
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
target.build_configurations.each do |c| native_target.build_configurations.each do |c|
relative_path = path.relative_path_from(project.path.dirname) relative_path = path.relative_path_from(project.path.dirname)
c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
end end
...@@ -176,8 +176,8 @@ module Pod ...@@ -176,8 +176,8 @@ module Pod
# @return [PBXFileReference] the file reference of the added file. # @return [PBXFileReference] the file reference of the added file.
# #
def add_file_to_support_group(path) def add_file_to_support_group(path)
pod_name = library.pod_name pod_name = target.pod_name
dir = library.support_files_dir dir = target.support_files_dir
group = project.pod_support_files_group(pod_name, dir) group = project.pod_support_files_group(pod_name, dir)
group.new_file(path) group.new_file(path)
end end
......
...@@ -52,7 +52,7 @@ module Pod ...@@ -52,7 +52,7 @@ module Pod
# @return [PBXNativeTarget] the target generated in the Pods project for # @return [PBXNativeTarget] the target generated in the Pods project for
# this library. # this library.
# #
attr_accessor :target attr_accessor :native_target
# @return [Platform] the platform for this library. # @return [Platform] the platform for this library.
# #
......
...@@ -57,8 +57,8 @@ module Pod ...@@ -57,8 +57,8 @@ module Pod
# depends. # depends.
# #
def dependencies def dependencies
specs.map do |spec| spec_consumers.map do |consumer|
spec.consumer(platform).dependencies.map { |dep| Specification.root_name(dep.name) } consumer.dependencies.map { |dep| Specification.root_name(dep.name) }
end.flatten end.flatten
end end
......
require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Header = Generator::Header do
before do
@gen = Header.new(Pod::Platform.ios)
end
it 'includes the imports' do
@gen.imports << 'header.h'
@gen.generate.should == <<-EOS.strip_heredoc
#import <UIKit/UIKit.h>
#import "header.h"
EOS
end
it 'imports UIKit in iOS platforms' do
@gen.stubs(:platform).returns(Pod::Platform.ios)
@gen.generate.should.include?('#import <UIKit/UIKit.h>')
end
it 'imports Cocoa for OS X platforms' do
@gen.stubs(:platform).returns(Pod::Platform.osx)
@gen.generate.should.include?('#import <Cocoa/Cocoa.h>')
end
it 'writes the header file to the disk' do
path = temporary_directory + 'Test.h'
@gen.save_as(path)
path.read.should == <<-EOS.strip_heredoc
#import <UIKit/UIKit.h>
EOS
end
end
end
...@@ -80,16 +80,6 @@ module Pod ...@@ -80,16 +80,6 @@ module Pod
EOS EOS
end end
it 'imports UIKit in iOS platforms' do
@gen.stubs(:platform).returns(Pod::Platform.ios)
@gen.generate.should.include?('#import <UIKit/UIKit.h>')
end
it 'imports Cocoa for OS X platforms' do
@gen.stubs(:platform).returns(Pod::Platform.osx)
@gen.generate.should.include?('#import <Cocoa/Cocoa.h>')
end
it 'writes the prefix header file to the disk' do it 'writes the prefix header file to the disk' do
path = temporary_directory + 'Test.pch' path = temporary_directory + 'Test.pch'
@gen.save_as(path) @gen.save_as(path)
......
...@@ -64,7 +64,7 @@ module Pod ...@@ -64,7 +64,7 @@ module Pod
it 'returns the native target' do it 'returns the native target' do
target = stub target = stub
@lib.target = target @lib.native_target = target
@rep.target.should == target @rep.target.should == target
end end
......
...@@ -109,7 +109,7 @@ module Pod ...@@ -109,7 +109,7 @@ module Pod
it 'does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default' do it 'does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default' do
@installer.install! @installer.install!
@installer.library.target.build_configurations.each do |config| @installer.target.native_target.build_configurations.each do |config|
config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'].should.be.nil config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'].should.be.nil
end end
end end
...@@ -166,7 +166,7 @@ module Pod ...@@ -166,7 +166,7 @@ module Pod
it 'creates a dummy source to ensure the creation of a single base library' do it 'creates a dummy source to ensure the creation of a single base library' do
@installer.install! @installer.install!
build_files = @installer.library.target.source_build_phase.files build_files = @installer.target.native_target.source_build_phase.files
build_file = build_files.find { |bf| bf.file_ref.path.include?('Pods-dummy.m') } build_file = build_files.find { |bf| bf.file_ref.path.include?('Pods-dummy.m') }
build_file.should.be.not.nil build_file.should.be.not.nil
build_file.file_ref.path.should == 'Pods-dummy.m' build_file.file_ref.path.should == 'Pods-dummy.m'
......
...@@ -88,7 +88,7 @@ module Pod ...@@ -88,7 +88,7 @@ module Pod
it 'does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default' do it 'does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default' do
@installer.install! @installer.install!
@installer.library.target.build_configurations.each do |config| @installer.target.native_target.build_configurations.each do |config|
config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'].should.be.nil config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'].should.be.nil
end end
end end
...@@ -97,7 +97,7 @@ module Pod ...@@ -97,7 +97,7 @@ module Pod
it 'adds the source files of each pod to the target of the Pod library' do it 'adds the source files of each pod to the target of the Pod library' do
@installer.install! @installer.install!
names = @installer.library.target.source_build_phase.files.map { |bf| bf.file_ref.display_name } names = @installer.target.native_target.source_build_phase.files.map { |bf| bf.file_ref.display_name }
names.should.include('Banana.m') names.should.include('Banana.m')
end end
...@@ -142,7 +142,7 @@ module Pod ...@@ -142,7 +142,7 @@ module Pod
it 'creates a dummy source to ensure the compilation of libraries with only categories' do it 'creates a dummy source to ensure the compilation of libraries with only categories' do
@installer.install! @installer.install!
build_files = @installer.library.target.source_build_phase.files build_files = @installer.target.native_target.source_build_phase.files
build_file = build_files.find { |bf| bf.file_ref.display_name == 'Pods-BananaLib-dummy.m' } build_file = build_files.find { |bf| bf.file_ref.display_name == 'Pods-BananaLib-dummy.m' }
build_file.should.be.not.nil build_file.should.be.not.nil
build_file.file_ref.path.should == 'Pods-BananaLib-dummy.m' build_file.file_ref.path.should == 'Pods-BananaLib-dummy.m'
...@@ -158,10 +158,10 @@ module Pod ...@@ -158,10 +158,10 @@ module Pod
end end
it 'flags should not be added to dtrace files' do it 'flags should not be added to dtrace files' do
@installer.library.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true) @installer.target.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true)
@installer.install! @installer.install!
dtrace_files = @installer.library.target.source_build_phase.files.reject do|sf| dtrace_files = @installer.target.native_target.source_build_phase.files.reject do |sf|
!(File.extname(sf.file_ref.path) == '.d') !(File.extname(sf.file_ref.path) == '.d')
end end
dtrace_files.each do |dt| dtrace_files.each do |dt|
...@@ -170,7 +170,7 @@ module Pod ...@@ -170,7 +170,7 @@ module Pod
end end
it 'adds -w per pod if target definition inhibits warnings for that pod' do it 'adds -w per pod if target definition inhibits warnings for that pod' do
@installer.library.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true) @installer.target.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true)
flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:ios)) flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:ios))
flags.should.include?('-w') flags.should.include?('-w')
...@@ -182,7 +182,7 @@ module Pod ...@@ -182,7 +182,7 @@ module Pod
end end
it 'adds -Xanalyzer -analyzer-disable-checker per pod' do it 'adds -Xanalyzer -analyzer-disable-checker per pod' do
@installer.library.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true) @installer.target.target_definition.stubs(:inhibits_warnings_for_pod?).returns(true)
flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:ios)) flags = @installer.send(:compiler_flags_for_consumer, @spec.consumer(:ios))
flags.should.include?('-Xanalyzer -analyzer-disable-checker') flags.should.include?('-Xanalyzer -analyzer-disable-checker')
......
...@@ -32,7 +32,7 @@ module Pod ...@@ -32,7 +32,7 @@ module Pod
it 'adds the architectures to the custom build configurations of the user target' do it 'adds the architectures to the custom build configurations of the user target' do
@pod_target.archs = '$(ARCHS_STANDARD_64_BIT)' @pod_target.archs = '$(ARCHS_STANDARD_64_BIT)'
@installer.send(:add_target) @installer.send(:add_target)
@installer.send(:target).resolved_build_setting('ARCHS').should == { @installer.send(:native_target).resolved_build_setting('ARCHS').should == {
'Release' => '$(ARCHS_STANDARD_64_BIT)', 'Release' => '$(ARCHS_STANDARD_64_BIT)',
'Debug' => '$(ARCHS_STANDARD_64_BIT)', 'Debug' => '$(ARCHS_STANDARD_64_BIT)',
'AppStore' => '$(ARCHS_STANDARD_64_BIT)', 'AppStore' => '$(ARCHS_STANDARD_64_BIT)',
...@@ -42,8 +42,8 @@ module Pod ...@@ -42,8 +42,8 @@ module Pod
it 'always clears the OTHER_LDFLAGS and OTHER_LIBTOOLFLAGS, because these lib targets do not ever need any' do it 'always clears the OTHER_LDFLAGS and OTHER_LIBTOOLFLAGS, because these lib targets do not ever need any' do
@installer.send(:add_target) @installer.send(:add_target)
@installer.send(:target).resolved_build_setting('OTHER_LDFLAGS').values.uniq.should == [''] @installer.send(:native_target).resolved_build_setting('OTHER_LDFLAGS').values.uniq.should == ['']
@installer.send(:target).resolved_build_setting('OTHER_LIBTOOLFLAGS').values.uniq.should == [''] @installer.send(:native_target).resolved_build_setting('OTHER_LIBTOOLFLAGS').values.uniq.should == ['']
end end
end end
......
...@@ -18,12 +18,12 @@ module Pod ...@@ -18,12 +18,12 @@ module Pod
end end
config.sandbox.project = Project.new(config.sandbox.project_path) config.sandbox.project = Project.new(config.sandbox.project_path)
Xcodeproj::Project.new(config.sandbox.project_path).save Xcodeproj::Project.new(config.sandbox.project_path).save
@library = AggregateTarget.new(@podfile.target_definitions['Pods'], config.sandbox) @target = AggregateTarget.new(@podfile.target_definitions['Pods'], config.sandbox)
@library.client_root = sample_project_path.dirname @target.client_root = sample_project_path.dirname
@library.user_project_path = sample_project_path @target.user_project_path = sample_project_path
@library.user_target_uuids = ['A346496C14F9BE9A0080D870'] @target.user_target_uuids = ['A346496C14F9BE9A0080D870']
empty_library = AggregateTarget.new(@podfile.target_definitions[:empty], config.sandbox) empty_library = AggregateTarget.new(@podfile.target_definitions[:empty], config.sandbox)
@integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@library, empty_library]) @integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@target, empty_library])
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
...@@ -59,10 +59,10 @@ module Pod ...@@ -59,10 +59,10 @@ module Pod
UI.warnings = '' UI.warnings = ''
target_config = stub(:name => 'Release', :build_settings => { 'GCC_PREPROCESSOR_DEFINITIONS' => ['FLAG=1'] }) target_config = stub(:name => 'Release', :build_settings => { 'GCC_PREPROCESSOR_DEFINITIONS' => ['FLAG=1'] })
user_target = stub(:name => 'SampleProject', :build_configurations => [target_config]) user_target = stub(:name => 'SampleProject', :build_configurations => [target_config])
@library.stubs(:user_targets).returns([user_target]) @target.stubs(:user_targets).returns([user_target])
@library.xcconfigs['Release'] = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1' } @target.xcconfigs['Release'] = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1' }
@integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@library]) @integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@target])
@integrator.unstub(:warn_about_xcconfig_overrides) @integrator.unstub(:warn_about_xcconfig_overrides)
@integrator.send(:warn_about_xcconfig_overrides) @integrator.send(:warn_about_xcconfig_overrides)
...@@ -74,10 +74,10 @@ module Pod ...@@ -74,10 +74,10 @@ module Pod
UI.warnings = '' UI.warnings = ''
target_config = stub(:name => 'Release', :build_settings => { 'GCC_PREPROCESSOR_DEFINITIONS' => ['FLAG=1', '${inherited}'] }) target_config = stub(:name => 'Release', :build_settings => { 'GCC_PREPROCESSOR_DEFINITIONS' => ['FLAG=1', '${inherited}'] })
user_target = stub(:name => 'SampleProject', :build_configurations => [target_config]) user_target = stub(:name => 'SampleProject', :build_configurations => [target_config])
@library.stubs(:user_targets).returns([user_target]) @target.stubs(:user_targets).returns([user_target])
@library.xcconfigs['Release'] = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1' } @target.xcconfigs['Release'] = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1' }
@integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@library]) @integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@target])
@integrator.unstub(:warn_about_xcconfig_overrides) @integrator.unstub(:warn_about_xcconfig_overrides)
@integrator.send(:warn_about_xcconfig_overrides) @integrator.send(:warn_about_xcconfig_overrides)
...@@ -88,10 +88,10 @@ module Pod ...@@ -88,10 +88,10 @@ module Pod
UI.warnings = '' UI.warnings = ''
target_config = stub(:name => 'Release', :build_settings => { 'GCC_PREPROCESSOR_DEFINITIONS' => ['FLAG=1', '$(inherited)'] }) target_config = stub(:name => 'Release', :build_settings => { 'GCC_PREPROCESSOR_DEFINITIONS' => ['FLAG=1', '$(inherited)'] })
user_target = stub(:name => 'SampleProject', :build_configurations => [target_config]) user_target = stub(:name => 'SampleProject', :build_configurations => [target_config])
@library.stubs(:user_targets).returns([user_target]) @target.stubs(:user_targets).returns([user_target])
@library.xcconfigs['Release'] = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1' } @target.xcconfigs['Release'] = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1' }
@integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@library]) @integrator = UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@target])
@integrator.unstub(:warn_about_xcconfig_overrides) @integrator.unstub(:warn_about_xcconfig_overrides)
@integrator.send(:warn_about_xcconfig_overrides) @integrator.send(:warn_about_xcconfig_overrides)
......
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