Commit 1d71b582 authored by Eloy Duran's avatar Eloy Duran

Move getting paths relative to a Xcode project's ${SRCROOT} to

Pod::Podfile::TargetDefinition.
parent 57c3e267
platform :ios platform :ios
workspace "RelativePathProject/TheWorkspaceOfTheRelativeProject.xcworkspace"
xcodeproj "RelativePathProject/RelativePathProject.xcodeproj" xcodeproj "RelativePathProject/RelativePathProject.xcodeproj"
dependency "AFNetworking" dependency "AFNetworking"
<?xml version='1.0' encoding='UTF-8'?><Workspace version='1.0'><FileRef location='group:Pods/Pods.xcodeproj'/><FileRef location='group:RelativePathProject/RelativePathProject.xcodeproj'/></Workspace>
\ No newline at end of file
...@@ -10,7 +10,40 @@ ...@@ -10,7 +10,40 @@
<string>46</string> <string>46</string>
<key>objects</key> <key>objects</key>
<dict> <dict>
<key>0D44AD8A79844DBFB547AFE1</key> <key>0655448A743D44CE9C8560F4</key>
<dict>
<key>explicitFileType</key>
<string>archive.ar</string>
<key>includeInIndex</key>
<string>0</string>
<key>isa</key>
<string>PBXFileReference</string>
<key>path</key>
<string>libPods.a</string>
<key>sourceTree</key>
<string>BUILT_PRODUCTS_DIR</string>
</dict>
<key>1BDBB6EEA4904D18883D5049</key>
<dict>
<key>explicitFileType</key>
<string>archive.ar</string>
<key>includeInIndex</key>
<string>0</string>
<key>isa</key>
<string>PBXFileReference</string>
<key>path</key>
<string>libPods.a</string>
<key>sourceTree</key>
<string>BUILT_PRODUCTS_DIR</string>
</dict>
<key>3A4A03DC6930408E8E49B095</key>
<dict>
<key>fileRef</key>
<string>DD3C7BABD6FA4FFB859BA028</string>
<key>isa</key>
<string>PBXBuildFile</string>
</dict>
<key>49592E987DEE4FDBBA2EA98F</key>
<dict> <dict>
<key>buildActionMask</key> <key>buildActionMask</key>
<string>2147483647</string> <string>2147483647</string>
...@@ -29,15 +62,34 @@ ...@@ -29,15 +62,34 @@
<key>shellPath</key> <key>shellPath</key>
<string>/bin/sh</string> <string>/bin/sh</string>
<key>shellScript</key> <key>shellScript</key>
<string>"${SRCROOT}/Pods/Pods-resources.sh" <string>"${SRCROOT}/../Pods/Pods-resources.sh"
</string> </string>
</dict> </dict>
<key>4564ED848C694645800D24BF</key> <key>4B73544C9B594609B70257C2</key>
<dict> <dict>
<key>fileRef</key> <key>explicitFileType</key>
<string>7BE04F9FCDE24A588AF38CCA</string> <string>archive.ar</string>
<key>includeInIndex</key>
<string>0</string>
<key>isa</key> <key>isa</key>
<string>PBXBuildFile</string> <string>PBXFileReference</string>
<key>path</key>
<string>libPods.a</string>
<key>sourceTree</key>
<string>BUILT_PRODUCTS_DIR</string>
</dict>
<key>60435663B02542A193962E58</key>
<dict>
<key>explicitFileType</key>
<string>archive.ar</string>
<key>includeInIndex</key>
<string>0</string>
<key>isa</key>
<string>PBXFileReference</string>
<key>path</key>
<string>libPods.a</string>
<key>sourceTree</key>
<string>BUILT_PRODUCTS_DIR</string>
</dict> </dict>
<key>7BE04F9FCDE24A588AF38CCA</key> <key>7BE04F9FCDE24A588AF38CCA</key>
<dict> <dict>
...@@ -47,8 +99,47 @@ ...@@ -47,8 +99,47 @@
<string>0</string> <string>0</string>
<key>isa</key> <key>isa</key>
<string>PBXFileReference</string> <string>PBXFileReference</string>
<key>path</key>
<string>libPods.a</string>
<key>sourceTree</key>
<string>BUILT_PRODUCTS_DIR</string>
</dict>
<key>8B12F3A90ABA4E47905FE316</key>
<dict>
<key>includeInIndex</key>
<string>1</string>
<key>isa</key>
<string>PBXFileReference</string>
<key>lastKnownFileType</key>
<string>text.xcconfig</string>
<key>name</key> <key>name</key>
<string>Pods.xcconfig</string>
<key>path</key>
<string>../Pods/Pods.xcconfig</string>
<key>sourceTree</key>
<string>SOURCE_ROOT</string>
</dict>
<key>968826D4F729428780EB11C7</key>
<dict>
<key>explicitFileType</key>
<string>archive.ar</string>
<key>includeInIndex</key>
<string>0</string>
<key>isa</key>
<string>PBXFileReference</string>
<key>path</key>
<string>libPods.a</string> <string>libPods.a</string>
<key>sourceTree</key>
<string>BUILT_PRODUCTS_DIR</string>
</dict>
<key>A317BF0E1976499FAF0A148C</key>
<dict>
<key>explicitFileType</key>
<string>archive.ar</string>
<key>includeInIndex</key>
<string>0</string>
<key>isa</key>
<string>PBXFileReference</string>
<key>path</key> <key>path</key>
<string>libPods.a</string> <string>libPods.a</string>
<key>sourceTree</key> <key>sourceTree</key>
...@@ -61,7 +152,7 @@ ...@@ -61,7 +152,7 @@
<string>B50504EF1509774600AFAE65</string> <string>B50504EF1509774600AFAE65</string>
<string>B50504E81509774600AFAE65</string> <string>B50504E81509774600AFAE65</string>
<string>B50504E61509774600AFAE65</string> <string>B50504E61509774600AFAE65</string>
<string>BE05502664FD4BA7A5C610EA</string> <string>8B12F3A90ABA4E47905FE316</string>
</array> </array>
<key>isa</key> <key>isa</key>
<string>PBXGroup</string> <string>PBXGroup</string>
...@@ -144,7 +235,7 @@ ...@@ -144,7 +235,7 @@
<string>B50504EA1509774600AFAE65</string> <string>B50504EA1509774600AFAE65</string>
<string>B50504EC1509774600AFAE65</string> <string>B50504EC1509774600AFAE65</string>
<string>B50504EE1509774600AFAE65</string> <string>B50504EE1509774600AFAE65</string>
<string>4564ED848C694645800D24BF</string> <string>3A4A03DC6930408E8E49B095</string>
</array> </array>
<key>isa</key> <key>isa</key>
<string>PBXFrameworksBuildPhase</string> <string>PBXFrameworksBuildPhase</string>
...@@ -175,7 +266,7 @@ ...@@ -175,7 +266,7 @@
<string>B50504E11509774600AFAE65</string> <string>B50504E11509774600AFAE65</string>
<string>B50504E21509774600AFAE65</string> <string>B50504E21509774600AFAE65</string>
<string>B50504E31509774600AFAE65</string> <string>B50504E31509774600AFAE65</string>
<string>0D44AD8A79844DBFB547AFE1</string> <string>49592E987DEE4FDBBA2EA98F</string>
</array> </array>
<key>buildRules</key> <key>buildRules</key>
<array/> <array/>
...@@ -228,6 +319,16 @@ ...@@ -228,6 +319,16 @@
<string>B50504EB1509774600AFAE65</string> <string>B50504EB1509774600AFAE65</string>
<string>B50504ED1509774600AFAE65</string> <string>B50504ED1509774600AFAE65</string>
<string>7BE04F9FCDE24A588AF38CCA</string> <string>7BE04F9FCDE24A588AF38CCA</string>
<string>BDDCC8E0B6B44EC5A067C887</string>
<string>B883D8352B9842028C5C0F5D</string>
<string>60435663B02542A193962E58</string>
<string>1BDBB6EEA4904D18883D5049</string>
<string>A317BF0E1976499FAF0A148C</string>
<string>4B73544C9B594609B70257C2</string>
<string>0655448A743D44CE9C8560F4</string>
<string>968826D4F729428780EB11C7</string>
<string>E3F6CFE58972416FB95F9145</string>
<string>DD3C7BABD6FA4FFB859BA028</string>
</array> </array>
<key>isa</key> <key>isa</key>
<string>PBXGroup</string> <string>PBXGroup</string>
...@@ -238,6 +339,8 @@ ...@@ -238,6 +339,8 @@
</dict> </dict>
<key>B50504E91509774600AFAE65</key> <key>B50504E91509774600AFAE65</key>
<dict> <dict>
<key>includeInIndex</key>
<string>1</string>
<key>isa</key> <key>isa</key>
<string>PBXFileReference</string> <string>PBXFileReference</string>
<key>lastKnownFileType</key> <key>lastKnownFileType</key>
...@@ -258,6 +361,8 @@ ...@@ -258,6 +361,8 @@
</dict> </dict>
<key>B50504EB1509774600AFAE65</key> <key>B50504EB1509774600AFAE65</key>
<dict> <dict>
<key>includeInIndex</key>
<string>1</string>
<key>isa</key> <key>isa</key>
<string>PBXFileReference</string> <string>PBXFileReference</string>
<key>lastKnownFileType</key> <key>lastKnownFileType</key>
...@@ -278,6 +383,8 @@ ...@@ -278,6 +383,8 @@
</dict> </dict>
<key>B50504ED1509774600AFAE65</key> <key>B50504ED1509774600AFAE65</key>
<dict> <dict>
<key>includeInIndex</key>
<string>1</string>
<key>isa</key> <key>isa</key>
<string>PBXFileReference</string> <string>PBXFileReference</string>
<key>lastKnownFileType</key> <key>lastKnownFileType</key>
...@@ -337,8 +444,6 @@ ...@@ -337,8 +444,6 @@
<string>PBXFileReference</string> <string>PBXFileReference</string>
<key>lastKnownFileType</key> <key>lastKnownFileType</key>
<string>text.plist.xml</string> <string>text.plist.xml</string>
<key>name</key>
<string>RelativePathProject-Info.plist</string>
<key>path</key> <key>path</key>
<string>RelativePathProject-Info.plist</string> <string>RelativePathProject-Info.plist</string>
<key>sourceTree</key> <key>sourceTree</key>
...@@ -383,8 +488,6 @@ ...@@ -383,8 +488,6 @@
<string>PBXFileReference</string> <string>PBXFileReference</string>
<key>lastKnownFileType</key> <key>lastKnownFileType</key>
<string>sourcecode.c.objc</string> <string>sourcecode.c.objc</string>
<key>name</key>
<string>main.m</string>
<key>path</key> <key>path</key>
<string>main.m</string> <string>main.m</string>
<key>sourceTree</key> <key>sourceTree</key>
...@@ -403,8 +506,6 @@ ...@@ -403,8 +506,6 @@
<string>PBXFileReference</string> <string>PBXFileReference</string>
<key>lastKnownFileType</key> <key>lastKnownFileType</key>
<string>sourcecode.c.h</string> <string>sourcecode.c.h</string>
<key>name</key>
<string>RelativePathProject-Prefix.pch</string>
<key>path</key> <key>path</key>
<string>RelativePathProject-Prefix.pch</string> <string>RelativePathProject-Prefix.pch</string>
<key>sourceTree</key> <key>sourceTree</key>
...@@ -416,8 +517,6 @@ ...@@ -416,8 +517,6 @@
<string>PBXFileReference</string> <string>PBXFileReference</string>
<key>lastKnownFileType</key> <key>lastKnownFileType</key>
<string>sourcecode.c.h</string> <string>sourcecode.c.h</string>
<key>name</key>
<string>CCPAppDelegate.h</string>
<key>path</key> <key>path</key>
<string>CCPAppDelegate.h</string> <string>CCPAppDelegate.h</string>
<key>sourceTree</key> <key>sourceTree</key>
...@@ -429,8 +528,6 @@ ...@@ -429,8 +528,6 @@
<string>PBXFileReference</string> <string>PBXFileReference</string>
<key>lastKnownFileType</key> <key>lastKnownFileType</key>
<string>sourcecode.c.objc</string> <string>sourcecode.c.objc</string>
<key>name</key>
<string>CCPAppDelegate.m</string>
<key>path</key> <key>path</key>
<string>CCPAppDelegate.m</string> <string>CCPAppDelegate.m</string>
<key>sourceTree</key> <key>sourceTree</key>
...@@ -449,8 +546,6 @@ ...@@ -449,8 +546,6 @@
<string>PBXFileReference</string> <string>PBXFileReference</string>
<key>lastKnownFileType</key> <key>lastKnownFileType</key>
<string>sourcecode.c.h</string> <string>sourcecode.c.h</string>
<key>name</key>
<string>CCPViewController.h</string>
<key>path</key> <key>path</key>
<string>CCPViewController.h</string> <string>CCPViewController.h</string>
<key>sourceTree</key> <key>sourceTree</key>
...@@ -462,8 +557,6 @@ ...@@ -462,8 +557,6 @@
<string>PBXFileReference</string> <string>PBXFileReference</string>
<key>lastKnownFileType</key> <key>lastKnownFileType</key>
<string>sourcecode.c.objc</string> <string>sourcecode.c.objc</string>
<key>name</key>
<string>CCPViewController.m</string>
<key>path</key> <key>path</key>
<string>CCPViewController.m</string> <string>CCPViewController.m</string>
<key>sourceTree</key> <key>sourceTree</key>
...@@ -634,13 +727,15 @@ ...@@ -634,13 +727,15 @@
</array> </array>
<key>defaultConfigurationIsVisible</key> <key>defaultConfigurationIsVisible</key>
<string>0</string> <string>0</string>
<key>defaultConfigurationName</key>
<string>Release</string>
<key>isa</key> <key>isa</key>
<string>XCConfigurationList</string> <string>XCConfigurationList</string>
</dict> </dict>
<key>B50505071509774600AFAE65</key> <key>B50505071509774600AFAE65</key>
<dict> <dict>
<key>baseConfigurationReference</key> <key>baseConfigurationReference</key>
<string>BE05502664FD4BA7A5C610EA</string> <string>8B12F3A90ABA4E47905FE316</string>
<key>buildSettings</key> <key>buildSettings</key>
<dict> <dict>
<key>DSTROOT</key> <key>DSTROOT</key>
...@@ -668,7 +763,7 @@ ...@@ -668,7 +763,7 @@
<key>B50505081509774600AFAE65</key> <key>B50505081509774600AFAE65</key>
<dict> <dict>
<key>baseConfigurationReference</key> <key>baseConfigurationReference</key>
<string>BE05502664FD4BA7A5C610EA</string> <string>8B12F3A90ABA4E47905FE316</string>
<key>buildSettings</key> <key>buildSettings</key>
<dict> <dict>
<key>DSTROOT</key> <key>DSTROOT</key>
...@@ -693,18 +788,59 @@ ...@@ -693,18 +788,59 @@
<key>name</key> <key>name</key>
<string>Release</string> <string>Release</string>
</dict> </dict>
<key>BE05502664FD4BA7A5C610EA</key> <key>B883D8352B9842028C5C0F5D</key>
<dict> <dict>
<key>explicitFileType</key>
<string>archive.ar</string>
<key>includeInIndex</key>
<string>0</string>
<key>isa</key>
<string>PBXFileReference</string>
<key>path</key>
<string>libPods.a</string>
<key>sourceTree</key>
<string>BUILT_PRODUCTS_DIR</string>
</dict>
<key>BDDCC8E0B6B44EC5A067C887</key>
<dict>
<key>explicitFileType</key>
<string>archive.ar</string>
<key>includeInIndex</key>
<string>0</string>
<key>isa</key>
<string>PBXFileReference</string>
<key>path</key>
<string>libPods.a</string>
<key>sourceTree</key>
<string>BUILT_PRODUCTS_DIR</string>
</dict>
<key>DD3C7BABD6FA4FFB859BA028</key>
<dict>
<key>explicitFileType</key>
<string>archive.ar</string>
<key>includeInIndex</key>
<string>0</string>
<key>isa</key> <key>isa</key>
<string>PBXFileReference</string> <string>PBXFileReference</string>
<key>lastKnownFileType</key>
<string>text.xcconfig</string>
<key>name</key> <key>name</key>
<string>Pods.xcconfig</string> <string>libPods.a</string>
<key>path</key> <key>path</key>
<string>Pods/Pods.xcconfig</string> <string>libPods.a</string>
<key>sourceTree</key> <key>sourceTree</key>
<string>SOURCE_ROOT</string> <string>BUILT_PRODUCTS_DIR</string>
</dict>
<key>E3F6CFE58972416FB95F9145</key>
<dict>
<key>explicitFileType</key>
<string>archive.ar</string>
<key>includeInIndex</key>
<string>0</string>
<key>isa</key>
<string>PBXFileReference</string>
<key>path</key>
<string>libPods.a</string>
<key>sourceTree</key>
<string>BUILT_PRODUCTS_DIR</string>
</dict> </dict>
</dict> </dict>
<key>rootObject</key> <key>rootObject</key>
......
<?xml version='1.0' encoding='UTF-8'?><Workspace version='1.0'><FileRef location='group:RelativePathProject.xcodeproj'/><FileRef location='group:../Pods/Pods.xcodeproj'/><FileRef location='group:Pods/Pods.xcodeproj'/><FileRef location='group:RelativePathProject/RelativePathProject.xcodeproj'/></Workspace>
\ No newline at end of file
...@@ -17,7 +17,6 @@ module Pod ...@@ -17,7 +17,6 @@ module Pod
autoload :Podfile, 'cocoapods/podfile' autoload :Podfile, 'cocoapods/podfile'
autoload :Project, 'cocoapods/project' autoload :Project, 'cocoapods/project'
autoload :Resolver, 'cocoapods/resolver' autoload :Resolver, 'cocoapods/resolver'
autoload :PodPathResolver, 'cocoapods/pod_path_resolver'
autoload :Sandbox, 'cocoapods/sandbox' autoload :Sandbox, 'cocoapods/sandbox'
autoload :Source, 'cocoapods/source' autoload :Source, 'cocoapods/source'
autoload :Spec, 'cocoapods/specification' autoload :Spec, 'cocoapods/specification'
......
...@@ -13,7 +13,7 @@ module Pod ...@@ -13,7 +13,7 @@ module Pod
def xcconfig def xcconfig
@xcconfig ||= Xcodeproj::Config.new({ @xcconfig ||= Xcodeproj::Config.new({
# In a workspace this is where the static library headers should be found. # In a workspace this is where the static library headers should be found.
'PODS_ROOT' => Pod::PodPathResolver.new(@target_definition).pods_root, 'PODS_ROOT' => @target_definition.relative_pods_root,
'ALWAYS_SEARCH_USER_PATHS' => 'YES', # needed to make EmbedReader build 'ALWAYS_SEARCH_USER_PATHS' => 'YES', # needed to make EmbedReader build
'OTHER_LDFLAGS' => default_ld_flags, 'OTHER_LDFLAGS' => default_ld_flags,
}) })
...@@ -78,7 +78,7 @@ module Pod ...@@ -78,7 +78,7 @@ module Pod
config.base_configuration = xcconfig_file config.base_configuration = xcconfig_file
config.build_settings['OTHER_LDFLAGS'] = '' config.build_settings['OTHER_LDFLAGS'] = ''
config.build_settings['GCC_PREFIX_HEADER'] = @target_definition.prefix_header_name config.build_settings['GCC_PREFIX_HEADER'] = @target_definition.prefix_header_name
config.build_settings['PODS_ROOT'] = '$(SRCROOT)' config.build_settings['PODS_ROOT'] = '${SRCROOT}'
end end
end end
......
...@@ -63,6 +63,14 @@ module Pod ...@@ -63,6 +63,14 @@ module Pod
def integrate! def integrate!
return if targets.empty? return if targets.empty?
unless Config.instance.silent?
# TODO let's just use ActiveSupport.
plural = targets.size > 1
puts "-> Integrating `#{@target_definition.lib_name}' into target#{'s' if plural} " \
"`#{targets.map(&:name).join(', ')}' of Xcode project `#{user_project_path.basename}'.".green
end
add_xcconfig_base_configuration add_xcconfig_base_configuration
add_pods_library add_pods_library
add_copy_resources_script_phase add_copy_resources_script_phase
...@@ -106,16 +114,16 @@ module Pod ...@@ -106,16 +114,16 @@ module Pod
# Default to the first, which in a simple project is probably an app target. # Default to the first, which in a simple project is probably an app target.
[user_project.targets.first] [user_project.targets.first]
end.reject do |target| end.reject do |target|
# Reject any target that already has this Pods library in one of its frameworks build phases # Reject any target that already has this Pods library in one of its frameworks build phases
target.frameworks_build_phases.any? do |phase| target.frameworks_build_phases.any? do |phase|
phase.files.any? { |file| file.name == @target_definition.lib_name } phase.files.any? { |file| file.name == @target_definition.lib_name }
end
end end
end end
end
end end
def add_xcconfig_base_configuration def add_xcconfig_base_configuration
xcconfig = user_project.files.new('path' => "Pods/#{@target_definition.xcconfig_name}") # TODO use Sandbox? xcconfig = user_project.files.new('path' => @target_definition.xcconfig_relative_path)
targets.each do |target| targets.each do |target|
target.build_configurations.each do |config| target.build_configurations.each do |config|
config.base_configuration = xcconfig config.base_configuration = xcconfig
...@@ -134,7 +142,7 @@ module Pod ...@@ -134,7 +142,7 @@ module Pod
targets.each do |target| targets.each do |target|
phase = target.shell_script_build_phases.new phase = target.shell_script_build_phases.new
phase.name = 'Copy Pods Resources' phase.name = 'Copy Pods Resources'
phase.shell_script = %{"${SRCROOT}/Pods/#{@target_definition.copy_resources_script_name}"\n} phase.shell_script = %{"#{@target_definition.copy_resources_script_relative_path}"\n}
end end
end end
end end
......
module Pod
class PodPathResolver
include Config::Mixin
def initialize(target_definition)
@target_definition = target_definition
end
def relative_path_for_pods
pods_path = config.project_pods_root
xcode_proj_path = @target_definition.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
...@@ -61,6 +61,16 @@ module Pod ...@@ -61,6 +61,16 @@ module Pod
end end
end end
# Returns a path, which is relative to the project_root, relative to the
# `$(SRCROOT)` of the user's project.
def relative_to_srcroot(path)
(config.project_root + path).relative_path_from(xcodeproj.dirname)
end
def relative_pods_root
"${SRCROOT}/#{relative_to_srcroot "Pods"}"
end
def lib_name def lib_name
"lib#{label}.a" "lib#{label}.a"
end end
...@@ -69,10 +79,18 @@ module Pod ...@@ -69,10 +79,18 @@ module Pod
"#{label}.xcconfig" "#{label}.xcconfig"
end end
def xcconfig_relative_path
relative_to_srcroot("Pods/#{xcconfig_name}").to_s
end
def copy_resources_script_name def copy_resources_script_name
"#{label}-resources.sh" "#{label}-resources.sh"
end end
def copy_resources_script_relative_path
"${SRCROOT}/#{relative_to_srcroot("Pods/#{copy_resources_script_name}")}"
end
def prefix_header_name def prefix_header_name
"#{label}-prefix.pch" "#{label}-prefix.pch"
end end
...@@ -142,7 +160,7 @@ module Pod ...@@ -142,7 +160,7 @@ module Pod
else else
projects = @target_definitions.map { |_, td| td.xcodeproj }.uniq projects = @target_definitions.map { |_, td| td.xcodeproj }.uniq
if projects.size == 1 && (xcodeproj = @target_definitions[:default].xcodeproj) if projects.size == 1 && (xcodeproj = @target_definitions[:default].xcodeproj)
xcodeproj.dirname + "#{xcodeproj.basename('.xcodeproj')}.xcworkspace" config.project_root + "#{xcodeproj.basename('.xcodeproj')}.xcworkspace"
end end
end end
end end
......
...@@ -39,7 +39,7 @@ module Pod ...@@ -39,7 +39,7 @@ module Pod
end end
def header_search_paths def header_search_paths
@header_search_paths.uniq.map { |path| "$(PODS_ROOT)/#{path}" } @header_search_paths.uniq.map { |path| "${PODS_ROOT}/#{path}" }
end end
def prepare_for_install def prepare_for_install
......
...@@ -47,14 +47,10 @@ describe Pod::Installer::UserProjectIntegrator do ...@@ -47,14 +47,10 @@ describe Pod::Installer::UserProjectIntegrator do
workspace.projpaths.find { |path| path =~ /Pods.xcodeproj/ }.should.not.be.nil workspace.projpaths.find { |path| path =~ /Pods.xcodeproj/ }.should.not.be.nil
end end
it 'adds the Pods xcconfig file to the project' do
@sample_project.files.where(:path => "Pods/Pods.xcconfig").should.not.be.nil
end
it 'sets the Pods xcconfig as the base config for each build configuration' do it 'sets the Pods xcconfig as the base config for each build configuration' do
@podfile.target_definitions.each do |_, definition| @podfile.target_definitions.each do |_, definition|
target = @sample_project.targets.where(:name => definition.link_with.first) target = @sample_project.targets.where(:name => definition.link_with.first)
xcconfig_file = @sample_project.files.where(:path => "Pods/#{definition.xcconfig_name}") xcconfig_file = @sample_project.files.where(:path => "${SRCROOT}/Pods/#{definition.xcconfig_name}")
target.build_configurations.each do |config| target.build_configurations.each do |config|
config.base_configuration.should == xcconfig_file config.base_configuration.should == xcconfig_file
end end
...@@ -78,7 +74,7 @@ describe Pod::Installer::UserProjectIntegrator do ...@@ -78,7 +74,7 @@ describe Pod::Installer::UserProjectIntegrator do
@podfile.target_definitions.each do |_, definition| @podfile.target_definitions.each do |_, definition|
target = @sample_project.targets.where(:name => definition.link_with.first) target = @sample_project.targets.where(:name => definition.link_with.first)
phase = target.shell_script_build_phases.where(:name => "Copy Pods Resources") phase = target.shell_script_build_phases.where(:name => "Copy Pods Resources")
phase.shell_script.strip.should == "\"${SRCROOT}/Pods/#{definition.copy_resources_script_name}\"".strip phase.shell_script.strip.should == "\"${SRCROOT}/Pods/#{definition.copy_resources_script_name}\""
end end
end end
......
...@@ -86,6 +86,7 @@ else ...@@ -86,6 +86,7 @@ else
commit = '2adcd0f81740d6b0cd4589af98790eee3bd1ae7b' commit = '2adcd0f81740d6b0cd4589af98790eee3bd1ae7b'
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
self.platform :ios self.platform :ios
xcodeproj 'dummy'
dependency 'SSToolkit', :git => url, :commit => commit dependency 'SSToolkit', :git => url, :commit => commit
end end
...@@ -103,6 +104,7 @@ else ...@@ -103,6 +104,7 @@ else
url = 'https://raw.github.com/gist/1349824/3ec6aa60c19113573fc48eac19d0fafd6a69e033/Reachability.podspec' url = 'https://raw.github.com/gist/1349824/3ec6aa60c19113573fc48eac19d0fafd6a69e033/Reachability.podspec'
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
self.platform :ios self.platform :ios
xcodeproj 'dummy'
# TODO use a local file instead of http? # TODO use a local file instead of http?
dependency 'Reachability', :podspec => url dependency 'Reachability', :podspec => url
end end
...@@ -120,6 +122,7 @@ else ...@@ -120,6 +122,7 @@ else
it "installs a library with a podspec defined inline" do it "installs a library with a podspec defined inline" do
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
self.platform :ios self.platform :ios
xcodeproj 'dummy'
dependency do |s| dependency do |s|
s.name = 'JSONKit' s.name = 'JSONKit'
s.version = '1.2' s.version = '1.2'
...@@ -150,6 +153,7 @@ else ...@@ -150,6 +153,7 @@ else
it "creates targets for different platforms" do it "creates targets for different platforms" do
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
self.platform :ios self.platform :ios
xcodeproj 'dummy'
dependency 'JSONKit', '1.4' dependency 'JSONKit', '1.4'
target :ios_target do target :ios_target do
# This brings in Reachability on iOS # This brings in Reachability on iOS
...@@ -179,6 +183,7 @@ else ...@@ -179,6 +183,7 @@ else
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
self.platform :ios self.platform :ios
xcodeproj 'dummy'
dependency 'JSONKit', '1.4' dependency 'JSONKit', '1.4'
dependency 'SSToolkit' dependency 'SSToolkit'
end end
...@@ -203,6 +208,7 @@ else ...@@ -203,6 +208,7 @@ else
it "runs the optional post_install callback defined in the Podfile _before_ the project is saved to disk" do it "runs the optional post_install callback defined in the Podfile _before_ the project is saved to disk" do
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
self.platform platform self.platform platform
xcodeproj 'dummy'
dependency 'SSZipArchive' dependency 'SSZipArchive'
post_install do |installer| post_install do |installer|
...@@ -224,6 +230,7 @@ else ...@@ -224,6 +230,7 @@ else
it "activates required pods and create a working static library xcode project" do it "activates required pods and create a working static library xcode project" do
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
self.platform platform self.platform platform
xcodeproj 'dummy'
dependency 'Reachability', '> 2.0.5' if platform == :ios dependency 'Reachability', '> 2.0.5' if platform == :ios
dependency 'ASIWebPageRequest', '>= 1.8.1' dependency 'ASIWebPageRequest', '>= 1.8.1'
dependency 'JSONKit', '>= 1.0' dependency 'JSONKit', '>= 1.0'
...@@ -268,6 +275,7 @@ else ...@@ -268,6 +275,7 @@ else
it "does not activate pods that are only part of other pods" do it "does not activate pods that are only part of other pods" do
spec = Pod::Podfile.new do spec = Pod::Podfile.new do
self.platform platform self.platform platform
xcodeproj 'dummy'
dependency 'Reachability', '2.0.4' # only 2.0.4 is part of ASIHTTPRequest’s source. dependency 'Reachability', '2.0.4' # only 2.0.4 is part of ASIHTTPRequest’s source.
end end
...@@ -285,6 +293,7 @@ else ...@@ -285,6 +293,7 @@ else
it "adds resources to the xcode copy script" do it "adds resources to the xcode copy script" do
spec = Pod::Podfile.new do spec = Pod::Podfile.new do
self.platform platform self.platform platform
xcodeproj 'dummy'
dependency 'SSZipArchive' dependency 'SSZipArchive'
end end
...@@ -302,6 +311,7 @@ else ...@@ -302,6 +311,7 @@ else
it "overwrites an existing project.pbxproj file" do it "overwrites an existing project.pbxproj file" do
spec = Pod::Podfile.new do spec = Pod::Podfile.new do
self.platform platform self.platform platform
xcodeproj 'dummy'
dependency 'JSONKit' dependency 'JSONKit'
end end
installer = SpecHelper::Installer.new(spec) installer = SpecHelper::Installer.new(spec)
...@@ -309,6 +319,7 @@ else ...@@ -309,6 +319,7 @@ else
spec = Pod::Podfile.new do spec = Pod::Podfile.new do
self.platform platform self.platform platform
xcodeproj 'dummy'
dependency 'SSZipArchive' dependency 'SSZipArchive'
end end
installer = SpecHelper::Installer.new(spec) installer = SpecHelper::Installer.new(spec)
...@@ -321,6 +332,7 @@ else ...@@ -321,6 +332,7 @@ else
it "creates a project with multiple targets" do it "creates a project with multiple targets" do
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
self.platform platform self.platform platform
xcodeproj 'dummy'
target(:debug) { dependency 'SSZipArchive' } target(:debug) { dependency 'SSZipArchive' }
target(:test, :exclusive => true) { dependency 'JSONKit' } target(:test, :exclusive => true) { dependency 'JSONKit' }
dependency 'ASIHTTPRequest' dependency 'ASIHTTPRequest'
...@@ -388,7 +400,7 @@ else ...@@ -388,7 +400,7 @@ else
target = project.targets.first target = project.targets.first
target.build_configurations.each do |config| target.build_configurations.each do |config|
config.base_configuration.path.should == 'Pods/Pods.xcconfig' config.base_configuration.path.should == '${SRCROOT}/Pods/Pods.xcconfig'
end end
target.frameworks_build_phases.first.files.should.include libPods target.frameworks_build_phases.first.files.should.include libPods
# should be the last phase # should be the last phase
...@@ -398,6 +410,7 @@ else ...@@ -398,6 +410,7 @@ else
it "should prevent duplication cleaning headers symlinks with multiple targets" do it "should prevent duplication cleaning headers symlinks with multiple targets" do
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
self.platform platform self.platform platform
xcodeproj 'dummy'
target(:debug) { dependency 'SSZipArchive' } target(:debug) { dependency 'SSZipArchive' }
target(:test, :exclusive => true) { dependency 'JSONKit' } target(:test, :exclusive => true) { dependency 'JSONKit' }
dependency 'ASIHTTPRequest' dependency 'ASIHTTPRequest'
......
...@@ -5,17 +5,11 @@ TMP_POD_ROOT = ROOT + "tmp" + "podroot" unless defined? TMP_POD_ROOT ...@@ -5,17 +5,11 @@ TMP_POD_ROOT = ROOT + "tmp" + "podroot" unless defined? TMP_POD_ROOT
describe Pod::Installer::TargetInstaller do describe Pod::Installer::TargetInstaller do
before do before do
platform = Pod::Platform.ios @podfile = Pod::Podfile.new do
platform :ios
@target_definition = Pod::Podfile::TargetDefinition.new(:foo) xcodeproj 'dummy'
@target_definition.platform = platform end
@target_definition = @podfile.target_definitions[:default]
@podfile = stub('podfile',
:platform => platform,
:xcodeproj => 'dummy.xcodeproj',
:generate_bridge_support? => false,
:set_arc_compatibility_flag? => false
)
@project = Pod::Project.new @project = Pod::Project.new
@project.main_group.groups.new('name' => 'Targets Support Files') @project.main_group.groups.new('name' => 'Targets Support Files')
...@@ -24,7 +18,7 @@ describe Pod::Installer::TargetInstaller do ...@@ -24,7 +18,7 @@ describe Pod::Installer::TargetInstaller do
@sandbox = Pod::Sandbox.new(TMP_POD_ROOT) @sandbox = Pod::Sandbox.new(TMP_POD_ROOT)
@specification = fixture_spec('banana-lib/BananaLib.podspec') @specification = fixture_spec('banana-lib/BananaLib.podspec')
@pods = [Pod::LocalPod.new(@specification, @sandbox, platform)] @pods = [Pod::LocalPod.new(@specification, @sandbox, Pod::Platform.ios)]
end end
def do_install! def do_install!
......
...@@ -17,6 +17,7 @@ describe "Pod::Installer" do ...@@ -17,6 +17,7 @@ describe "Pod::Installer" do
before do before do
@xcconfig = Pod::Installer.new(Pod::Podfile.new do @xcconfig = Pod::Installer.new(Pod::Podfile.new do
platform :ios platform :ios
xcodeproj 'MyProject'
dependency 'JSONKit' dependency 'JSONKit'
end).target_installers.first.xcconfig.to_hash end).target_installers.first.xcconfig.to_hash
end end
......
require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::PodPathResolver" do
it "should default to a path underneath source root" do
target_definition = Pod::Podfile::TargetDefinition.new(:default)
target_definition.xcodeproj = 'foo.xcodeproj'
resolver = Pod::PodPathResolver.new(target_definition)
resolver.pods_root.should == "$(SRCROOT)/Pods"
end
it "should work with source root one level deeper" do
target_definition = Pod::Podfile::TargetDefinition.new(:default)
target_definition.xcodeproj = 'subdir/foo.xcodeproj'
resolver = Pod::PodPathResolver.new(target_definition)
resolver.pods_root.should == "$(SRCROOT)/../Pods"
end
end
...@@ -217,12 +217,16 @@ describe "Pod::Podfile" do ...@@ -217,12 +217,16 @@ describe "Pod::Podfile" do
it "returns the name of the xcconfig file for the target" do it "returns the name of the xcconfig file for the target" do
@podfile.target_definitions[:default].xcconfig_name.should == 'Pods.xcconfig' @podfile.target_definitions[:default].xcconfig_name.should == 'Pods.xcconfig'
@podfile.target_definitions[:default].xcconfig_relative_path.should == 'Pods/Pods.xcconfig'
@podfile.target_definitions[:test].xcconfig_name.should == 'Pods-test.xcconfig' @podfile.target_definitions[:test].xcconfig_name.should == 'Pods-test.xcconfig'
@podfile.target_definitions[:test].xcconfig_relative_path.should == 'Pods/Pods-test.xcconfig'
end end
it "returns the name of the 'copy resources script' file for the target" do it "returns the name of the 'copy resources script' file for the target" do
@podfile.target_definitions[:default].copy_resources_script_name.should == 'Pods-resources.sh' @podfile.target_definitions[:default].copy_resources_script_name.should == 'Pods-resources.sh'
@podfile.target_definitions[:default].copy_resources_script_relative_path.should == '${SRCROOT}/Pods/Pods-resources.sh'
@podfile.target_definitions[:test].copy_resources_script_name.should == 'Pods-test-resources.sh' @podfile.target_definitions[:test].copy_resources_script_name.should == 'Pods-test-resources.sh'
@podfile.target_definitions[:test].copy_resources_script_relative_path.should == '${SRCROOT}/Pods/Pods-test-resources.sh'
end end
it "returns the name of the 'prefix header' file for the target" do it "returns the name of the 'prefix header' file for the target" do
...@@ -245,6 +249,25 @@ describe "Pod::Podfile" do ...@@ -245,6 +249,25 @@ describe "Pod::Podfile" do
@podfile.target_definitions[:osx_target].should.be.exclusive @podfile.target_definitions[:osx_target].should.be.exclusive
@podfile.target_definitions[:nested_osx_target].should.not.be.exclusive @podfile.target_definitions[:nested_osx_target].should.not.be.exclusive
end end
describe "with an Xcode project that's not in the project_root" do
before do
@target_definition = @podfile.target_definitions[:default]
@target_definition.stubs(:xcodeproj).returns(config.project_root + 'subdir/iOS Project.xcodeproj')
end
it "returns the $(PODS_ROOT) relative to the project's $(SRCROOT)" do
@target_definition.relative_pods_root.should == '${SRCROOT}/../Pods'
end
it "returns the xcconfig file path relative to the project's $(SRCROOT)" do
@target_definition.xcconfig_relative_path.should == '../Pods/Pods.xcconfig'
end
it "returns the 'copy resources script' path relative to the project's $(SRCROOT)" do
@target_definition.copy_resources_script_relative_path.should == '${SRCROOT}/../Pods/Pods-resources.sh'
end
end
end end
describe "concerning validations" do describe "concerning validations" do
......
...@@ -65,11 +65,11 @@ describe Pod::Sandbox do ...@@ -65,11 +65,11 @@ describe Pod::Sandbox do
File.open(@sandbox.root + path, "w") { |file| file.write('hello') } File.open(@sandbox.root + path, "w") { |file| file.write('hello') }
end end
@sandbox.add_header_files(namespace_path, relative_header_paths) @sandbox.add_header_files(namespace_path, relative_header_paths)
@sandbox.header_search_paths.should.include("$(PODS_ROOT)/Headers/ExampleLib") @sandbox.header_search_paths.should.include("${PODS_ROOT}/Headers/ExampleLib")
end end
it 'always adds the Headers root to the header search paths' do it 'always adds the Headers root to the header search paths' do
@sandbox.header_search_paths.should.include("$(PODS_ROOT)/Headers") @sandbox.header_search_paths.should.include("${PODS_ROOT}/Headers")
end end
it 'clears out its headers root when preparing for install' do it 'clears out its headers root when preparing for install' 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