Commit df0112ea authored by Ben Scheirman's avatar Ben Scheirman Committed by Eloy Duran

Move logic for generating PODS_ROOT to a class

parent 28b1e0f9
......@@ -5,3 +5,4 @@
* Validate that there are dependencies in a Podfile.
* Validate that the dependencies in the targets don't conflict. E.g. two different versions of the same pod.
* Move Podfile.lock generator from Installer into its own file.
* Remove better_installer.rb file
......@@ -17,6 +17,7 @@ module Pod
autoload :Podfile, 'cocoapods/podfile'
autoload :Project, 'cocoapods/project'
autoload :Resolver, 'cocoapods/resolver'
autoload :PodPathResolver, 'cocoapods/pod_path_resolver'
autoload :Sandbox, 'cocoapods/sandbox'
autoload :Source, 'cocoapods/source'
autoload :Spec, 'cocoapods/specification'
......
......@@ -10,10 +10,11 @@ module Pod
@podfile, @project, @target_definition = podfile, project, target_definition
end
def xcconfig
@xcconfig ||= Xcodeproj::Config.new({
# In a workspace this is where the static library headers should be found.
'PODS_ROOT' => '$(SRCROOT)/Pods',
'PODS_ROOT' => Pod::PodPathResolver.new(@podfile).pods_root,
'ALWAYS_SEARCH_USER_PATHS' => 'YES', # needed to make EmbedReader build
'OTHER_LDFLAGS' => default_ld_flags,
})
......
module Pod
class PodPathResolver
include Config::Mixin
def initialize(podfile)
@podfile = podfile
end
def relative_path_for_pods
pods_path = config.project_pods_root
xcode_proj_path = @podfile.xcodeproj || ''
source_root = (config.project_root + xcode_proj_path).parent
pods_path.relative_path_from(source_root)
end
def pods_root
"$(SRCROOT)/#{relative_path_for_pods}"
end
end
end
require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::PodPathResolver" do
it "should default to a path underneath source root" do
podfile = Pod::Podfile.new {platform :ios; xcodeproj 'foo.xcodeproj'}
resolver = Pod::PodPathResolver.new(podfile)
resolver.pods_root.should == "$(SRCROOT)/Pods"
end
it "should work with source root one level deeper" do
podfile = Pod::Podfile.new {platform :ios; xcodeproj 'subdir/foo.xcodeproj'}
resolver = Pod::PodPathResolver.new(podfile)
resolver.pods_root.should == "$(SRCROOT)/../Pods"
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