Skip to content
Browse files

[Library] Add #client_root

Closes #918
  • Loading branch information...
1 parent 6215ab0 commit 10218d3d5f84ff3ad0c23c46bae14da37dccbd72 @fabiopelosin fabiopelosin committed Apr 3, 2013
View
13 lib/cocoapods/installer/analyzer.rb
@@ -179,18 +179,19 @@ def generated_libraries
user_project = Xcodeproj::Project.new(project_path)
targets = compute_user_project_targets(target_definition, user_project)
- lib.user_project_path = project_path
- lib.user_target_uuids = targets.map(&:uuid)
+ lib.user_project_path = project_path
+ lib.client_root = project_path.dirname
+ lib.user_target_uuids = targets.map(&:uuid)
lib.user_build_configurations = compute_user_build_configurations(target_definition, targets)
- lib.platform = compute_platform_for_target_definition(target_definition, targets)
+ lib.platform = compute_platform_for_target_definition(target_definition, targets)
else
unless target_definition.platform
raise Informative, "It is necessary to specify the platform in the Podfile if not integrating."
end
- lib.user_project_path = config.installation_root
- lib.user_target_uuids = []
+ lib.client_root = config.installation_root
+ lib.user_target_uuids = []
lib.user_build_configurations = {}
- lib.platform = target_definition.platform
+ lib.platform = target_definition.platform
end
libraries << lib
end
View
11 lib/cocoapods/library.rb
@@ -53,6 +53,13 @@ def inspect
#
attr_accessor :support_files_root
+ # @return [Pathname] the folder where the client is stored used for
+ # computing the relative paths. If integrating it should be the
+ # folder where the user project is stored, otherwise it should
+ # be the installation root.
+ #
+ attr_accessor :client_root
+
# @return [Pathname] the path of the user project that this library will
# integrate as identified by the analyzer.
#
@@ -157,7 +164,7 @@ def dummy_source_path
# variable of the user's project.
#
def relative_pods_root
- "${SRCROOT}/#{support_files_root.relative_path_from(user_project_path.dirname)}"
+ "${SRCROOT}/#{support_files_root.relative_path_from(client_root)}"
end
# @return [String] the path of the xcconfig file relative to the root of
@@ -189,7 +196,7 @@ def copy_resources_script_relative_path
# @return [String] the computed path.
#
def relative_to_srcroot(path)
- path.relative_path_from(user_project_path.dirname).to_s
+ path.relative_path_from(client_root).to_s
end
end
end
View
3 spec/unit/installer/analyzer_spec.rb
@@ -81,6 +81,7 @@ module Pod
lib.support_files_root.should == config.sandbox.root
lib.user_project_path.to_s.should.include 'SampleProject/SampleProject'
+ lib.client_root.to_s.should.include 'SampleProject'
lib.user_target_uuids.should == ["A346496C14F9BE9A0080D870"]
user_proj = Xcodeproj::Project.new(lib.user_project_path)
user_proj.objects_by_uuid[lib.user_target_uuids.first].name.should == 'SampleProject'
@@ -92,7 +93,7 @@ module Pod
config.integrate_targets = false
lib = @analyzer.analyze.libraries.first
- lib.user_project_path.should == config.installation_root
+ lib.client_root.should == config.installation_root
lib.user_target_uuids.should == []
lib.user_build_configurations.should == {}
lib.platform.to_s.should == 'iOS 6.0'
View
3 spec/unit/installer/target_installer_spec.rb
@@ -22,7 +22,8 @@ module Pod
@library = Library.new(@target_definition)
@library.platform = Platform.new(:ios, '6.0')
@library.support_files_root = config.sandbox.root
- @library.user_project_path = config.sandbox.root + '../user_project.xcodeproj'
+ @library.client_root = config.sandbox.root.dirname
+ @library.user_project_path = config.sandbox.root + '../user_project.xcodeproj'
@library.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug }
@library.specs = [@spec]
@library.file_accessors = [file_accessor]
View
4 spec/unit/installer/user_project_integrator/target_integrator_spec.rb
@@ -17,12 +17,12 @@ module Pod
target_definition = Podfile::TargetDefinition.new('Pods', nil)
target_definition.link_with_first_target = true
@lib = Library.new(target_definition)
- @lib.user_project_path = sample_project_path
+ @lib.user_project_path = sample_project_path
+ @lib.client_root = sample_project_path.dirname
pods_project = Project.new()
@lib.target = pods_project.new_target(:static_library, target_definition.label, :ios)
@lib.user_target_uuids = [@target.uuid]
@lib.support_files_root = config.sandbox.root
- @lib.user_project_path = sample_project_path
@target_integrator = TargetIntegrator.new(@lib)
end
View
1 spec/unit/installer/user_project_integrator_spec.rb
@@ -18,6 +18,7 @@ module Pod
end
config.sandbox.project = Project.new()
@library = Library.new(@podfile.target_definitions['Pods'])
+ @library.client_root = sample_project_path.dirname
@library.user_project_path = sample_project_path
@library.user_target_uuids = ['A346496C14F9BE9A0080D870']
@library.support_files_root = config.sandbox.root
View
2 spec/unit/library_spec.rb
@@ -33,7 +33,7 @@ module Pod
@target_definition.link_with_first_target = true
@lib = Library.new(@target_definition)
@lib.support_files_root = config.sandbox.root
- @lib.user_project_path = config.sandbox.root + '../user_project.xcodeproj'
+ @lib.client_root = config.sandbox.root.dirname
end
it "returns the absolute path of the xcconfig file" do

0 comments on commit 10218d3

Please sign in to comment.
Something went wrong with that request. Please try again.