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
5df26a6f
Commit
5df26a6f
authored
Apr 02, 2012
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stash
parent
d51f5a06
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
86 additions
and
53 deletions
+86
-53
install.rb
lib/cocoapods/command/install.rb
+4
-3
config.rb
lib/cocoapods/config.rb
+2
-6
installer.rb
lib/cocoapods/installer.rb
+2
-1
target_installer.rb
lib/cocoapods/installer/target_installer.rb
+1
-2
user_project_integrator.rb
lib/cocoapods/installer/user_project_integrator.rb
+20
-24
pod_path_resolver.rb
lib/cocoapods/pod_path_resolver.rb
+3
-3
podfile.rb
lib/cocoapods/podfile.rb
+19
-3
user_project_integrator_spec.rb
spec/unit/installer/user_project_integrator_spec.rb
+2
-2
pod_path_resolver_spec.rb
spec/unit/pod_path_resolver_spec.rb
+6
-4
podfile_spec.rb
spec/unit/podfile_spec.rb
+27
-5
No files found.
lib/cocoapods/command/install.rb
View file @
5df26a6f
...
@@ -44,14 +44,15 @@ module Pod
...
@@ -44,14 +44,15 @@ module Pod
raise
Informative
,
"No `Podfile' found in the current working directory."
raise
Informative
,
"No `Podfile' found in the current working directory."
end
end
if
podfile
.
xcodeproj
.
nil?
# TODO this should be done for all targets (?)
if
xcodeproj
=
podfile
.
target_definitions
[
:default
].
xcodeproj
raise
Informative
,
"Please specify a valid xcodeproj path in your Podfile.
\n\n
"
+
raise
Informative
,
"Please specify a valid xcodeproj path in your Podfile.
\n\n
"
+
"Usage:
\n\t
"
+
"Usage:
\n\t
"
+
"xcodeproj 'path/to/project.xcodeproj'"
"xcodeproj 'path/to/project.xcodeproj'"
end
end
unless
File
.
exist?
(
podfile
.
xcodeproj
)
if
xcodeproj
&&
!
xcodeproj
.
exist?
raise
Informative
,
"The specified project `
#{
podfile
.
xcodeproj
}
' does not exist."
raise
Informative
,
"The specified project `
#{
xcodeproj
}
' does not exist."
end
end
if
@update_repo
if
@update_repo
...
...
lib/cocoapods/config.rb
View file @
5df26a6f
...
@@ -20,12 +20,8 @@ module Pod
...
@@ -20,12 +20,8 @@ module Pod
def
initialize
def
initialize
@repos_dir
=
Pathname
.
new
(
File
.
expand_path
(
"~/.cocoapods"
))
@repos_dir
=
Pathname
.
new
(
File
.
expand_path
(
"~/.cocoapods"
))
@clean
=
true
@verbose
=
@silent
=
@force_doc
=
false
@verbose
=
false
@clean
=
@doc
=
@doc_install
=
true
@silent
=
false
@doc
=
true
@doc_install
=
true
@force_doc
=
false
end
end
def
project_root
def
project_root
...
...
lib/cocoapods/installer.rb
View file @
5df26a6f
...
@@ -91,7 +91,8 @@ module Pod
...
@@ -91,7 +91,8 @@ module Pod
puts
"* Writing Xcode project file to `
#{
@sandbox
.
project_path
}
'
\n\n
"
if
config
.
verbose?
puts
"* Writing Xcode project file to `
#{
@sandbox
.
project_path
}
'
\n\n
"
if
config
.
verbose?
project
.
save_as
(
@sandbox
.
project_path
)
project
.
save_as
(
@sandbox
.
project_path
)
UserProjectIntegrator
.
new
(
@podfile
).
integrate!
if
@podfile
.
xcodeproj
# The conditional is actually only so we omit the integration when running the specs.
UserProjectIntegrator
.
new
(
@podfile
).
integrate!
if
@podfile
.
xcodeproj
(
false
)
end
end
def
run_post_install_hooks
def
run_post_install_hooks
...
...
lib/cocoapods/installer/target_installer.rb
View file @
5df26a6f
...
@@ -10,11 +10,10 @@ module Pod
...
@@ -10,11 +10,10 @@ module Pod
@podfile
,
@project
,
@target_definition
=
podfile
,
project
,
target_definition
@podfile
,
@project
,
@target_definition
=
podfile
,
project
,
target_definition
end
end
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
(
@
podfile
).
pods_root
,
'PODS_ROOT'
=>
Pod
::
PodPathResolver
.
new
(
@
target_definition
).
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
,
})
})
...
...
lib/cocoapods/installer/user_project_integrator.rb
View file @
5df26a6f
...
@@ -16,9 +16,7 @@ module Pod
...
@@ -16,9 +16,7 @@ module Pod
# Only need to write out the user's project if any of the target
# Only need to write out the user's project if any of the target
# integrators actually did some work.
# integrators actually did some work.
if
targets
.
map
(
&
:integrate!
).
any?
target_integrators
.
map
(
&
:integrate!
)
user_project
.
save_as
(
user_project_path
)
end
unless
config
.
silent?
unless
config
.
silent?
# TODO this really shouldn't be here
# TODO this really shouldn't be here
...
@@ -26,24 +24,18 @@ module Pod
...
@@ -26,24 +24,18 @@ module Pod
end
end
end
end
def
user_project_path
@podfile
.
xcodeproj
end
def
user_project
@user_project
||=
Xcodeproj
::
Project
.
new
(
user_project_path
)
end
def
workspace_path
def
workspace_path
config
.
project_root
+
"
#{
user_project_path
.
basename
(
'.xcodeproj'
)
}
.xcworkspace"
config
.
project_root
+
"
#{
@podfile
.
target_definitions
[
:default
].
xcodeproj
.
basename
(
'.xcodeproj'
)
}
.xcworkspace"
end
end
def
pods_project_path
def
pods_project_path
config
.
project_root
+
"Pods/Pods.xcodeproj"
config
.
project_root
+
"Pods/Pods.xcodeproj"
end
end
def
targets
def
target_integrators
@podfile
.
target_definitions
.
values
.
map
{
|
definition
|
Target
.
new
(
self
,
definition
)
}
@podfile
.
target_definitions
.
values
.
map
do
|
definition
|
TargetIntegrator
.
new
(
definition
)
end
end
end
def
create_workspace!
def
create_workspace!
...
@@ -55,19 +47,23 @@ module Pod
...
@@ -55,19 +47,23 @@ module Pod
workspace
.
save_as
(
workspace_path
)
workspace
.
save_as
(
workspace_path
)
end
end
class
Target
class
Target
Integrator
attr_reader
:
integrator
,
:
target_definition
attr_reader
:target_definition
def
initialize
(
integrator
,
target_definition
)
def
initialize
(
target_definition
)
@
integrator
,
@target_definition
=
integrator
,
target_definition
@
target_definition
=
target_definition
end
end
def
integrate!
def
integrate!
return
false
if
targets
.
empty?
return
if
targets
.
empty?
add_xcconfig_base_configuration
add_xcconfig_base_configuration
add_pods_library
add_pods_library
add_copy_resources_script_phase
add_copy_resources_script_phase
true
user_project
.
save_as
(
@target_definition
.
xcodeproj
)
end
def
user_project
@user_project
||=
Xcodeproj
::
Project
.
new
(
@target_definition
.
xcodeproj
)
end
end
# This returns a list of the targets from the user’s project to which
# This returns a list of the targets from the user’s project to which
...
@@ -82,11 +78,11 @@ module Pod
...
@@ -82,11 +78,11 @@ module Pod
def
targets
def
targets
@targets
||=
begin
@targets
||=
begin
if
link_with
=
@target_definition
.
link_with
if
link_with
=
@target_definition
.
link_with
@integrator
.
user_project
.
targets
.
select
do
|
target
|
user_project
.
targets
.
select
do
|
target
|
link_with
.
include?
target
.
name
link_with
.
include?
target
.
name
end
end
else
else
[
@integrator
.
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
|
...
@@ -97,7 +93,7 @@ module Pod
...
@@ -97,7 +93,7 @@ module Pod
end
end
def
add_xcconfig_base_configuration
def
add_xcconfig_base_configuration
xcconfig
=
@integrator
.
user_project
.
files
.
new
(
'path'
=>
"Pods/
#{
@target_definition
.
xcconfig_name
}
"
)
# TODO use Sandbox?
xcconfig
=
user_project
.
files
.
new
(
'path'
=>
"Pods/
#{
@target_definition
.
xcconfig_name
}
"
)
# TODO use Sandbox?
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
...
@@ -106,7 +102,7 @@ module Pod
...
@@ -106,7 +102,7 @@ module Pod
end
end
def
add_pods_library
def
add_pods_library
pods_library
=
@integrator
.
user_project
.
group
(
"Frameworks"
).
files
.
new_static_library
(
@target_definition
.
label
)
pods_library
=
user_project
.
group
(
"Frameworks"
).
files
.
new_static_library
(
@target_definition
.
label
)
targets
.
each
do
|
target
|
targets
.
each
do
|
target
|
target
.
frameworks_build_phases
.
each
{
|
build_phase
|
build_phase
<<
pods_library
}
target
.
frameworks_build_phases
.
each
{
|
build_phase
|
build_phase
<<
pods_library
}
end
end
...
...
lib/cocoapods/pod_path_resolver.rb
View file @
5df26a6f
...
@@ -2,13 +2,13 @@ module Pod
...
@@ -2,13 +2,13 @@ module Pod
class
PodPathResolver
class
PodPathResolver
include
Config
::
Mixin
include
Config
::
Mixin
def
initialize
(
podfile
)
def
initialize
(
target_definition
)
@
podfile
=
podfile
@
target_definition
=
target_definition
end
end
def
relative_path_for_pods
def
relative_path_for_pods
pods_path
=
config
.
project_pods_root
pods_path
=
config
.
project_pods_root
xcode_proj_path
=
@
podfile
.
xcodeproj
||
''
xcode_proj_path
=
@
target_definition
.
xcodeproj
||
''
source_root
=
(
config
.
project_root
+
xcode_proj_path
).
parent
source_root
=
(
config
.
project_root
+
xcode_proj_path
).
parent
pods_path
.
relative_path_from
(
source_root
)
pods_path
.
relative_path_from
(
source_root
)
end
end
...
...
lib/cocoapods/podfile.rb
View file @
5df26a6f
...
@@ -3,7 +3,7 @@ module Pod
...
@@ -3,7 +3,7 @@ module Pod
class
TargetDefinition
class
TargetDefinition
attr_reader
:name
,
:target_dependencies
attr_reader
:name
,
:target_dependencies
attr_accessor
:link_with
,
:platform
,
:parent
,
:exclusive
attr_accessor
:
xcodeproj
,
:
link_with
,
:platform
,
:parent
,
:exclusive
def
initialize
(
name
,
options
=
{})
def
initialize
(
name
,
options
=
{})
@name
,
@target_dependencies
=
name
,
[]
@name
,
@target_dependencies
=
name
,
[]
...
@@ -25,6 +25,22 @@ module Pod
...
@@ -25,6 +25,22 @@ module Pod
end
end
alias_method
:exclusive?
,
:exclusive
alias_method
:exclusive?
,
:exclusive
def
xcodeproj
=
(
path
)
path
=
path
.
to_s
@xcodeproj
=
Pathname
.
new
(
File
.
extname
(
path
)
==
'.xcodeproj'
?
path
:
"
#{
path
}
.xcodeproj"
)
end
def
xcodeproj
if
@xcodeproj
@xcodeproj
elsif
@parent
@parent
.
xcodeproj
else
xcodeprojs
=
Config
.
instance
.
project_root
.
glob
(
'*.xcodeproj'
)
@xcodeproj
=
xcodeprojs
.
first
if
xcodeprojs
.
size
==
1
end
end
def
link_with
=
(
targets
)
def
link_with
=
(
targets
)
@link_with
=
targets
.
is_a?
(
Array
)
?
targets
:
[
targets
]
@link_with
=
targets
.
is_a?
(
Array
)
?
targets
:
[
targets
]
end
end
...
@@ -121,8 +137,8 @@ module Pod
...
@@ -121,8 +137,8 @@ module Pod
# Specifies the path of the xcode project so it doesn't require the project to be specified
# Specifies the path of the xcode project so it doesn't require the project to be specified
# when running pod install each time.
# when running pod install each time.
def
xcodeproj
(
path
=
nil
)
def
xcodeproj
(
path
)
path
?
@xcodeproj
=
path
:
@xcodeproj
@target_definition
.
xcodeproj
=
path
end
end
# Specifies a dependency of the project.
# Specifies a dependency of the project.
...
...
spec/unit/installer/user_project_integrator_spec.rb
View file @
5df26a6f
...
@@ -34,11 +34,11 @@ describe Pod::Installer::UserProjectIntegrator do
...
@@ -34,11 +34,11 @@ describe Pod::Installer::UserProjectIntegrator do
end
end
it
"returns a Pod::Installer::UserProjectIntegrator::Target for each target definition in the Podfile"
do
it
"returns a Pod::Installer::UserProjectIntegrator::Target for each target definition in the Podfile"
do
@integrator
.
targets
.
map
(
&
:target_definition
).
should
==
@podfile
.
target_definitions
.
values
@integrator
.
target
_integrator
s
.
map
(
&
:target_definition
).
should
==
@podfile
.
target_definitions
.
values
end
end
it
"uses the first target in the user's project if no explicit target is specified"
do
it
"uses the first target in the user's project if no explicit target is specified"
do
target_integrator
=
@integrator
.
targets
.
first
target_integrator
=
@integrator
.
target
_integrator
s
.
first
target_integrator
.
target_definition
.
stubs
(
:link_with
).
returns
(
nil
)
target_integrator
.
target_definition
.
stubs
(
:link_with
).
returns
(
nil
)
target_integrator
.
targets
.
should
==
[
Xcodeproj
::
Project
.
new
(
@sample_project_path
).
targets
.
first
]
target_integrator
.
targets
.
should
==
[
Xcodeproj
::
Project
.
new
(
@sample_project_path
).
targets
.
first
]
end
end
...
...
spec/unit/pod_path_resolver_spec.rb
View file @
5df26a6f
...
@@ -2,14 +2,16 @@ require File.expand_path('../../spec_helper', __FILE__)
...
@@ -2,14 +2,16 @@ require File.expand_path('../../spec_helper', __FILE__)
describe
"Pod::PodPathResolver"
do
describe
"Pod::PodPathResolver"
do
it
"should default to a path underneath source root"
do
it
"should default to a path underneath source root"
do
podfile
=
Pod
::
Podfile
.
new
{
platform
:ios
;
xcodeproj
'foo.xcodeproj'
}
target_definition
=
Pod
::
Podfile
::
TargetDefinition
.
new
(
:default
)
resolver
=
Pod
::
PodPathResolver
.
new
(
podfile
)
target_definition
.
xcodeproj
=
'foo.xcodeproj'
resolver
=
Pod
::
PodPathResolver
.
new
(
target_definition
)
resolver
.
pods_root
.
should
==
"$(SRCROOT)/Pods"
resolver
.
pods_root
.
should
==
"$(SRCROOT)/Pods"
end
end
it
"should work with source root one level deeper"
do
it
"should work with source root one level deeper"
do
podfile
=
Pod
::
Podfile
.
new
{
platform
:ios
;
xcodeproj
'subdir/foo.xcodeproj'
}
target_definition
=
Pod
::
Podfile
::
TargetDefinition
.
new
(
:default
)
resolver
=
Pod
::
PodPathResolver
.
new
(
podfile
)
target_definition
.
xcodeproj
=
'subdir/foo.xcodeproj'
resolver
=
Pod
::
PodPathResolver
.
new
(
target_definition
)
resolver
.
pods_root
.
should
==
"$(SRCROOT)/../Pods"
resolver
.
pods_root
.
should
==
"$(SRCROOT)/../Pods"
end
end
end
end
spec/unit/podfile_spec.rb
View file @
5df26a6f
...
@@ -11,11 +11,6 @@ describe "Pod::Podfile" do
...
@@ -11,11 +11,6 @@ describe "Pod::Podfile" do
podfile
.
target_definitions
[
:default
].
platform
.
should
==
:ios
podfile
.
target_definitions
[
:default
].
platform
.
should
==
:ios
end
end
it
"assigns the xcodeproj attribute"
do
podfile
=
Pod
::
Podfile
.
new
{
platform
:ios
;
xcodeproj
"foo.xcodeproj"
}
podfile
.
xcodeproj
.
should
==
"foo.xcodeproj"
end
it
"adds dependencies"
do
it
"adds dependencies"
do
podfile
=
Pod
::
Podfile
.
new
{
dependency
'ASIHTTPRequest'
;
dependency
'SSZipArchive'
,
'>= 0.1'
}
podfile
=
Pod
::
Podfile
.
new
{
dependency
'ASIHTTPRequest'
;
dependency
'SSZipArchive'
,
'>= 0.1'
}
podfile
.
dependencies
.
size
.
should
==
2
podfile
.
dependencies
.
size
.
should
==
2
...
@@ -80,6 +75,7 @@ describe "Pod::Podfile" do
...
@@ -80,6 +75,7 @@ describe "Pod::Podfile" do
before
do
before
do
@podfile
=
Pod
::
Podfile
.
new
do
@podfile
=
Pod
::
Podfile
.
new
do
platform
:ios
platform
:ios
xcodeproj
'iOS Project'
target
:debug
do
target
:debug
do
dependency
'SSZipArchive'
dependency
'SSZipArchive'
...
@@ -95,6 +91,7 @@ describe "Pod::Podfile" do
...
@@ -95,6 +91,7 @@ describe "Pod::Podfile" do
target
:osx_target
do
target
:osx_target
do
platform
:osx
platform
:osx
xcodeproj
'OSX Project.xcodeproj'
link_with
'OSXTarget'
link_with
'OSXTarget'
dependency
'ASIHTTPRequest'
dependency
'ASIHTTPRequest'
target
:nested_osx_target
do
target
:nested_osx_target
do
...
@@ -136,6 +133,31 @@ describe "Pod::Podfile" do
...
@@ -136,6 +133,31 @@ describe "Pod::Podfile" do
target
.
dependencies
.
should
==
[
Pod
::
Dependency
.
new
(
'Reachability'
),
Pod
::
Dependency
.
new
(
'JSONKit'
)]
target
.
dependencies
.
should
==
[
Pod
::
Dependency
.
new
(
'Reachability'
),
Pod
::
Dependency
.
new
(
'JSONKit'
)]
end
end
it
"returns the Xcode project that contains the target to link with"
do
[
:default
,
:debug
,
:test
,
:subtarget
].
each
do
|
target_name
|
target
=
@podfile
.
target_definitions
[
target_name
]
target
.
xcodeproj
.
should
==
Pathname
.
new
(
'iOS Project.xcodeproj'
)
end
[
:osx_target
,
:nested_osx_target
].
each
do
|
target_name
|
target
=
@podfile
.
target_definitions
[
target_name
]
target
.
xcodeproj
.
should
==
Pathname
.
new
(
'OSX Project.xcodeproj'
)
end
end
it
"returns a Xcode project found in the working dir when no explicit project is specified"
do
xcodeproj1
=
config
.
project_root
+
'1.xcodeproj'
target
=
Pod
::
Podfile
::
TargetDefinition
.
new
(
:implicit
)
config
.
project_root
.
expects
(
:glob
).
with
(
'*.xcodeproj'
).
returns
([
xcodeproj1
])
target
.
xcodeproj
.
should
==
xcodeproj1
end
it
"returns `nil' if more than one Xcode project was found in the working when no explicit project is specified"
do
xcodeproj1
,
xcodeproj2
=
config
.
project_root
+
'1.xcodeproj'
,
config
.
project_root
+
'2.xcodeproj'
target
=
Pod
::
Podfile
::
TargetDefinition
.
new
(
:implicit
)
config
.
project_root
.
expects
(
:glob
).
with
(
'*.xcodeproj'
).
returns
([
xcodeproj1
,
xcodeproj2
])
target
.
xcodeproj
.
should
==
nil
end
it
"leaves the name of the target, to link with, to be automatically resolved"
do
it
"leaves the name of the target, to link with, to be automatically resolved"
do
target
=
@podfile
.
target_definitions
[
:default
]
target
=
@podfile
.
target_definitions
[
:default
]
target
.
link_with
.
should
==
nil
target
.
link_with
.
should
==
nil
...
...
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