Commit e5388f68 authored by Fabio Pelosin's avatar Fabio Pelosin

[Specification] Add support for framework_bundles

parent b5a8905d
...@@ -7,7 +7,7 @@ gemspec ...@@ -7,7 +7,7 @@ gemspec
group :development do group :development do
# To develop the deps in tandem use the `LOCAL GIT REPOS` feature of Bundler. # To develop the deps in tandem use the `LOCAL GIT REPOS` feature of Bundler.
gem 'cocoapods-core', :git => "https://github.com/CocoaPods/Core.git", :branch => 'master' gem 'cocoapods-core', :git => "https://github.com/CocoaPods/Core.git", :branch => 'feature-frameworks-bundles'
gem 'xcodeproj', :git => "https://github.com/CocoaPods/Xcodeproj.git", :branch => 'master' gem 'xcodeproj', :git => "https://github.com/CocoaPods/Xcodeproj.git", :branch => 'master'
gem 'cocoapods-downloader', :git => "https://github.com/CocoaPods/cocoapods-downloader.git", :branch => 'master' gem 'cocoapods-downloader', :git => "https://github.com/CocoaPods/cocoapods-downloader.git", :branch => 'master'
gem 'claide', :git => 'https://github.com/CocoaPods/CLAide.git', :branch => 'master' gem 'claide', :git => 'https://github.com/CocoaPods/CLAide.git', :branch => 'master'
......
...@@ -7,8 +7,8 @@ GIT ...@@ -7,8 +7,8 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Core.git remote: https://github.com/CocoaPods/Core.git
revision: b56cbd3145fbf97ff9589d70f7bc6f8b88c9a626 revision: fe6962d6fc0d5379d1bf8e5769cefb3683adb529
branch: master branch: feature-frameworks-bundles
specs: specs:
cocoapods-core (0.22.3) cocoapods-core (0.22.3)
activesupport (~> 3.2.13) activesupport (~> 3.2.13)
...@@ -17,7 +17,7 @@ GIT ...@@ -17,7 +17,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Xcodeproj.git remote: https://github.com/CocoaPods/Xcodeproj.git
revision: da60c7e415f150846d3120e9e3b7310d534446ff revision: 465fd0a975fae85cc621ada84f89cc24f01748ef
branch: master branch: master
specs: specs:
xcodeproj (0.8.1) xcodeproj (0.8.1)
......
...@@ -87,6 +87,27 @@ module Pod ...@@ -87,6 +87,27 @@ module Pod
add_developers_frameworks_if_needed(consumer, xcconfig) add_developers_frameworks_if_needed(consumer, xcconfig)
end end
# Configures the given Xcconfig with the the build settings for the given
# framework path.
#
# @param [Pathanme] framework_path
# The path of the framework.
#
# @param [Xcodeproj::Config] xcconfig
# The xcconfig to edit.
#
def add_framework_build_settings(framework_path, xcconfig)
name = File.basename(framework_path, ".framework")
dirname = File.dirname(framework_path).sub(sandbox.root.to_s, '$(PODS_ROOT)')
build_settings = {
'OTHER_LDFLAGS' => "-framework #{name}",
'FRAMEWORK_SEARCH_PATHS' => quote([dirname])
}
xcconfig.merge!(build_settings)
end
# @return [Array<String>] The search paths for the developer frameworks. # @return [Array<String>] The search paths for the developer frameworks.
# #
# @todo Inheritance should be properly handled in Xcconfigs. # @todo Inheritance should be properly handled in Xcconfigs.
......
...@@ -12,6 +12,9 @@ module Pod ...@@ -12,6 +12,9 @@ module Pod
# Each namespaced configuration value is merged into the Pod # Each namespaced configuration value is merged into the Pod
# xcconfig file. # xcconfig file.
# #
# @todo This doesn't include the specs xcconfigs anymore and now the
# logic is duplicated.
#
# @return [Xcodeproj::Config] # @return [Xcodeproj::Config]
# #
def generate def generate
...@@ -23,8 +26,11 @@ module Pod ...@@ -23,8 +26,11 @@ module Pod
}) })
target.pod_targets.each do |pod_target| target.pod_targets.each do |pod_target|
pod_target.spec_consumers.each do |consumer| pod_target.file_accessors.each do |file_accessor|
add_spec_build_settings_to_xcconfig(consumer, @xcconfig) add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, @xcconfig)
file_accessor.framework_bundles.each do |framework_bundle|
add_framework_build_settings(framework_bundle, @xcconfig)
end
end end
end end
......
...@@ -27,8 +27,11 @@ module Pod ...@@ -27,8 +27,11 @@ module Pod
# #
def generate def generate
@xcconfig = Xcodeproj::Config.new @xcconfig = Xcodeproj::Config.new
target.spec_consumers.each do |consumer| target.file_accessors.each do |file_accessor|
add_spec_build_settings_to_xcconfig(consumer, @xcconfig) add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, @xcconfig)
file_accessor.framework_bundles.each do |framework_bundle|
add_framework_build_settings(framework_bundle, @xcconfig)
end
end end
@xcconfig @xcconfig
end end
......
...@@ -285,7 +285,7 @@ module Pod ...@@ -285,7 +285,7 @@ module Pod
# #
def prepare_pods_project def prepare_pods_project
UI.message "- Creating Pods project" do UI.message "- Creating Pods project" do
@pods_project = Pod::Project.new(sandbox.project_path) @pods_project = Pod::Project.new(sandbox)
if config.podfile_path if config.podfile_path
@pods_project.add_podfile(config.podfile_path) @pods_project.add_podfile(config.podfile_path)
end end
......
...@@ -35,7 +35,9 @@ module Pod ...@@ -35,7 +35,9 @@ module Pod
def install! def install!
refresh_file_accessors refresh_file_accessors
add_source_files_references add_source_files_references
add_resources_references add_frameworks_bundles
add_library_files
add_resources_bundles
link_headers link_headers
end end
...@@ -71,16 +73,26 @@ module Pod ...@@ -71,16 +73,26 @@ module Pod
# #
def add_source_files_references def add_source_files_references
UI.message "- Adding source files to Pods project" do UI.message "- Adding source files to Pods project" do
file_accessors.each do |file_accessor| add_file_acessors_paths_to_pods_group(:source_files, :source_files)
files = file_accessor.source_files
spec_name = file_accessor.spec.name
local = sandbox.local?(file_accessor.spec.root.name)
parent_group = local ? pods_project.local_pods : pods_project.pods
pods_project.add_file_references(files, spec_name, parent_group)
end
end end
end end
# Adds the frameworks bundles to the Pods project
#
# @return [void]
#
def add_frameworks_bundles
UI.message "- Adding frameworks to Pods project" do
add_file_acessors_paths_to_pods_group(:framework_bundles, :frameworks)
end
end
# TODO
#
def add_library_files
end
# Adds the resources of the Pods to the Pods project. # Adds the resources of the Pods to the Pods project.
# #
# @note The source files are grouped by Pod and in turn by subspec # @note The source files are grouped by Pod and in turn by subspec
...@@ -88,16 +100,9 @@ module Pod ...@@ -88,16 +100,9 @@ module Pod
# #
# @return [void] # @return [void]
# #
def add_resources_references def add_resources_bundles
UI.message "- Adding resources to Pods project" do UI.message "- Adding resources to Pods project" do
file_accessors.each do |file_accessor| add_file_acessors_paths_to_pods_group(:resources, :resources)
file_accessor.resources.each do |resources|
files = file_accessor.resources
spec_name = file_accessor.spec.name
parent_group = pods_project.resources
pods_project.add_file_references(files, spec_name, parent_group)
end
end
end end
end end
...@@ -138,6 +143,17 @@ module Pod ...@@ -138,6 +143,17 @@ module Pod
@file_accessors ||= libraries.map(&:file_accessors).flatten.compact @file_accessors ||= libraries.map(&:file_accessors).flatten.compact
end end
def add_file_acessors_paths_to_pods_group(paths_method, group_name)
file_accessors.each do |file_accessor|
paths = file_accessor.send(paths_method)
paths.each do |path|
group = pods_project.group_for_spec(file_accessor.spec.name, group_name)
pods_project.add_file_reference(path, group)
# group.new_file(pods_project.relativize(path))
end
end
end
# Computes the destination sub-directory in the sandbox # Computes the destination sub-directory in the sandbox
# #
# @param [Pathname] headers_sandbox # @param [Pathname] headers_sandbox
......
...@@ -229,12 +229,13 @@ module Pod ...@@ -229,12 +229,13 @@ module Pod
# #
def used_files def used_files
files = [ files = [
file_accessors.map(&:source_files), file_accessors.map(&:framework_bundles),
file_accessors.map(&:resources), file_accessors.map(&:license),
file_accessors.map(&:preserve_paths),
file_accessors.map(&:prefix_header), file_accessors.map(&:prefix_header),
file_accessors.map(&:preserve_paths),
file_accessors.map(&:readme), file_accessors.map(&:readme),
file_accessors.map(&:license), file_accessors.map(&:resources),
file_accessors.map(&:source_files),
] ]
files.flatten.compact.map{ |path| path.to_s }.uniq files.flatten.compact.map{ |path| path.to_s }.uniq
......
...@@ -21,10 +21,10 @@ module Pod ...@@ -21,10 +21,10 @@ module Pod
end end
end end
#-----------------------------------------------------------------------#
private private
#-----------------------------------------------------------------------#
# Adds the build files of the pods to the target and adds a reference to # Adds the build files of the pods to the target and adds a reference to
# the frameworks of the Pods. # the frameworks of the Pods.
# #
...@@ -58,7 +58,12 @@ module Pod ...@@ -58,7 +58,12 @@ module Pod
public_gen = Generator::PublicPodXCConfig.new(library) public_gen = Generator::PublicPodXCConfig.new(library)
UI.message "- Generating public xcconfig file at #{UI.path(path)}" do UI.message "- Generating public xcconfig file at #{UI.path(path)}" do
public_gen.save_as(path) public_gen.save_as(path)
#
# TODO
add_file_to_support_group(path) add_file_to_support_group(path)
# relative_path = path.relative_path_from(sandbox.root)
# group = project.group_for_spec(library.root_spec.name, :support_files)
# group.new_file(relative_path)
end end
path = library.xcconfig_private_path path = library.xcconfig_private_path
......
...@@ -9,16 +9,20 @@ module Pod ...@@ -9,16 +9,20 @@ module Pod
# #
class Project < Xcodeproj::Project class Project < Xcodeproj::Project
# @return [Pathname] the path of the xcodeproj file which stores the
# project. # @return [Sandbox] the sandbox which returns the information about which
# Pods are local.
# #
attr_reader :path attr_reader :sandbox
# @param [Sandbox] sandbox @see #sandbox # @param [Sandbox] sandbox @see #sandbox
# #
def initialize(path = nil) def initialize(sandbox)
super(nil) # Recreate the project from scratch for now. super(nil) # Recreate the project from scratch for now.
@path = path # TODO
raise unless sandbox.is_a?(Sandbox)
@sandbox = sandbox
@path = sandbox.project_path
@support_files_group = new_group('Targets Support Files') @support_files_group = new_group('Targets Support Files')
@refs_by_absolute_path = {} @refs_by_absolute_path = {}
...@@ -107,25 +111,25 @@ module Pod ...@@ -107,25 +111,25 @@ module Pod
@resources ||= new_group('Resources') @resources ||= new_group('Resources')
end end
# Adds a group as child to the `Pods` group namespacing subspecs.
#
# @param [String] spec_name
# The full name of the specification.
#
# @param [PBXGroup] root_group
# The group where to add the specification. Either `Pods` or `Local
# Pods`.
#
# @return [PBXGroup] the group for the spec with the given name. # @return [PBXGroup] the group for the spec with the given name.
# #
def add_spec_group(spec_name, root_group) def group_for_spec(spec_name, type = nil)
current_group = root_group local = sandbox.local?(spec_name)
group = nil parent_group = local ? local_pods : pods
spec_name.split('/').each do |name| spec_group = add_spec_group(spec_name, parent_group)
group = current_group[name] || current_group.new_group(name) if type
current_group = group case type
when :source_files then sub_group = 'Source Files'
when :resources then sub_group = 'Resources'
when :frameworks then sub_group = 'Frameworks'
when :support_files then sub_group = 'Support Files'
else raise "[BUG]"
end
spec_group.find_subpath(sub_group, true)
else
spec_group
end end
group
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
...@@ -154,7 +158,7 @@ module Pod ...@@ -154,7 +158,7 @@ module Pod
# @return [void] # @return [void]
# #
def add_file_references(absolute_path, spec_name, parent_group) def add_file_references(absolute_path, spec_name, parent_group)
group = add_spec_group(spec_name, parent_group) group = group_for_spec(spec_name, :source_files)
absolute_path.each do |file| absolute_path.each do |file|
existing = file_reference(file) existing = file_reference(file)
unless existing unless existing
...@@ -165,6 +169,13 @@ module Pod ...@@ -165,6 +169,13 @@ module Pod
end end
end end
# TODO: missing customization for file reference
#
def add_file_reference(absolute_path, group)
ref = group.new_file(relativize(absolute_path))
@refs_by_absolute_path[absolute_path] = ref
end
# Returns the file reference for the given absolute file path. # Returns the file reference for the given absolute file path.
# #
# @param [Pathname,String] absolute_path # @param [Pathname,String] absolute_path
...@@ -204,6 +215,28 @@ module Pod ...@@ -204,6 +215,28 @@ module Pod
# #
attr_reader :refs_by_absolute_path attr_reader :refs_by_absolute_path
# Returns a subgroup of the give group for the given spec creating it if
# needed.
#
# @param [String] spec_name
# The full name of the specification.
#
# @param [PBXGroup] root_group
# The group where to add the specification. Either `Pods` or `Local
# Pods`.
#
# @return [PBXGroup] the group for the spec with the given name.
#
def add_spec_group(spec_name, root_group)
current_group = root_group
group = nil
spec_name.split('/').each do |name|
group = current_group[name] || current_group.new_group(name)
current_group = group
end
group
end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
end end
......
...@@ -36,7 +36,7 @@ module Pod ...@@ -36,7 +36,7 @@ module Pod
# @return [Pathname] the directory which contains the files of the Pod. # @return [Pathname] the directory which contains the files of the Pod.
# #
def root def root
path_list.root path_list.root if path_list
end end
# @return [Specification] the specification. # @return [Specification] the specification.
...@@ -54,7 +54,7 @@ module Pod ...@@ -54,7 +54,7 @@ module Pod
# @return [String] A string suitable for debugging. # @return [String] A string suitable for debugging.
# #
def inspect def inspect
"<#{self.class} spec=#{spec.name} platform=#{platform_name} root=#{path_list.root}>" "<#{self.class} spec=#{spec.name} platform=#{platform_name} root=#{root}>"
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
...@@ -102,6 +102,13 @@ module Pod ...@@ -102,6 +102,13 @@ module Pod
paths_for_attribute(:preserve_paths, true) paths_for_attribute(:preserve_paths, true)
end end
# @return [Array<Pathname>] The paths of the framework bundles that come
# shipped with the Pod.
#
def framework_bundles
expanded_paths(spec_consumer.framework_bundles, :include_dirs => true)
end
# @return [Pathname] The of the prefix header file of the specification. # @return [Pathname] The of the prefix header file of the specification.
# #
def prefix_header def prefix_header
...@@ -159,8 +166,6 @@ module Pod ...@@ -159,8 +166,6 @@ module Pod
# #
# @return [String] the glob pattern. # @return [String] the glob pattern.
# #
# @todo Move to the cocoapods-core so it appears in the docs?
#
def glob_for_attribute(attrbute) def glob_for_attribute(attrbute)
globs = { globs = {
:source_files => '*.{h,hpp,hh,m,mm,c,cpp}'.freeze, :source_files => '*.{h,hpp,hh,m,mm,c,cpp}'.freeze,
...@@ -185,8 +190,6 @@ module Pod ...@@ -185,8 +190,6 @@ module Pod
# #
# @return [Array<Pathname>] A list of the paths. # @return [Array<Pathname>] A list of the paths.
# #
# @todo Implement case insensitive search
#
def expanded_paths(patterns, options = {}) def expanded_paths(patterns, options = {})
return [] if patterns.empty? return [] if patterns.empty?
result = [] result = []
......
...@@ -8,21 +8,19 @@ module Pod ...@@ -8,21 +8,19 @@ module Pod
@pod_target = PodTarget.new([@spec], @target_definition, config.sandbox) @pod_target = PodTarget.new([@spec], @target_definition, config.sandbox)
@pod_target.stubs(:platform).returns(:ios) @pod_target.stubs(:platform).returns(:ios)
@generator = Generator::PublicPodXCConfig.new(@pod_target) @generator = Generator::PublicPodXCConfig.new(@pod_target)
end
it "returns the sandbox" do
@generator.sandbox.class.should == Sandbox
end
#-----------------------------------------------------------------------#
before do
@podfile = Podfile.new @podfile = Podfile.new
@pod_target.target_definition.stubs(:podfile).returns(@podfile)
@spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' } @spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' }
@spec.frameworks = ['QuartzCore'] @spec.frameworks = ['QuartzCore']
@spec.weak_frameworks = ['iAd'] @spec.weak_frameworks = ['iAd']
@spec.libraries = ['xml2'] @spec.libraries = ['xml2']
file_accessors = [Sandbox::FileAccessor.new(nil, @spec.consumer(:ios))]
framework_bundle_paths = [config.sandbox.root + 'BananaLib/BananaLib.framework']
Sandbox::FileAccessor.any_instance.stubs(:framework_bundles).returns(framework_bundle_paths)
@pod_target.target_definition.stubs(:podfile).returns(@podfile)
@pod_target.stubs(:file_accessors).returns(file_accessors)
@xcconfig = @generator.generate @xcconfig = @generator.generate
end end
...@@ -50,7 +48,7 @@ module Pod ...@@ -50,7 +48,7 @@ module Pod
@spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' } @spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' }
@spec.frameworks = ['SenTestingKit'] @spec.frameworks = ['SenTestingKit']
xcconfig = @generator.generate xcconfig = @generator.generate
xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should == '$(inherited) "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"' xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should == '$(inherited) "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks" "$(PODS_ROOT)/BananaLib"'
end end
it "doesn't include the developer frameworks if already present" do it "doesn't include the developer frameworks if already present" do
...@@ -58,10 +56,18 @@ module Pod ...@@ -58,10 +56,18 @@ module Pod
pod_target = PodTarget.new([@spec, spec], @target_definition, config.sandbox) pod_target = PodTarget.new([@spec, spec], @target_definition, config.sandbox)
pod_target.stubs(:platform).returns(:ios) pod_target.stubs(:platform).returns(:ios)
generator = Generator::PublicPodXCConfig.new(pod_target) generator = Generator::PublicPodXCConfig.new(pod_target)
@spec.frameworks = ['SenTestingKit']
spec.frameworks = ['SenTestingKit'] spec.frameworks = ['SenTestingKit']
file_accessors = [Sandbox::FileAccessor.new(nil, spec.consumer(:ios))]
pod_target.stubs(:file_accessors).returns(file_accessors)
xcconfig = generator.generate xcconfig = generator.generate
xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should == '$(inherited) "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"' xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should == '$(inherited) "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks" "$(PODS_ROOT)/BananaLib"'
end
it "includes the build settings of the frameworks bundles of the spec" do
@spec.framework_bundles = ['BananaLib.framework']
xcconfig = @generator.generate
xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should.include?('"$(PODS_ROOT)/BananaLib"')
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
......
...@@ -3,5 +3,38 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -3,5 +3,38 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe Generator::XCConfig do describe Generator::XCConfig do
before do
target = stub(:sandbox => config.sandbox)
@sut = Generator::XCConfig.new(target)
end
describe "#add_framework_build_settings" do
it "adds the build settings of a framework to the given xcconfig" do
framework_path = config.sandbox.root + 'Parse/Parse.framework'
xcconfig = Xcodeproj::Config.new
@sut.send(:add_framework_build_settings, framework_path, xcconfig)
hash_config = xcconfig.to_hash
hash_config['OTHER_LDFLAGS'].should == "-framework Parse"
hash_config['FRAMEWORK_SEARCH_PATHS'].should == '"$(PODS_ROOT)/Parse"'
end
it "doesn't ovverides exiting linker flags" do
framework_path = config.sandbox.root + 'Parse/Parse.framework'
xcconfig = Xcodeproj::Config.new( { 'OTHER_LDFLAGS' => '-framework CoreAnimation' } )
@sut.send(:add_framework_build_settings, framework_path, xcconfig)
hash_config = xcconfig.to_hash
hash_config['OTHER_LDFLAGS'].should == "-framework CoreAnimation -framework Parse"
end
it "doesn't ovverides exiting frameworks search paths" do
framework_path = config.sandbox.root + 'Parse/Parse.framework'
xcconfig = Xcodeproj::Config.new( { 'FRAMEWORK_SEARCH_PATHS' => '"path/to/frameworks"' } )
@sut.send(:add_framework_build_settings, framework_path, xcconfig)
hash_config = xcconfig.to_hash
hash_config['FRAMEWORK_SEARCH_PATHS'].should == '"path/to/frameworks" "$(PODS_ROOT)/Parse"'
end
end
end end
end end
...@@ -7,7 +7,7 @@ module Pod ...@@ -7,7 +7,7 @@ module Pod
@file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec') @file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@pod_target = PodTarget.new([], nil, config.sandbox) @pod_target = PodTarget.new([], nil, config.sandbox)
@pod_target.file_accessors = [@file_accessor] @pod_target.file_accessors = [@file_accessor]
@project = Project.new(config.sandbox.project_path) @project = Project.new(config.sandbox)
@installer = Installer::FileReferencesInstaller.new(config.sandbox, [@pod_target], @project) @installer = Installer::FileReferencesInstaller.new(config.sandbox, [@pod_target], @project)
end end
...@@ -23,9 +23,7 @@ module Pod ...@@ -23,9 +23,7 @@ module Pod
it "adds the files references of the source files the Pods project" do it "adds the files references of the source files the Pods project" do
@installer.install! @installer.install!
group_ref = @installer.pods_project['Pods/BananaLib'] file_ref = @installer.pods_project['Pods/BananaLib/Source Files/Banana.m']
group_ref.should.be.not.nil
file_ref = @installer.pods_project['Pods/BananaLib/Banana.m']
file_ref.should.be.not.nil file_ref.should.be.not.nil
file_ref.path.should == "../../spec/fixtures/banana-lib/Classes/Banana.m" file_ref.path.should == "../../spec/fixtures/banana-lib/Classes/Banana.m"
end end
...@@ -33,17 +31,13 @@ module Pod ...@@ -33,17 +31,13 @@ module Pod
it "adds the files references of the local Pods in a dedicated group" do it "adds the files references of the local Pods in a dedicated group" do
config.sandbox.store_local_path('BananaLib', 'Some Path') config.sandbox.store_local_path('BananaLib', 'Some Path')
@installer.install! @installer.install!
group_ref = @installer.pods_project['Local Pods/BananaLib'] file_ref = @installer.pods_project['Local Pods/BananaLib/Source Files/Banana.m']
group_ref.should.be.not.nil
file_ref = @installer.pods_project['Local Pods/BananaLib/Banana.m']
file_ref.should.be.not.nil file_ref.should.be.not.nil
end end
it "adds the files references of the resources the Pods project" do it "adds the files references of the resources the Pods project" do
@installer.install! @installer.install!
group_ref = @installer.pods_project['Resources/BananaLib'] file_ref = @installer.pods_project['Pods/BananaLib/Resources/logo-sidebar.png']
group_ref.should.be.not.nil
file_ref = @installer.pods_project['Resources/BananaLib/logo-sidebar.png']
file_ref.should.be.not.nil file_ref.should.be.not.nil
file_ref.path.should == "../../spec/fixtures/banana-lib/Resources/logo-sidebar.png" file_ref.path.should == "../../spec/fixtures/banana-lib/Resources/logo-sidebar.png"
end end
......
...@@ -176,6 +176,7 @@ module Pod ...@@ -176,6 +176,7 @@ module Pod
Sandbox::FileAccessor.any_instance.stubs(:prefix_header) Sandbox::FileAccessor.any_instance.stubs(:prefix_header)
Sandbox::FileAccessor.any_instance.stubs(:readme) Sandbox::FileAccessor.any_instance.stubs(:readme)
Sandbox::FileAccessor.any_instance.stubs(:license) Sandbox::FileAccessor.any_instance.stubs(:license)
Sandbox::FileAccessor.any_instance.stubs(:framework_bundles)
paths = @installer.send(:used_files) paths = @installer.send(:used_files)
paths.should == [] paths.should == []
end end
......
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
xcodeproj 'dummy' xcodeproj 'dummy'
end end
@target_definition = @podfile.target_definitions['Pods'] @target_definition = @podfile.target_definitions['Pods']
@project = Project.new(config.sandbox.project_path) @project = Project.new(config.sandbox)
config.sandbox.project = @project config.sandbox.project = @project
path_list = Sandbox::PathList.new(fixture('banana-lib')) path_list = Sandbox::PathList.new(fixture('banana-lib'))
......
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
xcodeproj 'dummy' xcodeproj 'dummy'
end end
@target_definition = @podfile.target_definitions['Pods'] @target_definition = @podfile.target_definitions['Pods']
@project = Project.new(config.sandbox.project_path) @project = Project.new(config.sandbox)
config.sandbox.project = @project config.sandbox.project = @project
path_list = Sandbox::PathList.new(fixture('banana-lib')) path_list = Sandbox::PathList.new(fixture('banana-lib'))
......
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
xcodeproj 'dummy' xcodeproj 'dummy'
end end
@target_definition = @podfile.target_definitions['Pods'] @target_definition = @podfile.target_definitions['Pods']
@project = Project.new(config.sandbox.project_path) @project = Project.new(config.sandbox)
config.sandbox.project = @project config.sandbox.project = @project
path_list = Sandbox::PathList.new(fixture('banana-lib')) path_list = Sandbox::PathList.new(fixture('banana-lib'))
......
...@@ -16,7 +16,7 @@ module Pod ...@@ -16,7 +16,7 @@ module Pod
end end
end end
config.sandbox.project = Project.new() config.sandbox.project = Project.new(config.sandbox)
Xcodeproj::Project.new.save_as(config.sandbox.project_path) Xcodeproj::Project.new.save_as(config.sandbox.project_path)
@library = AggregateTarget.new(@podfile.target_definitions['Pods'], config.sandbox) @library = AggregateTarget.new(@podfile.target_definitions['Pods'], config.sandbox)
@library.client_root = sample_project_path.dirname @library.client_root = sample_project_path.dirname
......
...@@ -4,7 +4,7 @@ module Pod ...@@ -4,7 +4,7 @@ module Pod
describe Project do describe Project do
before do before do
@project = Project.new(config.sandbox.project_path) @project = Project.new(config.sandbox)
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
...@@ -50,22 +50,6 @@ module Pod ...@@ -50,22 +50,6 @@ module Pod
@project.resources.name.should == 'Resources' @project.resources.name.should == 'Resources'
end end
it "adds a group for a specification" do
group = @project.add_spec_group('JSONKit', @project.pods)
@project.pods.children.should.include?(group)
g = @project['Pods/JSONKit']
g.name.should == 'JSONKit'
g.children.should.be.empty?
end
it "namespaces subspecs in groups" do
group = @project.add_spec_group('JSONKit/Subspec', @project.pods)
@project.pods.groups.find { |g| g.name == 'JSONKit' }.children.should.include?(group)
g = @project['Pods/JSONKit/Subspec']
g.name.should == 'Subspec'
g.children.should.be.empty?
end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
...@@ -75,7 +59,7 @@ module Pod ...@@ -75,7 +59,7 @@ module Pod
it "adds the file references for the given source files" do it "adds the file references for the given source files" do
source_files = [ config.sandbox.root + "A_POD/some_file.m" ] source_files = [ config.sandbox.root + "A_POD/some_file.m" ]
@project.add_file_references(source_files, 'BananaLib', @project.pods) @project.add_file_references(source_files, 'BananaLib', @project.pods)
group = @project['Pods/BananaLib'] group = @project['Pods/BananaLib/Source Files']
group.should.not.be.nil group.should.not.be.nil
group.children.map(&:path).should == [ "A_POD/some_file.m" ] group.children.map(&:path).should == [ "A_POD/some_file.m" ]
end end
...@@ -84,7 +68,7 @@ module Pod ...@@ -84,7 +68,7 @@ module Pod
source_files = [ config.sandbox.root + "A_POD/some_file.m" ] source_files = [ config.sandbox.root + "A_POD/some_file.m" ]
@project.add_file_references(source_files, 'BananaLib', @project.pods) @project.add_file_references(source_files, 'BananaLib', @project.pods)
@project.add_file_references(source_files, 'BananaLib', @project.pods) @project.add_file_references(source_files, 'BananaLib', @project.pods)
group = @project['Pods/BananaLib'] group = @project['Pods/BananaLib/Source Files']
group.children.count.should == 1 group.children.count.should == 1
group.children.first.path.should == "A_POD/some_file.m" group.children.first.path.should == "A_POD/some_file.m"
end end
...@@ -108,15 +92,35 @@ module Pod ...@@ -108,15 +92,35 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "File references" do describe "Private helpers" do
describe "#refs_by_absolute_path" do
it "stores the references by absolute path" do
file = config.sandbox.root + "A_POD/some_file.m"
@project.add_file_references([file], 'BananaLib', @project.pods)
refs_by_absolute_path = @project.send(:refs_by_absolute_path)
refs_by_absolute_path.should == {
file => @project.file_reference(file)
}
end
end
it "stores the references by absolute path" do describe "#add_spec_group" do
file = config.sandbox.root + "A_POD/some_file.m" it "adds a group for a specification" do
@project.add_file_references([file], 'BananaLib', @project.pods) group = @project.send(:add_spec_group, 'JSONKit', @project.pods)
refs_by_absolute_path = @project.send(:refs_by_absolute_path) @project.pods.children.should.include?(group)
refs_by_absolute_path.should == { g = @project['Pods/JSONKit']
file => @project.file_reference(file) g.name.should == 'JSONKit'
} g.children.should.be.empty?
end
it "namespaces subspecs in groups" do
group = @project.send(:add_spec_group, 'JSONKit/Subspec', @project.pods)
@project.pods.groups.find { |g| g.name == 'JSONKit' }.children.should.include?(group)
g = @project['Pods/JSONKit/Subspec']
g.name.should == 'Subspec'
g.children.should.be.empty?
end
end end
end end
......
...@@ -103,6 +103,10 @@ module Pod ...@@ -103,6 +103,10 @@ module Pod
@accessor.preserve_paths.should.include?(@root + "Resources") @accessor.preserve_paths.should.include?(@root + "Resources")
end end
it "returns the paths of the framework bundles" do
@accessor.framework_bundles.should.include?(@root + "Bananalib.framework")
end
it "returns the prefix header of the specification" do it "returns the prefix header of the specification" do
@accessor.prefix_header.should == @root + 'Classes/BananaLib.pch' @accessor.prefix_header.should == @root + 'Classes/BananaLib.pch'
end end
......
...@@ -35,7 +35,7 @@ module Pod ...@@ -35,7 +35,7 @@ module Pod
dirs.reject! do |f| dirs.reject! do |f|
f.include?('libPusher') || f.include?('.git') f.include?('libPusher') || f.include?('.git')
end end
dirs.sort.should == %w| Classes Resources Resources/sub_dir sub-dir sub-dir/sub-dir-2 | dirs.sort.should == %w| Bananalib.framework Classes Resources Resources/sub_dir sub-dir sub-dir/sub-dir-2 |
end end
it "handles directories with glob metacharacters" do it "handles directories with glob metacharacters" 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