Commit 12b5bedc authored by Fabio Pelosin's avatar Fabio Pelosin

[PodsProjectGenerator] Major improvements

parent 6d3c2c45
...@@ -56,12 +56,9 @@ module Pod ...@@ -56,12 +56,9 @@ module Pod
@native_target.add_build_configuration(bc_name, type) @native_target.add_build_configuration(bc_name, type)
end end
target.target = @native_target target.target = @native_target
end end
# @return [PBXNativeTarget] the target generated by the installation # @return [PBXNativeTarget] the target generated by the installation
# process. # process.
# #
......
...@@ -18,5 +18,5 @@ module Pod ...@@ -18,5 +18,5 @@ module Pod
end end
end end
end end
end end
end end
...@@ -78,6 +78,21 @@ module Pod ...@@ -78,6 +78,21 @@ module Pod
Lockfile.from_file(manifest_path) if manifest_path.exist? Lockfile.from_file(manifest_path) if manifest_path.exist?
end end
# Returns whether the version of CocoaPods used to generate the sandbox is
# is major than the given version.
#
# @param [String]
#
# @return [Bool]
#
def version_at_least?(version)
if manifest
manifest.cocoapods_version >= Version.new(version)
else
false
end
end
# @return [Installer::Analyzer::SpecsState] The state of the sandbox # @return [Installer::Analyzer::SpecsState] The state of the sandbox
# (added, deleted, changed and unchanged pods) as computed by the # (added, deleted, changed and unchanged pods) as computed by the
# analyzer. # analyzer.
......
...@@ -35,6 +35,10 @@ module Pod ...@@ -35,6 +35,10 @@ module Pod
label.upcase.gsub(/[^A-Z]/, '_') + '_' label.upcase.gsub(/[^A-Z]/, '_') + '_'
end end
def skip_installation?
false
end
# @return [String] A string suitable for debugging. # @return [String] A string suitable for debugging.
# #
def inspect def inspect
......
...@@ -15,6 +15,10 @@ module Pod ...@@ -15,6 +15,10 @@ module Pod
@file_accessors = [] @file_accessors = []
end end
def skip_installation?
target_definition.empty?
end
# @return [String] the label for the target. # @return [String] the label for the target.
# #
def label def label
......
...@@ -4,6 +4,10 @@ module Pod ...@@ -4,6 +4,10 @@ module Pod
class Installer class Installer
describe PodsProjectGenerator do describe PodsProjectGenerator do
before do
config.sandbox.stubs(:cocoapods_version).returns(Version.new(Pod::VERSION))
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
describe "In general" do describe "In general" do
...@@ -167,7 +171,30 @@ module Pod ...@@ -167,7 +171,30 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
describe "#sync_target_dependencies" do describe "#add_missing_aggregate_targets_libraries" do
before do
project = Pod::Project.new(config.sandbox.project_path)
@aggregate_native_target = project.new_target(:static_library, 'Pods', :ios)
@pod_native_target = project.new_target(:static_library, 'Pods-BananaLib', :ios)
pod_target = PodTarget.new([], nil, config.sandbox)
pod_target.target = @pod_native_target
aggregate_target = AggregateTarget.new(nil, config.sandbox)
aggregate_target.pod_targets = [pod_target]
aggregate_target.target = @aggregate_native_target
@sut = PodsProjectGenerator.new(config.sandbox, [aggregate_target])
end
it "links the aggregate targets to the pod targets" do
@sut.send(:add_missing_aggregate_targets_libraries)
@aggregate_native_target.frameworks_build_phase.files.map(&:file_ref).should.include?(@pod_native_target.product_reference)
end
end
#-----------------------------------------------------------------------#
describe "#add_missing_target_dependencies" do
before do before do
project = Pod::Project.new(config.sandbox.project_path) project = Pod::Project.new(config.sandbox.project_path)
...@@ -188,14 +215,14 @@ module Pod ...@@ -188,14 +215,14 @@ module Pod
it "sets the pod targets as dependencies of the aggregate target" do it "sets the pod targets as dependencies of the aggregate target" do
@sut.send(:sync_target_dependencies) @sut.send(:add_missing_target_dependencies)
dependencies = @aggregate_target.target.dependencies dependencies = @aggregate_target.target.dependencies
dependencies.map { |d| d.target.name}.should == ["Pods-BananaLib", "Pods-monkey"] dependencies.map { |d| d.target.name}.should == ["Pods-BananaLib", "Pods-monkey"]
end end
it "sets the dependencies of the pod targets" do it "sets the dependencies of the pod targets" do
@pod_target_1.stubs(:dependencies).returns(['monkey']) @pod_target_1.stubs(:dependencies).returns(['monkey'])
@sut.send(:sync_target_dependencies) @sut.send(:add_missing_target_dependencies)
dependencies = @pod_target_1.target.dependencies dependencies = @pod_target_1.target.dependencies
dependencies.map { |d| d.target.name}.should == ["Pods-monkey"] dependencies.map { |d| d.target.name}.should == ["Pods-monkey"]
end end
...@@ -204,29 +231,6 @@ module Pod ...@@ -204,29 +231,6 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
describe "#sync_aggregate_targets_libraries" do
before do
project = Pod::Project.new(config.sandbox.project_path)
@aggregate_native_target = project.new_target(:static_library, 'Pods', :ios)
@pod_native_target = project.new_target(:static_library, 'Pods-BananaLib', :ios)
pod_target = PodTarget.new([], nil, config.sandbox)
pod_target.target = @pod_native_target
aggregate_target = AggregateTarget.new(nil, config.sandbox)
aggregate_target.pod_targets = [pod_target]
aggregate_target.target = @aggregate_native_target
@sut = PodsProjectGenerator.new(config.sandbox, [aggregate_target])
end
it "links the aggregate targets to the pod targets" do
@sut.send(:sync_aggregate_targets_libraries)
@aggregate_native_target.frameworks_build_phase.files.map(&:file_ref).should.include?(@pod_native_target.product_reference)
end
end
#-----------------------------------------------------------------------#
end end
end end
end end
...@@ -19,6 +19,20 @@ module Pod ...@@ -19,6 +19,20 @@ module Pod
@sandbox.manifest.should == nil @sandbox.manifest.should == nil
end end
describe "#version_at_least?" do
it "returns whether the version of CocoaPods used to generate the sandbox is major to the given one" do
manifest = stub(:cocoapods_version => Version.new('1.0'))
@sandbox.stubs(:manifest).returns(manifest)
@sandbox.version_at_least?('1.0.0').should.be.true
end
it "returns false if the manifest is not available" do
@sandbox.version_at_least?('0.0.1').should.be.false
end
end
it "returns the project" do it "returns the project" do
@sandbox.project.should == nil @sandbox.project.should == nil
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