Commit 85745020 authored by Fabio Pelosin's avatar Fabio Pelosin

[Installer] Add Frameworks & Resources to the Pods project.

With this patch the Main group of the Pods project is also sorted.

Closes #647
Closes #588
parent 21c970f3
......@@ -34,7 +34,9 @@
- CocoaPods now has support for working in teams and not committing the Pods folder.
- CocoaPods now can infer the platform from the integrated targets.
- Adds new subcommand `pod spec cat NAME` to print a spec file to standard output.
- Added Podfile to the Pods project.
- Added Podfile, Frameworks, and Resources to the Pods project.
[#647](https://github.com/CocoaPods/CocoaPods/issues/647)
[#588](https://github.com/CocoaPods/CocoaPods/issues/588)
- The `--no-clean` option of the `pod spec lint` command now displays the Pods project for inspection.
- It is now possible to specify default values for the configuration in `~/.cocoapods/config.yaml` ([example]()).
- CocoaPods now checks the checksums of the installed specifications and reinstalls them if needed.
......
GIT
remote: git://github.com/CocoaPods/Core.git
revision: 65076d5eb9b6b99ecce7b4628ce08b4c0f98f192
revision: b9a83fac80d06138852b183a41b3828372bddb8c
specs:
cocoapods-core (0.17.0.alpha)
activesupport (~> 3.2.6)
......@@ -9,7 +9,7 @@ GIT
GIT
remote: git://github.com/CocoaPods/Xcodeproj.git
revision: 9acba540a10bb50e69f4fb95052885d53ce76e1f
revision: d2bd1824f39ca1f2742e1e7af352db36251a267d
specs:
xcodeproj (0.4.0)
activesupport (~> 3.2.6)
......
......@@ -86,19 +86,29 @@ module Pod
prepare_for_legacy_compatibility
prepare_sandbox
install_dependencies
install_targets
UI.section "Generating Pods Project" do
prepare_pods_project
generate_target_installers
add_file_references_to_pods_project
run_pre_install_hooks
generate_target_support_files
run_post_install_hooks
write_pod_project
write_lockfiles
end
integrate_user_project
end
#-------------------------------------------------------------------------#
public
# @!group API
#
# This is the tentative API for the podfile and the specification hooks.
public
# @return [Analyzer] the analyzer which provides the information about what
# needs to be installed.
#
......@@ -133,7 +143,7 @@ module Pod
#--------------------------------------#
# @!group Hooks compatiblity
# @!group Hooks compatibility
alias :project :pods_project
alias :pods :local_pods
......@@ -170,7 +180,7 @@ module Pod
analyzer.specs_by_target.each do |target_definition, specs|
libray = libraries.find {|l| l.target_definition == target_definition }
# TODO the sanbox cached the local pods by target definition
# TODO the sandbox cached the local pods by target definition
# take into account local? in specification#==
locally_sourced_pods = {}
......@@ -235,14 +245,14 @@ module Pod
# regenerated from scratch and any file which might not be
# overwritten.
#
# @todo Clean the podspecs of all the pods that aren't unchanged so the
# resolution process doesn't get confused by them.
#
# @todo [#247] Clean the headers of only the pods to install.
#
# @todo [#534] Clean all the Pods folder that are not unchanged
#
# @todo Use the local pod implode.
#
# @todo [#534] Clean all the Pods folder that are not unchanged
# @todo Clean the podspecs of all the pods that aren't unchanged so the
# resolution process doesn't get confused by them.
#
def prepare_sandbox
sandbox.build_headers.implode!
......@@ -279,88 +289,12 @@ module Pod
end
end
# @return [void] Downloads, clean and generates the documentation of a pod.
#
# @note The docs need to be generated before cleaning because the
# documentation is created for all the subspecs.
#
# @note In this step we clean also the Pods that have been pre-downloaded
# in AbstractExternalSource#specification_from_sandbox.
#
def install_local_pod(pod)
unless sandbox.predownloaded_pods.include?(pod.name)
pod.implode
download_pod(pod)
end
generate_docs_if_needed(pod)
pod.clean! if config.clean?
end
# Downloads a Pod forcing the `bleeding edge' version if requested.
#
# @todo store the source of non specific downloads in the lockfile.
#
# @return [void]
#
def download_pod(pod)
downloader = Downloader.for_target(pod.root, pod.top_specification.source.dup)
downloader.cache_root = "~/Library/Caches/CocoaPods"
downloader.max_cache_size = 500
downloader.agressive_cache = config.agressive_cache?
if pod.top_specification.version.head?
downloader.download_head
specific_source = downloader.checkout_options
else
downloader.download
specific_source = downloader.checkout_options if downloader.specific_options?
end
pod.downloaded = true
if specific_source
# store the specific source
end
end
# Generates the documentation of a Pod unless it exists for a given
# version.
#
# @return [void]
#
def generate_docs_if_needed(pod)
doc_generator = Generator::Documentation.new(pod)
if ( config.generate_docs? && !doc_generator.already_installed? )
UI.section " > Installing documentation"
doc_generator.generate(config.doc_install?)
else
UI.section " > Using existing documentation"
end
end
# Creates and populates the targets of the pods project.
#
# @note Post install hooks run _before_ saving of project, so that they
# can alter it before it is written to the disk.
# Creates the Pods project from scratch if it doesn't exists.
#
# @return [void]
#
def install_targets
UI.section "Generating support files" do
prepare_pods_project
generate_target_installers
add_source_files_to_pods_project
run_pre_install_hooks
generate_target_support_files
run_post_install_hooks
write_pod_project
end
end
# Creates the Pods project from scratch if it doesn't exists.
#
# @todo Clean and modify the project if it exists.
#
# @return [void]
#
def prepare_pods_project
UI.message "- Creating Pods project" do
@pods_project = Pod::Project.new(nil)
......@@ -394,24 +328,34 @@ module Pod
#
# @todo Clean the groups of the deleted Pods and add only the Pods that
# should be installed.
# @todo [#588] Add file references for the resources of the Pods as well
# so they are visible for the user.
#
def add_source_files_to_pods_project
def add_file_references_to_pods_project
UI.message "- Adding Pods files to Pods project" do
local_pods.each { |p| p.add_file_references_to_project(pods_project) }
local_pods.each { |p| p.link_headers }
local_pods.each do |pod|
pod.add_file_references_to_project(pods_project)
pod.link_headers
pod.frameworks.each do |framework|
file_ref= pods_project.add_system_framework(framework, pod.platform.name)
end
unless pod.resources.empty?
resources_group = pods_project.new_group(pod.name, "Resources")
pod.resources.each do |resource|
resources_group.new_file(resource.relative_path_from(sandbox.root))
end
end
end
end
end
# Runs the pre install hooks of the installed specs and of the Podfile.
#
# @return [void]
#
# @todo Run the hooks only for the installed pods.
#
# @todo Print a message with the names of the specs.
#
# @return [void]
#
def run_pre_install_hooks
UI.message "- Running pre install hooks" do
local_pods_by_target.each do |target_definition, pods|
......@@ -425,12 +369,15 @@ module Pod
# Runs the post install hooks of the installed specs and of the Podfile.
#
# @note Post install hooks run _before_ saving of project, so that they
# can alter it before it is written to the disk.
#
# @return [void]
#
# @todo Run the hooks only for the installed pods.
#
# @todo Print a message with the names of the specs.
#
# @return [void]
#
def run_post_install_hooks
UI.message "- Running post install hooks" do
target_installers.each do |target_installer|
......@@ -459,6 +406,7 @@ module Pod
#
def write_pod_project
UI.message "- Writing Xcode project file to #{UI.path sandbox.project_path}" do
pods_project.main_group.sort_by_type!
pods_project.save_as(sandbox.project_path)
end
end
......@@ -500,5 +448,73 @@ module Pod
return unless config.integrate_targets?
UserProjectIntegrator.new(podfile, sandbox, config.project_root, analyzer.libraries).integrate!
end
#-------------------------------------------------------------------------#
private
# @!group Helpers
# Downloads, clean and generates the documentation of a pod.
#
# @note The docs need to be generated before cleaning because the
# documentation is created for all the subspecs.
#
# @note In this step we clean also the Pods that have been pre-downloaded
# in AbstractExternalSource#specification_from_sandbox.
#
# @return [void]
#
def install_local_pod(pod)
unless sandbox.predownloaded_pods.include?(pod.name)
pod.implode
download_pod(pod)
end
generate_docs_if_needed(pod)
pod.clean! if config.clean?
end
# Downloads a Pod forcing the `bleeding edge' version if requested.
#
# @return [void]
#
# @todo Store the source of non specific downloads in the lockfile.
#
def download_pod(pod)
downloader = Downloader.for_target(pod.root, pod.top_specification.source.dup)
downloader.cache_root = "~/Library/Caches/CocoaPods"
downloader.max_cache_size = 500
downloader.agressive_cache = config.agressive_cache?
if pod.top_specification.version.head?
downloader.download_head
specific_source = downloader.checkout_options
else
downloader.download
specific_source = downloader.checkout_options if downloader.specific_options?
end
pod.downloaded = true
if specific_source
# store the specific source
end
end
# Generates the documentation of a Pod unless it exists for a given
# version.
#
# @return [void]
#
def generate_docs_if_needed(pod)
doc_generator = Generator::Documentation.new(pod)
if ( config.generate_docs? && !doc_generator.already_installed? )
UI.section " > Installing documentation"
doc_generator.generate(config.doc_install?)
else
UI.section " > Using existing documentation"
end
end
#-------------------------------------------------------------------------#
end
end
......@@ -407,6 +407,10 @@ module Pod
config
end
def frameworks
specifications.map { |spec| spec.frameworks }.flatten.uniq
end
# Computes the paths of all the public headers of the pod including every
# subspec (activated or not).
# For this reason the pod must not be cleaned when calling this command.
......
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