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
bb500057
Commit
bb500057
authored
Sep 13, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move installation code into Installer class.
parent
c14cdd66
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
119 additions
and
87 deletions
+119
-87
Podfile
examples/Podfile
+2
-2
cocoa_pods.rb
lib/cocoa_pods.rb
+1
-0
install.rb
lib/cocoa_pods/command/install.rb
+1
-2
installer.rb
lib/cocoa_pods/installer.rb
+66
-0
resolver.rb
lib/cocoa_pods/resolver.rb
+1
-1
specification.rb
lib/cocoa_pods/specification.rb
+46
-80
set.rb
lib/cocoa_pods/specification/set.rb
+1
-1
project.rb
lib/cocoa_pods/xcode/project.rb
+1
-1
No files found.
examples/Podfile
View file @
bb500057
#
dependency 'SSZipArchive', '>= 1'
dependency
'SSZipArchive'
,
'>= 1'
#
dependency 'ASIHTTPRequest', '1.8'
dependency
'ASIHTTPRequest'
,
'1.8'
#dependency 'ASIWebPageRequest', '= 1.8'
# is part of ASIHTTPRequest 1.8 and 1.8.1
...
...
lib/cocoa_pods.rb
View file @
bb500057
...
...
@@ -3,6 +3,7 @@ module Pod
autoload
:Config
,
'cocoa_pods/config'
autoload
:Dependency
,
'cocoa_pods/dependency'
autoload
:Downloader
,
'cocoa_pods/downloader'
autoload
:Installer
,
'cocoa_pods/installer'
autoload
:Resolver
,
'cocoa_pods/resolver'
autoload
:Source
,
'cocoa_pods/source'
autoload
:Spec
,
'cocoa_pods/specification'
...
...
lib/cocoa_pods/command/install.rb
View file @
bb500057
...
...
@@ -3,8 +3,7 @@ module Pod
class
Install
<
Command
def
run
if
spec
=
Specification
.
from_podfile
(
podfile
)
spec
.
install_dependent_specifications!
spec
.
create_static_library_project!
Installer
.
new
(
spec
,
config
.
project_pods_root
).
install!
else
$stderr
.
puts
"No Podfile found in current working directory."
end
...
...
lib/cocoa_pods/installer.rb
0 → 100644
View file @
bb500057
module
Pod
# TODO the static library needs an extra xcconfig which sets the values from issue #1.
# Or we could edit the project.pbxproj file, but that seems like more work...
class
Installer
def
initialize
(
top_level_specification
,
pods_root
)
@top_level_specification
,
@pods_root
=
top_level_specification
,
pods_root
end
def
dependent_specification_sets
@dependent_specifications_sets
||=
Resolver
.
new
(
@top_level_specification
).
resolve
end
def
xcconfig
@xcconfig
||=
Xcode
::
Config
.
new
({
# in a workspace this is where the static library headers should be found
'USER_HEADER_SEARCH_PATHS'
=>
'$(BUILT_PRODUCTS_DIR)'
,
# search the user headers
'ALWAYS_SEARCH_USER_PATHS'
=>
'YES'
,
})
end
def
xproj
@xproj
||=
Xcode
::
Project
.
static_library
end
def
install!
install_dependent_specifications!
generate_project
write_files!
end
def
install_dependent_specifications!
dependent_specification_sets
.
each
do
|
set
|
# In case the set is only part of other pods we don't need to install
# the pod itself.
next
if
set
.
only_part_of_other_pod?
set
.
specification
.
install!
end
end
def
generate_project
puts
"==> Creating Pods project files"
dependent_specification_sets
.
each
do
|
set
|
# In case the set is only part of other pods we don't need to build
# the pod itself.
next
if
set
.
only_part_of_other_pod?
spec
=
set
.
specification
spec
.
read
(
:source_files
).
each
do
|
pattern
|
pattern
=
spec
.
pod_destroot
+
pattern
pattern
=
pattern
+
'*.{h,m,mm,c,cpp}'
if
pattern
.
directory?
Dir
.
glob
(
pattern
.
to_s
).
each
do
|
file
|
file
=
Pathname
.
new
(
file
)
file
=
file
.
relative_path_from
(
@pods_root
)
xproj
.
add_source_file
(
file
)
end
end
xcconfig
<<
spec
.
read
(
:xcconfig
)
end
end
def
write_files!
xproj
.
create_in
(
@pods_root
)
xcconfig
.
create_in
(
@pods_root
)
end
end
end
lib/cocoa_pods/resolver.rb
View file @
bb500057
...
...
@@ -20,7 +20,7 @@ module Pod
set
.
required_by
(
specification
,
dependency
)
unless
@sets
.
include?
(
set
)
@sets
<<
set
find_dependency_sets
(
set
.
podspec
)
find_dependency_sets
(
set
.
specification
)
end
end
end
...
...
lib/cocoa_pods/specification.rb
View file @
bb500057
...
...
@@ -21,6 +21,7 @@ module Pod
def
initialize
(
&
block
)
@dependencies
=
[]
@xcconfig
=
{}
instance_eval
(
&
block
)
if
block_given?
end
...
...
@@ -62,7 +63,6 @@ module Pod
end
def
part_of
(
name
,
*
version_requirements
)
#@part_of = Dependency.new(name, *version_requirements)
@part_of
=
dependency
(
name
,
*
version_requirements
)
@part_of
.
part_of_other_pod
=
true
end
...
...
@@ -93,81 +93,57 @@ module Pod
# Not attributes
include
Config
::
Mixin
# Returns the specification for the pod that this pod's source is a part of.
def
part_of_specification
if
@part_of
Set
.
by_specification_name
(
@part_of
.
name
).
podspec
Set
.
by_specification_name
(
@part_of
.
name
).
specification
end
end
# TODO move this all to an Installer class
# This also includes those that are only part of other specs, but are not
# actually being used themselves.
def
resolved_dependent_specification_sets
@resolved_dependent_specifications_sets
||=
Resolver
.
new
(
self
).
resolve
end
def
install_dependent_specifications!
sets
=
resolved_dependent_specification_sets
sets
.
each
do
|
set
|
# In case the set is only part of other pods we don't need to install
# the pod itself.
next
if
set
.
only_part_of_other_pod?
set
.
podspec
.
install!
def
pod_destroot
if
part_of_other_pod?
part_of_specification
.
pod_destroot
else
config
.
project_pods_root
+
"
#{
@name
}
-
#{
@version
}
"
end
end
def
create_static_library_project!
puts
"==> Creating static library project"
xcconfig
=
Xcode
::
Config
.
new
({
# in a workspace this is where the static library headers should be found
'USER_HEADER_SEARCH_PATHS'
=>
'$(BUILT_PRODUCTS_DIR)'
,
# search the user headers
'ALWAYS_SEARCH_USER_PATHS'
=>
'YES'
,
})
project
=
Xcode
::
Project
.
static_library
resolved_dependent_specification_sets
.
each
do
|
set
|
# In case the set is only part of other pods we don't need to build
# the pod itself.
next
if
set
.
only_part_of_other_pod?
spec
=
set
.
podspec
spec
.
read
(
:source_files
).
each
do
|
pattern
|
pattern
=
spec
.
pod_destroot
+
pattern
pattern
=
pattern
+
'*.{h,m,mm,c,cpp}'
if
pattern
.
directory?
Dir
.
glob
(
pattern
.
to_s
).
each
do
|
file
|
file
=
Pathname
.
new
(
file
)
file
=
file
.
relative_path_from
(
config
.
project_pods_root
)
project
.
add_source_file
(
file
)
end
end
if
xcconfig_hash
=
spec
.
read
(
:xcconfig
)
xcconfig
<<
xcconfig_hash
end
end
project
.
create_in
(
config
.
project_pods_root
)
# TODO the static library needs an extra xcconfig which sets the values from issue #1.
# Or we could edit the project.pbxproj file, but that seems like more work...
xcconfig
.
create_in
(
config
.
project_pods_root
)
def
part_of_other_pod?
!
@part_of
.
nil?
end
include
Config
::
Mixin
def
from_podfile?
@name
.
nil?
&&
@version
.
nil?
end
def
pod_destroot
if
part_of_other_pod
?
part_of_specification
.
pod_destroot
def
to_s
if
from_podfile
?
"podfile at `
#{
@defined_in_file
}
'"
else
config
.
project_pods_root
+
"
#{
@name
}
-
#{
@version
}
"
"`
#{
@name
}
' version `
#{
@version
}
'
"
end
end
# Places the activated podspec in the project's pods directory.
def
inspect
"#<
#{
self
.
class
.
name
}
for
#{
to_s
}
>"
end
# Install and download hooks
# Places the activated specification in the project's pods directory.
#
# Override this if you need to perform work before or after activating the
# pod. Eg:
#
# Pod::Spec.new do
# def install!
# # pre-install
# super
# # post-install
# end
# end
def
install!
puts
"==> Installing:
#{
self
}
"
config
.
project_pods_root
.
mkpath
...
...
@@ -191,32 +167,22 @@ module Pod
# Downloads the source of the pod and places it in the project's pods
# directory.
#
# You can override this for custom downloading.
# Override this if you need to perform work before or after downloading the
# pod, or if you need to implement custom dowloading. Eg:
#
# Pod::Spec.new do
# def download!
# # pre-download
# super # or custom downloading
# # post-download
# end
# end
def
download!
downloader
=
Downloader
.
for_source
(
@source
,
pod_destroot
)
downloader
.
download
downloader
.
clean
if
config
.
clean
end
def
part_of_other_pod?
!
@part_of
.
nil?
end
def
from_podfile?
@name
.
nil?
&&
@version
.
nil?
end
def
to_s
if
from_podfile?
"podfile at `
#{
@defined_in_file
}
'"
else
"`
#{
@name
}
' version `
#{
@version
}
'"
end
end
def
inspect
"#<
#{
self
.
class
.
name
}
for
#{
to_s
}
>"
end
end
Spec
=
Specification
...
...
lib/cocoa_pods/specification/set.rb
View file @
bb500057
...
...
@@ -48,7 +48,7 @@ module Pod
@pod_dir
+
required_version
.
to_s
+
"
#{
name
}
.podspec"
end
def
podspec
def
specification
Specification
.
from_podspec
(
spec_pathname
)
end
...
...
lib/cocoa_pods/xcode/project.rb
View file @
bb500057
...
...
@@ -3,7 +3,7 @@ framework 'Foundation'
module
Pod
module
Xcode
class
Project
TEMPLATES_DIR
=
Pathname
.
new
(
File
.
expand_path
(
'../../../xcode-project-templates'
,
__FILE__
))
TEMPLATES_DIR
=
Pathname
.
new
(
File
.
expand_path
(
'../../../
../
xcode-project-templates'
,
__FILE__
))
# TODO see if we really need different templates for iOS and OS X
def
self
.
static_library
...
...
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