Commit 18f6fe20 authored by Eloy Duran's avatar Eloy Duran

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
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|
set.specification.header_files.map do |header|
BridgeSupportGenerator.new(build_specifications.map do |spec|
spec.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
......@@ -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
......
......@@ -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
[
[
......
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