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
18f6fe20
Commit
18f6fe20
authored
Oct 19, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a post install hook which allows a pod spec to run custom code.
For instance, by appending code to the Pods prefix header.
parent
cb5f3890
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
15 deletions
+43
-15
installer.rb
lib/cocoapods/installer.rb
+9
-11
specification.rb
lib/cocoapods/specification.rb
+19
-4
installer_spec.rb
spec/unit/installer_spec.rb
+15
-0
No files found.
lib/cocoapods/installer.rb
View file @
18f6fe20
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
include
Config
::
Mixin
...
...
@@ -16,6 +14,10 @@ module Pod
dependent_specification_sets
.
reject
(
&
:only_part_of_other_pod?
)
end
def
build_specifications
build_specification_sets
.
map
(
&
:specification
)
end
def
xcconfig
@xcconfig
||=
Xcode
::
Config
.
new
({
# In a workspace this is where the static library headers should be found
...
...
@@ -33,8 +35,7 @@ module Pod
def
generate_project
puts
"==> Generating Xcode project and xcconfig"
unless
config
.
silent?
user_header_search_paths
=
[]
build_specification_sets
.
each
do
|
set
|
spec
=
set
.
specification
build_specifications
.
each
do
|
spec
|
xcconfig
.
merge!
(
spec
.
xcconfig
)
group
=
xcodeproj
.
add_pod_group
(
spec
.
name
)
...
...
@@ -59,25 +60,22 @@ module Pod
end
def
bridge_support_generator
BridgeSupportGenerator
.
new
(
build_specification
_sets
.
map
do
|
set
|
s
et
.
specification
.
header_files
.
map
do
|
header
|
BridgeSupportGenerator
.
new
(
build_specification
s
.
map
do
|
spec
|
s
pec
.
header_files
.
map
do
|
header
|
config
.
project_pods_root
+
header
end
end
.
flatten
)
end
# TODO we need a spec that tests that all dependencies are first downloaded/installed
# before #generate_project is called!
def
install!
puts
"Installing dependencies of:
#{
@specification
.
defined_in_file
}
"
unless
config
.
silent?
build_specification_sets
.
each
do
|
set
|
set
.
specification
.
install!
end
build_specifications
.
each
(
&
:install!
)
generate_project
root
=
config
.
project_pods_root
xcodeproj
.
create_in
(
root
)
xcconfig
.
create_in
(
root
)
bridge_support_generator
.
create_in
(
root
)
if
@specification
.
generate_bridge_support
build_specifications
.
each
(
&
:post_install
)
end
end
end
lib/cocoapods/specification.rb
View file @
18f6fe20
...
...
@@ -257,8 +257,8 @@ module Pod
# Override this if you need to perform work before or after activating the
# pod. Eg:
#
# Pod::Spec.new do
# def install!
# Pod::Spec.new do
|s|
# def
s.
install!
# # pre-install
# super
# # post-install
...
...
@@ -290,8 +290,8 @@ module Pod
# 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!
# Pod::Spec.new do
|s|
# def
s.
download!
# # pre-download
# super # or custom downloading
# # post-download
...
...
@@ -303,6 +303,21 @@ module Pod
downloader
.
clean
(
clean_paths
)
if
config
.
clean
end
# This is a convenience method which gets called after all pods have been
# downloaded, installed, and the Xcode project and related files have been
# generated. Override this to, for instance, add to the prefix header:
#
# Pod::Spec.new do |s|
# def s.post_install
# prefix_header = config.project_pods_root + 'Pods-Prefix.pch'
# prefix_header.open('a') do |file|
# file.puts(%{#ifdef __OBJC__\n#import "SSToolkitDefines.h"\n#endif})
# end
# end
# end
def
post_install
end
end
Spec
=
Specification
...
...
spec/unit/installer_spec.rb
View file @
18f6fe20
...
...
@@ -12,6 +12,21 @@ describe "Pod::Installer" do
config
.
repos_dir
=
SpecHelper
.
tmp_repos_path
end
it
"generates a BridgeSupport metadata file from all the pod headers"
do
spec
=
Pod
::
Spec
.
new
do
|
s
|
s
.
platform
=
:osx
s
.
dependency
'ASIHTTPRequest'
end
expected
=
[]
installer
=
Pod
::
Installer
.
new
(
spec
)
installer
.
build_specifications
.
each
do
|
spec
|
spec
.
header_files
.
each
do
|
header
|
expected
<<
config
.
project_pods_root
+
header
end
end
installer
.
bridge_support_generator
.
headers
.
should
==
expected
end
it
"adds all source files that should be included in the library to the xcode project"
do
[
[
...
...
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