Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
2fecb2d9
Commit
2fecb2d9
authored
Feb 15, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move code around.
parent
3d1b65a4
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
420 additions
and
400 deletions
+420
-400
external_sources.rb
lib/cocoapods/external_sources.rb
+1
-1
file_references_installer.rb
lib/cocoapods/installer/file_references_installer.rb
+0
-2
user_project_integrator.rb
lib/cocoapods/installer/user_project_integrator.rb
+6
-181
target_integrator.rb
...ds/installer/user_project_integrator/target_integrator.rb
+186
-0
sandbox.rb
lib/cocoapods/sandbox.rb
+4
-90
headers_store.rb
lib/cocoapods/sandbox/headers_store.rb
+96
-0
integration_2.rb
spec/integration_2.rb
+2
-2
target_integrator_spec.rb
...staller/user_project_integrator/target_integrator_spec.rb
+71
-0
user_project_integrator_spec.rb
spec/unit/installer/user_project_integrator_spec.rb
+0
-68
headers_store_spec.rb
spec/unit/sandbox/headers_store_spec.rb
+50
-0
sandbox_spec.rb
spec/unit/sandbox_spec.rb
+4
-56
No files found.
lib/cocoapods/external_sources.rb
View file @
2fecb2d9
...
...
@@ -348,7 +348,7 @@ module Pod
#
def
pod_spec_path
path
=
Pathname
.
new
(
@params
[
:local
]).
expand_path
path
+=
"
#{
name
}
.podspec"
# unless path.to_s.include?("#{name}.podspec"
)
path
+=
"
#{
name
}
.podspec"
unless
path
.
to_s
.
match
(
/
#{
name
}
\.podspec$/
)
unless
path
.
exist?
raise
Informative
,
"No podspec found for `
#{
name
}
` in `
#{
@params
[
:local
]
}
`"
end
...
...
lib/cocoapods/installer/file_references_installer.rb
View file @
2fecb2d9
...
...
@@ -93,8 +93,6 @@ module Pod
# Creates the link to the headers of the Pod in the sandbox.
#
# TODO: clean up
#
# @return [void]
#
def
link_headers
...
...
lib/cocoapods/installer/user_project_integrator.rb
View file @
2fecb2d9
...
...
@@ -13,6 +13,8 @@ module Pod
#
class
UserProjectIntegrator
autoload
:TargetIntegrator
,
'cocoapods/installer/user_project_integrator/target_integrator'
# @return [Podfile] the podfile that should be integrated with the user
# projects.
#
...
...
@@ -62,7 +64,7 @@ module Pod
warn_about_empty_podfile
end
#--------------------------------------#
#--------------------------------------
---------------------------------
#
# @!group Integration steps
...
...
@@ -71,8 +73,8 @@ module Pod
# Creates and saved the workspace containing the Pods project and the
# user projects, if needed.
#
# @note If the workspace alrea
yd containt
s the projects it is not saved
# to avoid Xcode from di
plat
ying the revert dialog: `Do you want to
# @note If the workspace alrea
dy contain
s the projects it is not saved
# to avoid Xcode from di
spla
ying the revert dialog: `Do you want to
# keep the Xcode version or revert to the version on disk?`
#
# @return [void]
...
...
@@ -129,7 +131,7 @@ module Pod
end
end
#--------------------------------------#
#--------------------------------------
---------------------------------
#
# @!group Helpers.
...
...
@@ -164,183 +166,6 @@ module Pod
#-----------------------------------------------------------------------#
# This class is responsible for integrating the library generated by a
# {TargetDefinition} with its destination project.
#
class
TargetIntegrator
# @return [Library] the library that should be integrated.
#
attr_reader
:library
# @param [Library] library @see #target_definition
#
def
initialize
(
library
)
@library
=
library
end
# Integrates the user project targets. Only the targets that do **not**
# already have the Pods library in their frameworks build phase are
# processed.
#
# @return [void]
#
def
integrate!
return
if
targets
.
empty?
UI
.
section
(
integration_message
)
do
add_xcconfig_base_configuration
add_pods_library
add_copy_resources_script_phase
save_user_project
end
end
# @return [Array<PBXNativeTarget>] the list of targets that the Pods
# lib that need to be integrated.
#
# @note A target is considered integrated if it already references
#
def
targets
unless
@targets
target_uuids
=
library
.
user_target_uuids
targets
=
target_uuids
.
map
{
|
uuid
|
user_project
.
targets
.
find
{
|
target
|
target
.
uuid
==
uuid
}
}
non_integrated
=
targets
.
reject
do
|
target
|
target
.
frameworks_build_phase
.
files
.
any?
do
|
build_file
|
file_ref
=
build_file
.
file_ref
!
file_ref
.
proxy?
&&
file_ref
.
display_name
==
library
.
product_name
end
end
@targets
=
non_integrated
end
@targets
end
# Read the project from the disk to ensure that it is up to date as
# other TargetIntegrator might have modified it.
#
def
user_project
@user_project
||=
Xcodeproj
::
Project
.
new
(
library
.
user_project_path
)
end
# @return [String] a string representation suitable for debugging.
#
def
inspect
"#<
#{
self
.
class
}
for target `
#{
target_definition
.
label
}
'>"
end
#--------------------------------------#
# @!group Integration steps
private
# Adds the `xcconfig` configurations files generated for the current
# {TargetDefinition} to the build configurations of the targets that
# should be integrated.
#
# @note It also checks if any build setting of the build
# configurations overrides the `xcconfig` file and warns the
# user.
#
# @todo If the xcconfig is already set don't override it and inform
# the user.
#
# @return [void]
#
def
add_xcconfig_base_configuration
xcconfig
=
user_project
.
new_file
(
library
.
xcconfig_relative_path
)
targets
.
each
do
|
target
|
check_overridden_build_settings
(
library
.
xcconfig
,
target
)
target
.
build_configurations
.
each
do
|
config
|
config
.
base_configuration_reference
=
xcconfig
end
end
end
# Adds a file reference to the library of the {TargetDefinition} and
# adds it to the frameworks build phase of the targets.
#
# @return [void]
#
def
add_pods_library
frameworks
=
user_project
.
frameworks_group
pods_library
=
frameworks
.
new_static_library
(
library
.
label
)
targets
.
each
do
|
target
|
target
.
frameworks_build_phase
.
add_file_reference
(
pods_library
)
end
end
# Adds a shell script build phase responsible to copy the resources
# generated by the TargetDefinition to the bundle of the product of the
# targets.
#
# @return [void]
#
def
add_copy_resources_script_phase
targets
.
each
do
|
target
|
phase
=
target
.
new_shell_script_build_phase
(
'Copy Pods Resources'
)
path
=
library
.
copy_resources_script_relative_path
phase
.
shell_script
=
%{"#{path}"\n}
end
end
# Saves the changes to the user project to the disk.
#
# @return [void]
#
def
save_user_project
user_project
.
save_as
(
library
.
user_project_path
)
end
#--------------------------------------#
# @!group Private helpers.
private
# Informs the user about any build setting of the target which might
# override the given xcconfig file.
#
# @return [void]
#
def
check_overridden_build_settings
(
xcconfig
,
target
)
return
unless
xcconfig
configs_by_overridden_key
=
{}
target
.
build_configurations
.
each
do
|
config
|
xcconfig
.
attributes
.
keys
.
each
do
|
key
|
target_value
=
config
.
build_settings
[
key
]
if
target_value
&&
!
target_value
.
include?
(
'$(inherited)'
)
configs_by_overridden_key
[
key
]
||=
[]
configs_by_overridden_key
[
key
]
<<
config
.
name
end
end
configs_by_overridden_key
.
each
do
|
key
,
config_names
|
name
=
"
#{
target
.
name
}
[
#{
config_names
.
join
(
' - '
)
}
]"
actions
=
[
"Use the `$(inherited)` flag, or"
,
"Remove the build settings from the target."
]
UI
.
warn
(
"The target `
#{
name
}
` overrides the `
#{
key
}
` build "
\
"setting defined in `
#{
library
.
xcconfig_relative_path
}
'."
,
actions
)
end
end
end
# @return [String] the message that should be displayed for the target
# integration.
#
def
integration_message
"Integrating `
#{
library
.
product_name
}
` into "
\
"
#{
'target'
.
pluralize
(
targets
.
size
)
}
"
\
"`
#{
targets
.
map
(
&
:name
).
to_sentence
}
` "
\
"of project
#{
UI
.
path
library
.
user_project_path
}
."
end
end
end
end
end
lib/cocoapods/installer/user_project_integrator/target_integrator.rb
0 → 100644
View file @
2fecb2d9
module
Pod
class
Installer
class
UserProjectIntegrator
# This class is responsible for integrating the library generated by a
# {TargetDefinition} with its destination project.
#
class
TargetIntegrator
# @return [Library] the library that should be integrated.
#
attr_reader
:library
# @param [Library] library @see #target_definition
#
def
initialize
(
library
)
@library
=
library
end
# Integrates the user project targets. Only the targets that do **not**
# already have the Pods library in their frameworks build phase are
# processed.
#
# @return [void]
#
def
integrate!
return
if
targets
.
empty?
UI
.
section
(
integration_message
)
do
add_xcconfig_base_configuration
add_pods_library
add_copy_resources_script_phase
save_user_project
end
end
# @return [Array<PBXNativeTarget>] the list of targets that the Pods
# lib that need to be integrated.
#
# @note A target is considered integrated if it already references
#
def
targets
unless
@targets
target_uuids
=
library
.
user_target_uuids
targets
=
target_uuids
.
map
{
|
uuid
|
user_project
.
targets
.
find
{
|
target
|
target
.
uuid
==
uuid
}
}
non_integrated
=
targets
.
reject
do
|
target
|
target
.
frameworks_build_phase
.
files
.
any?
do
|
build_file
|
file_ref
=
build_file
.
file_ref
!
file_ref
.
proxy?
&&
file_ref
.
display_name
==
library
.
product_name
end
end
@targets
=
non_integrated
end
@targets
end
# Read the project from the disk to ensure that it is up to date as
# other TargetIntegrators might have modified it.
#
def
user_project
@user_project
||=
Xcodeproj
::
Project
.
new
(
library
.
user_project_path
)
end
# @return [String] a string representation suitable for debugging.
#
def
inspect
"#<
#{
self
.
class
}
for target `
#{
target_definition
.
label
}
'>"
end
#---------------------------------------------------------------------#
# @!group Integration steps
private
# Adds the `xcconfig` configurations files generated for the current
# {TargetDefinition} to the build configurations of the targets that
# should be integrated.
#
# @note It also checks if any build setting of the build
# configurations overrides the `xcconfig` file and warns the
# user.
#
# @todo If the xcconfig is already set don't override it and inform
# the user.
#
# @return [void]
#
def
add_xcconfig_base_configuration
xcconfig
=
user_project
.
new_file
(
library
.
xcconfig_relative_path
)
targets
.
each
do
|
target
|
check_overridden_build_settings
(
library
.
xcconfig
,
target
)
target
.
build_configurations
.
each
do
|
config
|
config
.
base_configuration_reference
=
xcconfig
end
end
end
# Adds a file reference to the library of the {TargetDefinition} and
# adds it to the frameworks build phase of the targets.
#
# @return [void]
#
def
add_pods_library
frameworks
=
user_project
.
frameworks_group
pods_library
=
frameworks
.
new_static_library
(
library
.
label
)
targets
.
each
do
|
target
|
target
.
frameworks_build_phase
.
add_file_reference
(
pods_library
)
end
end
# Adds a shell script build phase responsible to copy the resources
# generated by the TargetDefinition to the bundle of the product of the
# targets.
#
# @return [void]
#
def
add_copy_resources_script_phase
targets
.
each
do
|
target
|
phase
=
target
.
new_shell_script_build_phase
(
'Copy Pods Resources'
)
path
=
library
.
copy_resources_script_relative_path
phase
.
shell_script
=
%{"#{path}"\n}
end
end
# Saves the changes to the user project to the disk.
#
# @return [void]
#
def
save_user_project
user_project
.
save_as
(
library
.
user_project_path
)
end
#---------------------------------------------------------------------#
# @!group Private helpers.
private
# Informs the user about any build setting of the target which might
# override the given xcconfig file.
#
# @return [void]
#
def
check_overridden_build_settings
(
xcconfig
,
target
)
return
unless
xcconfig
configs_by_overridden_key
=
{}
target
.
build_configurations
.
each
do
|
config
|
xcconfig
.
attributes
.
keys
.
each
do
|
key
|
target_value
=
config
.
build_settings
[
key
]
if
target_value
&&
!
target_value
.
include?
(
'$(inherited)'
)
configs_by_overridden_key
[
key
]
||=
[]
configs_by_overridden_key
[
key
]
<<
config
.
name
end
end
configs_by_overridden_key
.
each
do
|
key
,
config_names
|
name
=
"
#{
target
.
name
}
[
#{
config_names
.
join
(
' - '
)
}
]"
actions
=
[
"Use the `$(inherited)` flag, or"
,
"Remove the build settings from the target."
]
UI
.
warn
(
"The target `
#{
name
}
` overrides the `
#{
key
}
` build "
\
"setting defined in `
#{
library
.
xcconfig_relative_path
}
'."
,
actions
)
end
end
end
# @return [String] the message that should be displayed for the target
# integration.
#
def
integration_message
"Integrating `
#{
library
.
product_name
}
` into "
\
"
#{
'target'
.
pluralize
(
targets
.
size
)
}
"
\
"`
#{
targets
.
map
(
&
:name
).
to_sentence
}
` "
\
"of project
#{
UI
.
path
library
.
user_project_path
}
."
end
#---------------------------------------------------------------------#
end
end
end
end
lib/cocoapods/sandbox.rb
View file @
2fecb2d9
...
...
@@ -29,7 +29,7 @@ module Pod
# | +-- Acknowledgements.plist
# | +-- Pods.xcconfig
# | +-- Pods-prefix.pch
# | +-- Pods
D
ummy_Pods.m
# | +-- Pods
-d
ummy_Pods.m
# |
# +-- Manifest.lock
# |
...
...
@@ -37,8 +37,9 @@ module Pod
#
class
Sandbox
autoload
:PathList
,
'cocoapods/sandbox/path_list'
autoload
:FileAccessor
,
'cocoapods/sandbox/file_accessor'
autoload
:HeadersStore
,
'cocoapods/sandbox/headers_store'
autoload
:PathList
,
'cocoapods/sandbox/path_list'
# @return [Pathname] the root of the sandbox.
#
...
...
@@ -117,7 +118,7 @@ module Pod
"#<
#{
self
.
class
}
> with root
#{
root
}
"
end
#--------------------------------------#
#--------------------------------------
-----------------------------------
#
# @!group Paths
...
...
@@ -203,94 +204,7 @@ module Pod
#-------------------------------------------------------------------------#
# Provides support for managing a header directory. It also keeps track of
# the header search paths.
#
class
HeadersStore
# @return [Pathname] the absolute path of this header directory.
#
def
root
@sandbox
.
root
+
@relative_path
end
# @return [Sandbox] the sandbox where this header directory is stored.
#
attr_reader
:sandbox
# @param [Sandbox] @see sandbox
#
# @param [String] relative_path
# the relative path to the sandbox root and hence to the Pods
# project.
#
def
initialize
(
sandbox
,
relative_path
)
@sandbox
=
sandbox
@relative_path
=
relative_path
@search_paths
=
[
relative_path
]
end
# @return [Array<String>] All the search paths of the header directory in
# xcconfig format. The paths are specified relative to the pods
# root with the `${PODS_ROOT}` variable.
#
def
search_paths
@search_paths
.
uniq
.
map
{
|
path
|
"${PODS_ROOT}/
#{
path
}
"
}
end
# Removes the directory as it is regenerated from scratch during each
# installation.
#
# @return [void]
#
def
implode!
root
.
rmtree
if
root
.
exist?
end
#--------------------------------------#
public
# @!group Adding headers
# Adds a header to the directory.
#
# @param [Pathname] namespace_path
# the path where the header file should be stored relative to the
# headers directory.
#
# @param [Pathname] relative_header_path
# the path of the header file relative to the sandbox.
#
# @note This method adds the files are added to the search paths.
#
# @return [Pathname]
#
def
add_files
(
namespace
,
relative_header_paths
)
add_search_path
(
namespace
)
namespaced_path
=
root
+
namespace
namespaced_path
.
mkpath
unless
File
.
exist?
(
namespaced_path
)
relative_header_paths
.
map
do
|
relative_header_path
|
source
=
(
@sandbox
.
root
+
relative_header_path
).
relative_path_from
(
namespaced_path
)
Dir
.
chdir
(
namespaced_path
)
do
FileUtils
.
ln_sf
(
source
,
relative_header_path
.
basename
)
end
namespaced_path
+
relative_header_path
.
basename
end
end
# Adds an header search path to the sandbox.
#
# @param [Pathname] path
# the path tho add.
#
# @return [void]
#
def
add_search_path
(
path
)
@search_paths
<<
Pathname
.
new
(
@relative_path
)
+
path
end
end
#-------------------------------------------------------------------------#
...
...
lib/cocoapods/sandbox/headers_store.rb
0 → 100644
View file @
2fecb2d9
module
Pod
class
Sandbox
# Provides support for managing a header directory. It also keeps track of
# the header search paths.
#
class
HeadersStore
# @return [Pathname] the absolute path of this header directory.
#
def
root
@sandbox
.
root
+
@relative_path
end
# @return [Sandbox] the sandbox where this header directory is stored.
#
attr_reader
:sandbox
# @param [Sandbox] @see sandbox
#
# @param [String] relative_path
# the relative path to the sandbox root and hence to the Pods
# project.
#
def
initialize
(
sandbox
,
relative_path
)
@sandbox
=
sandbox
@relative_path
=
relative_path
@search_paths
=
[
relative_path
]
end
# @return [Array<String>] All the search paths of the header directory in
# xcconfig format. The paths are specified relative to the pods
# root with the `${PODS_ROOT}` variable.
#
def
search_paths
@search_paths
.
uniq
.
map
{
|
path
|
"${PODS_ROOT}/
#{
path
}
"
}
end
# Removes the directory as it is regenerated from scratch during each
# installation.
#
# @return [void]
#
def
implode!
root
.
rmtree
if
root
.
exist?
end
#-----------------------------------------------------------------------#
public
# @!group Adding headers
# Adds a header to the directory.
#
# @param [Pathname] namespace_path
# the path where the header file should be stored relative to the
# headers directory.
#
# @param [Pathname] relative_header_path
# the path of the header file relative to the sandbox.
#
# @note This method adds the files are added to the search paths.
#
# @return [Pathname]
#
def
add_files
(
namespace
,
relative_header_paths
)
add_search_path
(
namespace
)
namespaced_path
=
root
+
namespace
namespaced_path
.
mkpath
unless
File
.
exist?
(
namespaced_path
)
relative_header_paths
.
map
do
|
relative_header_path
|
source
=
(
@sandbox
.
root
+
relative_header_path
).
relative_path_from
(
namespaced_path
)
Dir
.
chdir
(
namespaced_path
)
do
FileUtils
.
ln_sf
(
source
,
relative_header_path
.
basename
)
end
namespaced_path
+
relative_header_path
.
basename
end
end
# Adds an header search path to the sandbox.
#
# @param [Pathname] path
# the path tho add.
#
# @return [void]
#
def
add_search_path
(
path
)
@search_paths
<<
Pathname
.
new
(
@relative_path
)
+
path
end
#-----------------------------------------------------------------------#
end
end
end
spec/integration_2.rb
View file @
2fecb2d9
...
...
@@ -275,7 +275,7 @@ end
# subfolders.
#
def
check
(
arguments
,
folder
)
focused_check
(
arguments
,
folder
)
#
focused_check(arguments, folder)
end
# Shortcut to focus on a test: Comment the implmentation of #check and
...
...
@@ -324,7 +324,7 @@ describe "Integration take 2" do
end
describe
"Installs a Pod with a local source"
do
check
"install --no-update --no-doc"
,
"install_local_source"
focused_
check
"install --no-update --no-doc"
,
"install_local_source"
end
describe
"Installs a Pod with an external source"
do
...
...
spec/unit/installer/user_project_integrator/target_integrator_spec.rb
0 → 100644
View file @
2fecb2d9
require
File
.
expand_path
(
'../../../../spec_helper'
,
__FILE__
)
module
Pod
describe
TargetIntegrator
=
Installer
::
UserProjectIntegrator
::
TargetIntegrator
do
describe
"In general"
do
before
do
sample_project_path
=
SpecHelper
.
create_sample_app_copy_from_fixture
(
'SampleProject'
)
@sample_project
=
Xcodeproj
::
Project
.
new
sample_project_path
@target
=
@sample_project
.
targets
.
first
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
,
nil
)
@lib
=
Library
.
new
(
target_definition
)
@lib
.
user_project_path
=
sample_project_path
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
it
'returns the targets that need to be integrated'
do
@target_integrator
.
targets
.
map
(
&
:name
).
should
==
%w[ SampleProject ]
end
it
'returns the targets that need to be integrated'
do
pods_library
=
@sample_project
.
frameworks_group
.
new_static_library
(
'Pods'
)
@target
.
frameworks_build_phase
.
add_file_reference
(
pods_library
)
Xcodeproj
::
Project
.
any_instance
.
stubs
(
:targets
).
returns
([
@target
])
@target_integrator
.
targets
.
map
(
&
:name
).
should
.
be
.
empty?
end
it
'does not perform the integration if there are no targets to integrate'
do
@target_integrator
.
stubs
(
:targets
).
returns
([])
@target_integrator
.
expects
(
:add_xcconfig_base_configuration
).
never
@target_integrator
.
expects
(
:add_pods_library
).
never
@target_integrator
.
expects
(
:add_copy_resources_script_phase
).
never
@target_integrator
.
expects
(
:save_user_project
).
never
@target_integrator
.
integrate!
end
before
do
@target_integrator
.
integrate!
end
it
'sets the Pods xcconfig as the base config for each build configuration'
do
xcconfig_file
=
@sample_project
.
files
.
find
{
|
f
|
f
.
path
==
@lib
.
xcconfig_relative_path
}
@target
.
build_configurations
.
each
do
|
config
|
config
.
base_configuration_reference
.
should
==
xcconfig_file
end
end
it
'adds references to the Pods static libraries to the Frameworks group'
do
@target_integrator
.
user_project
[
"Frameworks/libPods.a"
].
should
.
not
==
nil
end
it
'adds the libPods static library to the "Link binary with libraries" build phase of each target'
do
target
=
@target_integrator
.
targets
.
first
target
.
frameworks_build_phase
.
files
.
find
{
|
f
|
f
.
file_ref
.
path
==
'libPods.a'
}.
should
.
not
==
nil
end
it
'adds a Copy Pods Resources build phase to each target'
do
target
=
@target_integrator
.
targets
.
first
phase
=
target
.
shell_script_build_phases
.
find
{
|
bp
|
bp
.
name
==
"Copy Pods Resources"
}
phase
.
shell_script
.
strip
.
should
==
"
\"
${SRCROOT}/../Pods/Pods-resources.sh
\"
"
end
end
end
end
spec/unit/installer/user_project_integrator_spec.rb
View file @
2fecb2d9
...
...
@@ -80,72 +80,4 @@ module Pod
end
end
end
#-----------------------------------------------------------------------------#
describe
TargetIntegrator
=
Installer
::
UserProjectIntegrator
::
TargetIntegrator
do
describe
"In general"
do
before
do
sample_project_path
=
SpecHelper
.
create_sample_app_copy_from_fixture
(
'SampleProject'
)
@sample_project
=
Xcodeproj
::
Project
.
new
sample_project_path
@target
=
@sample_project
.
targets
.
first
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
,
nil
)
@lib
=
Library
.
new
(
target_definition
)
@lib
.
user_project_path
=
sample_project_path
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
it
'returns the targets that need to be integrated'
do
@target_integrator
.
targets
.
map
(
&
:name
).
should
==
%w[ SampleProject ]
end
it
'returns the targets that need to be integrated'
do
pods_library
=
@sample_project
.
frameworks_group
.
new_static_library
(
'Pods'
)
@target
.
frameworks_build_phase
.
add_file_reference
(
pods_library
)
Xcodeproj
::
Project
.
any_instance
.
stubs
(
:targets
).
returns
([
@target
])
@target_integrator
.
targets
.
map
(
&
:name
).
should
.
be
.
empty?
end
it
'does not perform the integration if there are no targets to integrate'
do
@target_integrator
.
stubs
(
:targets
).
returns
([])
@target_integrator
.
expects
(
:add_xcconfig_base_configuration
).
never
@target_integrator
.
expects
(
:add_pods_library
).
never
@target_integrator
.
expects
(
:add_copy_resources_script_phase
).
never
@target_integrator
.
expects
(
:save_user_project
).
never
@target_integrator
.
integrate!
end
before
do
@target_integrator
.
integrate!
end
it
'sets the Pods xcconfig as the base config for each build configuration'
do
xcconfig_file
=
@sample_project
.
files
.
find
{
|
f
|
f
.
path
==
@lib
.
xcconfig_relative_path
}
@target
.
build_configurations
.
each
do
|
config
|
config
.
base_configuration_reference
.
should
==
xcconfig_file
end
end
it
'adds references to the Pods static libraries to the Frameworks group'
do
@target_integrator
.
user_project
[
"Frameworks/libPods.a"
].
should
.
not
==
nil
end
it
'adds the libPods static library to the "Link binary with libraries" build phase of each target'
do
target
=
@target_integrator
.
targets
.
first
target
.
frameworks_build_phase
.
files
.
find
{
|
f
|
f
.
file_ref
.
path
==
'libPods.a'
}.
should
.
not
==
nil
end
it
'adds a Copy Pods Resources build phase to each target'
do
target
=
@target_integrator
.
targets
.
first
phase
=
target
.
shell_script_build_phases
.
find
{
|
bp
|
bp
.
name
==
"Copy Pods Resources"
}
phase
.
shell_script
.
strip
.
should
==
"
\"
${SRCROOT}/../Pods/Pods-resources.sh
\"
"
end
end
end
end
spec/unit/sandbox/headers_store_spec.rb
0 → 100644
View file @
2fecb2d9
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Sandbox
::
HeadersStore
do
before
do
@sandbox
=
Pod
::
Sandbox
.
new
(
temporary_directory
+
'Sandbox'
)
@header_dir
=
Sandbox
::
HeadersStore
.
new
(
@sandbox
,
'Headers'
)
end
it
"returns it's headers root"
do
@header_dir
.
root
.
should
==
temporary_directory
+
'Sandbox/Headers'
end
it
"can add namespaced headers to it's header path using symlinks and return the relative path"
do
FileUtils
.
mkdir_p
(
@sandbox
.
root
+
"ExampleLib/"
)
namespace_path
=
Pathname
.
new
(
"ExampleLib"
)
relative_header_paths
=
[
Pathname
.
new
(
"ExampleLib/MyHeader.h"
),
Pathname
.
new
(
"ExampleLib/MyOtherHeader.h"
)
]
relative_header_paths
.
each
do
|
path
|
File
.
open
(
@sandbox
.
root
+
path
,
"w"
)
{
|
file
|
file
.
write
(
'hello'
)
}
end
symlink_paths
=
@header_dir
.
add_files
(
namespace_path
,
relative_header_paths
)
symlink_paths
.
each
do
|
path
|
path
.
should
.
be
.
symlink
File
.
read
(
path
).
should
==
"hello"
end
end
it
'keeps a list of unique header search paths when headers are added'
do
FileUtils
.
mkdir_p
(
@sandbox
.
root
+
"ExampleLib/Dir"
)
namespace_path
=
Pathname
.
new
(
"ExampleLib"
)
relative_header_paths
=
[
Pathname
.
new
(
"ExampleLib/Dir/MyHeader.h"
),
Pathname
.
new
(
"ExampleLib/Dir/MyOtherHeader.h"
)
]
relative_header_paths
.
each
do
|
path
|
File
.
open
(
@sandbox
.
root
+
path
,
"w"
)
{
|
file
|
file
.
write
(
'hello'
)
}
end
@header_dir
.
add_files
(
namespace_path
,
relative_header_paths
)
@header_dir
.
search_paths
.
should
.
include
(
"${PODS_ROOT}/Headers/ExampleLib"
)
end
it
'always adds the Headers root to the header search paths'
do
@header_dir
.
search_paths
.
should
.
include
(
"${PODS_ROOT}/Headers"
)
end
end
end
spec/unit/sandbox_spec.rb
View file @
2fecb2d9
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
module
Pod
describe
Sandbox
do
before
do
@sandbox
=
Pod
::
Sandbox
.
new
(
temporary_directory
+
'Sandbox'
)
end
...
...
@@ -51,12 +49,12 @@ module Pod
@sandbox
.
relativize
(
path
).
should
==
expected
end
it
"converts a list of paths to the relative paths respec to the sandbox"
do
it
"converts a list of paths to the relative paths respec
t
to the sandbox"
do
paths
=
[
temporary_directory
+
'Sandbox/file_1'
,
temporary_directory
+
'Sandbox/file_2'
]
@sandbox
.
relativize_paths
(
paths
).
should
==
[
Pathname
.
new
(
'file_1'
),
Pathname
.
new
(
'file_2'
)]
end
#--------------------------------------#
#--------------------------------------
-----------------------------------
#
it
"returns the path of the manifest"
do
@sandbox
.
manifest_path
.
should
==
temporary_directory
+
'Sandbox/Manifest.lock'
...
...
@@ -84,7 +82,7 @@ module Pod
@sandbox
.
specification_path
(
'BananaLib'
).
should
==
@sandbox
.
root
+
'Local Podspecs/BananaLib.podspec'
end
#--------------------------------------#
#--------------------------------------
-----------------------------------
#
it
"loads the stored specification with the given name"
do
(
@sandbox
.
root
+
'Local Podspecs'
).
mkdir
...
...
@@ -96,58 +94,8 @@ module Pod
@sandbox
.
predownloaded_pods
<<
'JSONKit'
@sandbox
.
predownloaded_pods
.
should
==
[
'JSONKit'
]
end
end
#---------------------------------------------------------------------------#
describe
Sandbox
::
HeadersStore
do
#-------------------------------------------------------------------------#
before
do
@sandbox
=
Pod
::
Sandbox
.
new
(
temporary_directory
+
'Sandbox'
)
@header_dir
=
Sandbox
::
HeadersStore
.
new
(
@sandbox
,
'Headers'
)
end
it
"returns it's headers root"
do
@header_dir
.
root
.
should
==
temporary_directory
+
'Sandbox/Headers'
end
it
"can add namespaced headers to it's header path using symlinks and return the relative path"
do
FileUtils
.
mkdir_p
(
@sandbox
.
root
+
"ExampleLib/"
)
namespace_path
=
Pathname
.
new
(
"ExampleLib"
)
relative_header_paths
=
[
Pathname
.
new
(
"ExampleLib/MyHeader.h"
),
Pathname
.
new
(
"ExampleLib/MyOtherHeader.h"
)
]
relative_header_paths
.
each
do
|
path
|
File
.
open
(
@sandbox
.
root
+
path
,
"w"
)
{
|
file
|
file
.
write
(
'hello'
)
}
end
symlink_paths
=
@header_dir
.
add_files
(
namespace_path
,
relative_header_paths
)
symlink_paths
.
each
do
|
path
|
path
.
should
.
be
.
symlink
File
.
read
(
path
).
should
==
"hello"
end
end
it
'keeps a list of unique header search paths when headers are added'
do
FileUtils
.
mkdir_p
(
@sandbox
.
root
+
"ExampleLib/Dir"
)
namespace_path
=
Pathname
.
new
(
"ExampleLib"
)
relative_header_paths
=
[
Pathname
.
new
(
"ExampleLib/Dir/MyHeader.h"
),
Pathname
.
new
(
"ExampleLib/Dir/MyOtherHeader.h"
)
]
relative_header_paths
.
each
do
|
path
|
File
.
open
(
@sandbox
.
root
+
path
,
"w"
)
{
|
file
|
file
.
write
(
'hello'
)
}
end
@header_dir
.
add_files
(
namespace_path
,
relative_header_paths
)
@header_dir
.
search_paths
.
should
.
include
(
"${PODS_ROOT}/Headers/ExampleLib"
)
end
it
'always adds the Headers root to the header search paths'
do
@header_dir
.
search_paths
.
should
.
include
(
"${PODS_ROOT}/Headers"
)
end
end
#--------------------------------------#
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment