Commit e3cfdfd6 authored by Fabio Pelosin's avatar Fabio Pelosin

Merge branch 'master' into sandbox_reorganization_544

* master: (46 commits)
  [Command::Init] Update specs for recent changes
  [Command::Init] Add dependencies of the normal targets inside the target block
  [Command::Init] Add note about the configuration files to the description
  Update CHANGELOG for #1294
  [rake] Welcome to the real world, where envs don’t automagically work.
  [Installer] Add all the user's build configurations to the Pods project.
  [Analyzer] Resolve all user build configurations.
  Misc small changes.
  Rebuild integration specs.
  Update Xcodeproj to the latest master revision
  Use the build configurations from the Podfile for the Pods project
  Add test for STRIP_INSTALLED_PRODUCT = NO at project level
  Fix all callers of Pod::Project.new()
  Handle the build_configurations parameter in Xcodeproj::Project subclasses
  Pass the user build configurations to the Pods project
  Add link to Gemfile regarding local repos.
  Add that this is the MIT license.
  [CONTRIBUTING] Update CocoaPods.
  [Xcodeproj] Use Pod::UI for warnings and messages
  [Changelog]
  ...

Conflicts:
	spec/cocoapods-integration-specs
parents cedc0bf0 c95e3cf4
...@@ -4,6 +4,45 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -4,6 +4,45 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
## Master ## Master
###### Enhancements
* Create all necessary build configurations for *Pods.xcodeproj* at the project level. If the user’s project has more than just *Debug* and *Release* build configurations, they may be explicitly specified in the Podfile:
`xcodeproj 'MyApp', 'App Store' => :release, 'Debug' => :debug, 'Release' => :release`
If build configurations aren’t specified in the Podfile then they will be automatically picked from the user’s project in *Release* mode.
These changes will ensure that the `libPods.a` static library is not stripped for all configurations, as explained in [#1217](https://github.com/CocoaPods/CocoaPods/pull/1217).
[Cédric Luthi](https://github.com/0xced)
[#1294](https://github.com/CocoaPods/CocoaPods/issues/1294)
* Added `pod init` command which generates a Podfile according to the
targets of the project stored in the working directory and to the templates
stored in the `~/.cocoapods/templates` folder. Tow templates are supported:
- the `Podfile.default` template for regular targets.
- and the `Podfile.test` template for test targets.
[Ian Ynda-Hummel](https://github.com/ianyh)
[#1106](https://github.com/CocoaPods/CocoaPods/issues/1106)
[#1045](https://github.com/CocoaPods/CocoaPods/issues/1045)
* CocoaPods will now leverage the [xcproj](https://github.com/0xced/xcproj)
command line tool if available in the path of the user to touch saved
projects. This will result in projects being serialized in the exact format
used by Xcode eliminating merge conflicts and other related issues. To learn
more about how to install xcproj see its
[readme](https://github.com/0xced/xcproj).
[Cédric Luthi](https://github.com/0xced)
[#1275](https://github.com/CocoaPods/CocoaPods/issues/1275)
###### Bug Fixes
* Fixed crash in `pod spec cat`.
* Use the `TARGET_BUILD_DIR` environment variable for installing resource bundles.
[Cédric Luthi](https://github.com/0xced)
[#1268](https://github.com/CocoaPods/CocoaPods/issues/1268)
## 0.23.0
## 0.23.0.rc1 ## 0.23.0.rc1
###### Enhancements ###### Enhancements
...@@ -59,7 +98,7 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -59,7 +98,7 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[#1155](https://github.com/CocoaPods/CocoaPods/issues/1155) [#1155](https://github.com/CocoaPods/CocoaPods/issues/1155)
* Removed punctuation check from the specification validations. * Removed punctuation check from the specification validations.
[#1155](https://github.com/CocoaPods/CocoaPods/issues/1155) [#1242](https://github.com/CocoaPods/CocoaPods/issues/1242)
* Deprecated the `documentation` attribute of the Specification DSL. * Deprecated the `documentation` attribute of the Specification DSL.
[Core#20](https://github.com/CocoaPods/Core/issues/20) [Core#20](https://github.com/CocoaPods/Core/issues/20)
......
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
## Bug reports ## Bug reports
First check if you are using the latest CocoaPods version before filing a ticket.
You can install the latest version with `$ [sudo] gem install cocoapods`.
Please include _all_ relevant information, including the version of CocoaPods and Please include _all_ relevant information, including the version of CocoaPods and
any template printed by the tool. any template printed by the tool.
......
...@@ -7,6 +7,7 @@ gemspec ...@@ -7,6 +7,7 @@ gemspec
group :development do group :development do
# To develop the deps in tandem use the `LOCAL GIT REPOS` feature of Bundler. # To develop the deps in tandem use the `LOCAL GIT REPOS` feature of Bundler.
# For more info see http://bundler.io/git.html#local
gem 'cocoapods-core', :git => "https://github.com/CocoaPods/Core.git", :branch => 'master' gem 'cocoapods-core', :git => "https://github.com/CocoaPods/Core.git", :branch => 'master'
gem 'xcodeproj', :git => "https://github.com/CocoaPods/Xcodeproj.git", :branch => 'master' gem 'xcodeproj', :git => "https://github.com/CocoaPods/Xcodeproj.git", :branch => 'master'
gem 'cocoapods-downloader', :git => "https://github.com/CocoaPods/cocoapods-downloader.git", :branch => 'master' gem 'cocoapods-downloader', :git => "https://github.com/CocoaPods/cocoapods-downloader.git", :branch => 'master'
......
...@@ -7,17 +7,17 @@ GIT ...@@ -7,17 +7,17 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Core.git remote: https://github.com/CocoaPods/Core.git
revision: 63f310adb5210854b34c3d94bb9452bafd7cbc26 revision: 925b48bb35d969e2f74777a883ef3a9e5659dde3
branch: master branch: master
specs: specs:
cocoapods-core (0.23.0.rc1) cocoapods-core (0.23.0)
activesupport (~> 3.2.13) activesupport (~> 3.2.13)
json (~> 1.8.0) json (~> 1.8.0)
nap (~> 0.5.1) nap (~> 0.5.1)
GIT GIT
remote: https://github.com/CocoaPods/Xcodeproj.git remote: https://github.com/CocoaPods/Xcodeproj.git
revision: 83c3e0781cbea05c704d02523610fe43f3ea062c revision: 9d2f8cef72466cb3f155a9a5a3cfb12c94802656
branch: master branch: master
specs: specs:
xcodeproj (0.9.0) xcodeproj (0.9.0)
...@@ -61,10 +61,10 @@ GIT ...@@ -61,10 +61,10 @@ GIT
PATH PATH
remote: . remote: .
specs: specs:
cocoapods (0.23.0.rc1) cocoapods (0.23.0)
activesupport (~> 3.2.13) activesupport (~> 3.2.13)
claide (~> 0.3.2) claide (~> 0.3.2)
cocoapods-core (= 0.23.0.rc1) cocoapods-core (= 0.23.0)
cocoapods-downloader (~> 0.1.2) cocoapods-downloader (~> 0.1.2)
colored (~> 1.2) colored (~> 1.2)
escape (~> 0.0.4) escape (~> 0.0.4)
...@@ -99,7 +99,7 @@ GEM ...@@ -99,7 +99,7 @@ GEM
metaclass (~> 0.0.1) metaclass (~> 0.0.1)
mocha-on-bacon (0.2.2) mocha-on-bacon (0.2.2)
mocha (>= 0.13.0) mocha (>= 0.13.0)
multi_json (1.7.7) multi_json (1.7.8)
nap (0.5.1) nap (0.5.1)
open4 (1.3.0) open4 (1.3.0)
posix-spawn (0.3.6) posix-spawn (0.3.6)
......
This project is licensed under the MIT license.
Copyright (c) 2011 - 2012 Eloy Durán <eloy.de.enige@gmail.com> Copyright (c) 2011 - 2012 Eloy Durán <eloy.de.enige@gmail.com>
Copyright (c) 2012 Fabio Pelosin <fabiopelosin@gmail.com> Copyright (c) 2012 Fabio Pelosin <fabiopelosin@gmail.com>
......
...@@ -220,6 +220,7 @@ namespace :spec do ...@@ -220,6 +220,7 @@ namespace :spec do
title 'Running the specs' title 'Running the specs'
sh "bundle exec bacon #{specs('**')}" sh "bundle exec bacon #{specs('**')}"
require 'pathname'
unless Pathname.new(ENV['HOME']+'/.cocoapods/repos/master').exist? unless Pathname.new(ENV['HOME']+'/.cocoapods/repos/master').exist?
title 'Ensuring specs repo is up to date' title 'Ensuring specs repo is up to date'
sh "./bin/pod setup" sh "./bin/pod setup"
...@@ -282,8 +283,10 @@ namespace :spec do ...@@ -282,8 +283,10 @@ namespace :spec do
# Remove files not used for the comparison # Remove files not used for the comparison
# To keep the git diff clean # To keep the git diff clean
FileList['spec/integration/*/after/{Podfile,*.podspec,**/*.xcodeproj,PodTest-hg-source}'].each do |to_delete| files_to_delete = FileList['spec/cocoapods-integration-specs/*/after/{Podfile,*.podspec,**/*.xcodeproj,PodTest-hg-source}']
sh "rm -rf #{to_delete}" files_to_delete.exclude('/spec/cocoapods-integration-specs/init_single_platform/**/*.*')
files_to_delete.each do |file_to_delete|
sh "rm -rf #{file_to_delete}"
end end
puts puts
...@@ -341,7 +344,8 @@ namespace :examples do ...@@ -341,7 +344,8 @@ namespace :examples do
Dir.chdir(example.to_s) do Dir.chdir(example.to_s) do
execute_command "rm -rf Pods DerivedData" execute_command "rm -rf Pods DerivedData"
# WARNING: This appeart to use sytem gems instead of the bundle ones. # WARNING: This appeart to use sytem gems instead of the bundle ones.
execute_command "#{'../../bin/' unless ENV['FROM_GEM']}sandbox-pod install --verbose --no-repo-update" pod_command = ENV['FROM_GEM'] ? 'sandbox-pod' : 'bundle exec ../../bin/sandbox-pod'
execute_command "#{pod_command} install --verbose --no-repo-update"
command = "xcodebuild -workspace '#{example.basename}.xcworkspace' -scheme '#{example.basename}'" command = "xcodebuild -workspace '#{example.basename}.xcworkspace' -scheme '#{example.basename}'"
if (example + 'Podfile').read.include?('platform :ios') if (example + 'Podfile').read.include?('platform :ios')
# Specifically build against the simulator SDK so we don't have to deal with code signing. # Specifically build against the simulator SDK so we don't have to deal with code signing.
......
require 'rubygems' require 'rubygems'
require 'xcodeproj'
autoload :Xcodeproj, 'xcodeproj'
module Pod module Pod
require 'pathname' require 'pathname'
......
...@@ -20,6 +20,7 @@ module Pod ...@@ -20,6 +20,7 @@ module Pod
require 'cocoapods/command/search' require 'cocoapods/command/search'
require 'cocoapods/command/setup' require 'cocoapods/command/setup'
require 'cocoapods/command/spec' require 'cocoapods/command/spec'
require 'cocoapods/command/init'
self.abstract_command = true self.abstract_command = true
self.default_subcommand = 'install' self.default_subcommand = 'install'
......
require 'xcodeproj'
require 'active_support/core_ext/string/strip'
module Pod
class Command
class Init < Command
self.summary = 'Generate a Podfile for the current directory.'
self.description = <<-DESC
Creates a Podfile for the current directory if none currently exists. If
an Xcode project file is specified or if there is only a single project
file in the current directory, targets will be automatically generated
based on targets defined in the project.
It is possible to specify a list of dependencies which will be used by
the template in the `Podfile.default` (normal targets) `Podfile.test`
(test targets) files which should be stored in the
`~/.cocoapods/templates` folder.
DESC
self.arguments = '[XCODEPROJ]'
def initialize(argv)
@podfile_path = Pathname.pwd + "Podfile"
@project_path = argv.shift_argument
@project_paths = Pathname.pwd.children.select { |pn| pn.extname == '.xcodeproj' }
super
end
def validate!
super
raise Informative, "Existing Podfile found in directory" unless config.podfile.nil?
if @project_path
help! "Xcode project at #{@project_path} does not exist" unless File.exist? @project_path
else
raise Informative, "No xcode project found, please specify one" unless @project_paths.length > 0
raise Informative, "Multiple xcode projects found, please specify one" unless @project_paths.length == 1
@project_path = @project_paths.first
end
@xcode_project = Xcodeproj::Project.new(@project_path)
end
def run
@podfile_path.open('w') { |f| f << podfile_template(@xcode_project) }
end
private
# @param [Xcodeproj::Project] project
# The xcode project to generate a podfile for.
#
# @return [String] the text of the Podfile for the provided project
#
def podfile_template(project)
podfile = <<-PLATFORM.strip_heredoc
# Uncomment this line to define a global platform for your project
# platform :ios, "6.0"
PLATFORM
for target in project.targets
podfile << target_module(target)
end
podfile << "\n"
end
# @param [Xcodeproj::PBXTarget] target
# A target to generate a Podfile target module for.
#
# @return [String] the text for the target module
#
def target_module(target)
target_module = "\ntarget \"#{target.name}\" do\n"
if target.name =~ /tests?/i
target_module << template_contents(config.default_test_podfile_path)
else
target_module << template_contents(config.default_podfile_path)
end
target_module << "\nend\n"
end
def template_contents(path)
if path.exist?
path.read.chomp.lines.map{ |line| " #{line}" }.join("\n")
else
String.new
end
end
end
end
end
...@@ -6,7 +6,7 @@ module Pod ...@@ -6,7 +6,7 @@ module Pod
self.summary = 'Setup the CocoaPods environment' self.summary = 'Setup the CocoaPods environment'
self.description = <<-DESC self.description = <<-DESC
Creates a directory at `~/.cocoapods` which will hold your spec-repos. Creates a directory at `~/.cocoapods/repos` which will hold your spec-repos.
This is where it will create a clone of the public `master` spec-repo from: This is where it will create a clone of the public `master` spec-repo from:
https://github.com/CocoaPods/Specs https://github.com/CocoaPods/Specs
......
...@@ -304,7 +304,7 @@ module Pod ...@@ -304,7 +304,7 @@ module Pod
# @return [Pathname] the absolute path of the given spec and source # @return [Pathname] the absolute path of the given spec and source
# #
def pathname_from_spec(spec, source) def pathname_from_spec(spec, source)
Pathname.new("~/.cocoapods/#{ source }/#{ spec.name }/#{ spec.version }/#{ spec.name }.podspec").expand_path config.repos_dir + "#{source}/#{spec.name}/#{spec.version}/#{spec.name}.podspec"
end end
# @return [String] of spec paths one on each line # @return [String] of spec paths one on each line
......
...@@ -147,6 +147,12 @@ module Pod ...@@ -147,6 +147,12 @@ module Pod
attr_writer :repos_dir attr_writer :repos_dir
# @return [Pathname] the directory where the CocoaPods templates are stored.
#
def templates_dir
@templates_dir ||= Pathname.new(ENV['CP_TEMPLATES_DIR'] || "~/.cocoapods/templates").expand_path
end
# @return [Pathname] the root of the CocoaPods installation where the # @return [Pathname] the root of the CocoaPods installation where the
# Podfile is located. # Podfile is located.
# #
...@@ -223,6 +229,26 @@ module Pod ...@@ -223,6 +229,26 @@ module Pod
@lockfile_path ||= installation_root + 'Podfile.lock' @lockfile_path ||= installation_root + 'Podfile.lock'
end end
# Returns the path of the default Podfile pods.
#
# @note The file is expected to be named Podfile.default
#
# @return [Pathname]
#
def default_podfile_path
@default_podfile_path ||= templates_dir + "Podfile.default"
end
# Returns the path of the default Podfile test pods.
#
# @note The file is expected to be named Podfile.test
#
# @return [Pathname]
#
def default_test_podfile_path
@default_test_podfile_path ||= templates_dir + "Podfile.test"
end
# @return [Pathname] The file to use a cache of the statistics provider. # @return [Pathname] The file to use a cache of the statistics provider.
# #
def statistics_cache_file def statistics_cache_file
......
module Pod module Pod
# The version of the cocoapods command line tool. # The version of the cocoapods command line tool.
# #
VERSION = '0.23.0.rc1' unless defined? Pod::VERSION VERSION = '0.23.0' unless defined? Pod::VERSION
end end
...@@ -294,7 +294,7 @@ module Pod ...@@ -294,7 +294,7 @@ module Pod
# #
def prepare_pods_project def prepare_pods_project
UI.message "- Creating Pods project" do UI.message "- Creating Pods project" do
@pods_project = Pod::Project.new(sandbox) @pods_project = Pod::Project.new(sandbox, analysis_result.all_user_build_configurations)
if config.podfile_path if config.podfile_path
@pods_project.add_podfile(config.podfile_path) @pods_project.add_podfile(config.podfile_path)
end end
......
...@@ -488,6 +488,16 @@ module Pod ...@@ -488,6 +488,16 @@ module Pod
# #
attr_accessor :targets attr_accessor :targets
# @return [Hash{String=>Symbol}] A hash representing all the user build
# configurations across all integration targets. Each key
# corresponds to the name of a configuration and its value to
# its type (`:debug` or `:release`).
#
def all_user_build_configurations
targets.inject({}) do |result, target|
result.merge(target.user_build_configurations)
end
end
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
......
...@@ -91,7 +91,7 @@ module Pod ...@@ -91,7 +91,7 @@ module Pod
UI.message "- Generating copy resources script at #{UI.path(path)}" do UI.message "- Generating copy resources script at #{UI.path(path)}" do
file_accessors = library.pod_targets.map(&:file_accessors).flatten file_accessors = library.pod_targets.map(&:file_accessors).flatten
resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map {|res| project.relativize(res)} }.flatten resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map {|res| project.relativize(res)} }.flatten
resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map {|name| "${BUILD_DIR}/${CONFIGURATION}${EFFECTIVE_PLATFORM_NAME}/#{name}.bundle" } }.flatten resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map {|name| "${TARGET_BUILD_DIR}/#{name}.bundle" } }.flatten
resources = [] resources = []
resources.concat(resource_paths) resources.concat(resource_paths)
resources.concat(resource_bundles) resources.concat(resource_bundles)
......
...@@ -17,8 +17,8 @@ module Pod ...@@ -17,8 +17,8 @@ module Pod
# @param [Sandbox] sandbox @see #sandbox # @param [Sandbox] sandbox @see #sandbox
# #
def initialize(sandbox) def initialize(sandbox, build_configurations)
super(nil) # Recreate the project from scratch for now. super(nil, build_configurations) # Recreate the project from scratch for now.
# TODO # TODO
raise unless sandbox.is_a?(Sandbox) raise unless sandbox.is_a?(Sandbox)
@sandbox = sandbox @sandbox = sandbox
......
...@@ -283,23 +283,41 @@ module Pod ...@@ -283,23 +283,41 @@ module Pod
end end
UI = UserInterface UI = UserInterface
#---------------------------------------------------------------------------#
# Redirects cocoapods-core UI. # Redirects cocoapods-core UI.
# #
module CoreUI module CoreUI
class << self class << self
# @todo enable in CocoaPods 0.17.0 release
#
def puts(message) def puts(message)
# UI.puts message UI.puts message
end end
# @todo enable in CocoaPods 0.17.0 release
#
def warn(message) def warn(message)
# UI.warn message UI.warn message
end
end
end
end
#---------------------------------------------------------------------------#
module Xcodeproj
# Redirects xcodeproj UI.
#
module UserInterface
def self.puts(message)
::Pod::UI.puts message
end end
def self.warn(message)
::Pod::UI.warn message
end end
end end
end end
Subproject commit 0d881f354b7c482e27f9af1514c082a1f5a958c7 Subproject commit af709e4b9c9487f8f5b9dacf814021f49c505447
require File.expand_path('../../../spec_helper', __FILE__)
require 'xcodeproj'
module Pod
describe Command::Init do
it "complains if project does not exist" do
lambda { run_command('init') }.should.raise Informative
lambda { run_command('init', 'foo.xcodeproj') }.should.raise CLAide::Help
end
it "complains if wrong parameters" do
lambda { run_command('too', 'many') }.should.raise CLAide::Help
end
it "complains if more than one project exists and none is specified" do
Dir.chdir(temporary_directory) do
Xcodeproj::Project.new.save_as(temporary_directory + 'test1.xcodeproj')
Xcodeproj::Project.new.save_as(temporary_directory + 'test2.xcodeproj')
lambda { run_command('init') }.should.raise Informative
end
end
it "complains if a Podfile already exists" do
Dir.chdir(temporary_directory) do
(Pathname.pwd + 'Podfile').open('w') { |f| f << "pod 'AFNetworking'" }
Xcodeproj::Project.new.save_as(temporary_directory + 'test1.xcodeproj')
lambda { run_command('init') }.should.raise Informative
end
end
it "creates a Podfile for a project in current directory" do
Dir.chdir(temporary_directory) do
Xcodeproj::Project.new.save_as(temporary_directory + 'test1.xcodeproj')
run_command('init')
Pathname.new(temporary_directory + 'Podfile').exist?.should == true
end
end
it "creates a Podfile for a specified project" do
Dir.chdir(temporary_directory) do
Xcodeproj::Project.new.save_as(temporary_directory + 'test1.xcodeproj')
Xcodeproj::Project.new.save_as(temporary_directory + 'test2.xcodeproj')
run_command('init', 'test2.xcodeproj')
Pathname.new(temporary_directory + 'Podfile').exist?.should == true
config.podfile.nil?.should == false
end
end
it "creates a Podfile with targets from the project" do
Dir.chdir(temporary_directory) do
project = Xcodeproj::Project.new
target1 = project.new_target(:application, "AppA", :ios)
target2 = project.new_target(:application, "AppB", :ios)
project.save_as(temporary_directory + 'test.xcodeproj')
run_command('init')
config.podfile.nil?.should == false
config.podfile.target_definitions.length.should == project.targets.length + 1
config.podfile.target_definitions["AppA"].nil?.should == false
config.podfile.target_definitions["AppB"].nil?.should == false
end
end
it "includes default pods in a Podfile" do
Dir.chdir(temporary_directory) do
tmp_templates_dir = Pathname.pwd + 'templates_dir'
tmp_templates_dir.mkpath
config.stubs(:templates_dir).returns(tmp_templates_dir)
open(config.default_podfile_path, 'w') { |f| f << "pod 'AFNetworking'" }
project = Xcodeproj::Project.new
project.new_target(:application, 'AppA', :ios)
project.save_as(temporary_directory + 'test.xcodeproj')
run_command('init')
dependencies = config.podfile.target_definitions["AppA"].dependencies
dependencies.map(&:name).should == ["AFNetworking"]
end
end
it "includes default test pods in test targets in a Podfile" do
Dir.chdir(temporary_directory) do
tmp_templates_dir = Pathname.pwd + 'templates_dir'
tmp_templates_dir.mkpath
config.stubs(:templates_dir).returns(tmp_templates_dir)
open(config.default_test_podfile_path, 'w') { |f| f << "pod 'Kiwi'" }
project = Xcodeproj::Project.new
project.new_target(:application, "AppTests", :ios)
project.save_as(temporary_directory + 'test.xcodeproj')
run_command('init')
dependencies = config.podfile.target_definitions["AppTests"].dependencies
dependencies.map(&:name).should == ["Kiwi"]
end
end
it "does not include default test pods if there are no test targets" do
Dir.chdir(temporary_directory) do
tmp_templates_dir = Pathname.pwd + 'templates_dir'
tmp_templates_dir.mkpath
config.stubs(:templates_dir).returns(tmp_templates_dir)
open(config.default_test_podfile_path, 'w') { |f| f << "pod 'Kiwi'" }
project = Xcodeproj::Project.new
project.new_target(:application, "App", :ios)
project.save_as(temporary_directory + 'test.xcodeproj')
run_command('init')
config.podfile.nil?.should == false
config.podfile.dependencies.length.should == 0
end
end
end
end
...@@ -378,7 +378,14 @@ describe "Integration" do ...@@ -378,7 +378,14 @@ describe "Integration" do
#--------------------------------------# #--------------------------------------#
end describe "Pod init" do
describe "Initializes a Podfile with a single platform" do
check "init", "init_single_platform"
end
end
#--------------------------------------#
end
...@@ -17,6 +17,7 @@ module Pod ...@@ -17,6 +17,7 @@ module Pod
Command.parse(%w{ spec create }).should.be.instance_of Command::Spec::Create Command.parse(%w{ spec create }).should.be.instance_of Command::Spec::Create
Command.parse(%w{ spec lint }).should.be.instance_of Command::Spec::Lint Command.parse(%w{ spec lint }).should.be.instance_of Command::Spec::Lint
Command.parse(%w{ repo update }).should.be.instance_of Command::Repo::Update Command.parse(%w{ repo update }).should.be.instance_of Command::Repo::Update
Command.parse(%w{ init }).should.be.instance_of Command::Init
end end
end end
end end
...@@ -23,6 +23,15 @@ module Pod ...@@ -23,6 +23,15 @@ module Pod
@sut.repos_dir.should == Pathname.new("~/.cocoapods/repos").expand_path @sut.repos_dir.should == Pathname.new("~/.cocoapods/repos").expand_path
end end
it "returns the path to the templates dir" do
@sut.templates_dir.should == Pathname.new("~/.cocoapods/templates").expand_path
end
it "returns the path of the default podfiles" do
@sut.default_podfile_path.should == Pathname.new("~/.cocoapods/templates/Podfile.default").expand_path
@sut.default_test_podfile_path.should == Pathname.new("~/.cocoapods/templates/Podfile.test").expand_path
end
it "allows to specify whether the aggressive cache should be used with an environment variable" do it "allows to specify whether the aggressive cache should be used with an environment variable" do
@sut.aggressive_cache = false @sut.aggressive_cache = false
ENV['CP_AGGRESSIVE_CACHE'] = 'TRUE' ENV['CP_AGGRESSIVE_CACHE'] = 'TRUE'
......
...@@ -89,7 +89,7 @@ module Pod ...@@ -89,7 +89,7 @@ module Pod
target.user_target_uuids.should == ["A346496C14F9BE9A0080D870"] target.user_target_uuids.should == ["A346496C14F9BE9A0080D870"]
user_proj = Xcodeproj::Project.new(target.user_project_path) user_proj = Xcodeproj::Project.new(target.user_project_path)
user_proj.objects_by_uuid[target.user_target_uuids.first].name.should == 'SampleProject' user_proj.objects_by_uuid[target.user_target_uuids.first].name.should == 'SampleProject'
target.user_build_configurations.should == {"Test"=>:release, "App Store"=>:release} target.user_build_configurations.should == { "Test" => :release, "App Store" => :release }
target.platform.to_s.should == 'iOS 6.0' target.platform.to_s.should == 'iOS 6.0'
end end
...@@ -103,6 +103,12 @@ module Pod ...@@ -103,6 +103,12 @@ module Pod
target.platform.to_s.should == 'iOS 6.0' target.platform.to_s.should == 'iOS 6.0'
end end
it "returns all the configurations the user has in any of its projects and/or targets" do
target_definition = @analyzer.podfile.target_definition_list.first
target_definition.stubs(:build_configurations).returns("AdHoc" => :test)
@analyzer.analyze.all_user_build_configurations.should == { "AdHoc" => :test, "Test" => :release, "App Store" => :release }
end
#--------------------------------------# #--------------------------------------#
it "locks the version of the dependencies which did not change in the Podfile" do it "locks the version of the dependencies which did not change in the Podfile" do
...@@ -314,7 +320,6 @@ module Pod ...@@ -314,7 +320,6 @@ module Pod
configurations.should == { 'AppStore' => :release } configurations.should == { 'AppStore' => :release }
end end
it "returns the user build configurations specified in the target definition" do it "returns the user build configurations specified in the target definition" do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.build_configurations = { 'AppStore' => :release } target_definition.build_configurations = { 'AppStore' => :release }
......
...@@ -7,7 +7,7 @@ module Pod ...@@ -7,7 +7,7 @@ module Pod
@file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec') @file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@pod_target = PodTarget.new([], nil, config.sandbox) @pod_target = PodTarget.new([], nil, config.sandbox)
@pod_target.file_accessors = [@file_accessor] @pod_target.file_accessors = [@file_accessor]
@project = Project.new(config.sandbox) @project = Project.new(config.sandbox, nil)
@installer = Installer::FileReferencesInstaller.new(config.sandbox, [@pod_target], @project) @installer = Installer::FileReferencesInstaller.new(config.sandbox, [@pod_target], @project)
end end
......
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
xcodeproj 'dummy' xcodeproj 'dummy'
end end
@target_definition = @podfile.target_definitions['Pods'] @target_definition = @podfile.target_definitions['Pods']
@project = Project.new(config.sandbox) @project = Project.new(config.sandbox, nil)
config.sandbox.project = @project config.sandbox.project = @project
path_list = Sandbox::PathList.new(fixture('banana-lib')) path_list = Sandbox::PathList.new(fixture('banana-lib'))
......
...@@ -9,7 +9,8 @@ module Pod ...@@ -9,7 +9,8 @@ module Pod
xcodeproj 'dummy' xcodeproj 'dummy'
end end
@target_definition = @podfile.target_definitions['Pods'] @target_definition = @podfile.target_definitions['Pods']
@project = Project.new(config.sandbox) user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug }
@project = Project.new(config.sandbox, user_build_configurations)
config.sandbox.project = @project config.sandbox.project = @project
path_list = Sandbox::PathList.new(fixture('banana-lib')) path_list = Sandbox::PathList.new(fixture('banana-lib'))
...@@ -19,7 +20,7 @@ module Pod ...@@ -19,7 +20,7 @@ module Pod
@pod_target = PodTarget.new([@spec], @target_definition, config.sandbox) @pod_target = PodTarget.new([@spec], @target_definition, config.sandbox)
@pod_target.stubs(:platform).returns(Platform.new(:ios, '6.0')) @pod_target.stubs(:platform).returns(Platform.new(:ios, '6.0'))
@pod_target.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug } @pod_target.user_build_configurations = user_build_configurations
@pod_target.file_accessors = [file_accessor] @pod_target.file_accessors = [file_accessor]
@installer = Installer::PodTargetInstaller.new(config.sandbox, @pod_target) @installer = Installer::PodTargetInstaller.new(config.sandbox, @pod_target)
......
...@@ -9,7 +9,7 @@ module Pod ...@@ -9,7 +9,7 @@ module Pod
xcodeproj 'dummy' xcodeproj 'dummy'
end end
@target_definition = @podfile.target_definitions['Pods'] @target_definition = @podfile.target_definitions['Pods']
@project = Project.new(config.sandbox) @project = Project.new(config.sandbox, nil)
config.sandbox.project = @project config.sandbox.project = @project
path_list = Sandbox::PathList.new(fixture('banana-lib')) path_list = Sandbox::PathList.new(fixture('banana-lib'))
......
...@@ -16,7 +16,7 @@ module Pod ...@@ -16,7 +16,7 @@ module Pod
end end
end end
config.sandbox.project = Project.new(config.sandbox) config.sandbox.project = Project.new(config.sandbox, nil)
Xcodeproj::Project.new.save_as(config.sandbox.project_path) Xcodeproj::Project.new.save_as(config.sandbox.project_path)
@library = AggregateTarget.new(@podfile.target_definitions['Pods'], config.sandbox) @library = AggregateTarget.new(@podfile.target_definitions['Pods'], config.sandbox)
@library.client_root = sample_project_path.dirname @library.client_root = sample_project_path.dirname
......
...@@ -16,7 +16,7 @@ end ...@@ -16,7 +16,7 @@ end
def generate_podfile(pods = ['JSONKit']) def generate_podfile(pods = ['JSONKit'])
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
platform :ios platform :ios
xcodeproj 'SampleProject/SampleProject' xcodeproj SpecHelper.fixture('SampleProject/SampleProject'), 'Test' => :debug, 'App Store' => :release
pods.each { |name| pod name } pods.each { |name| pod name }
end end
end end
...@@ -112,7 +112,7 @@ module Pod ...@@ -112,7 +112,7 @@ module Pod
@installer.pod_targets.map(&:name).sort.should == ['Pods-JSONKit'] @installer.pod_targets.map(&:name).sort.should == ['Pods-JSONKit']
end end
it "configures the analizer to use update mode if appropriate" do it "configures the analyzer to use update mode if appropriate" do
@installer.update_mode = true @installer.update_mode = true
Installer::Analyzer.any_instance.expects(:update_mode=).with(true) Installer::Analyzer.any_instance.expects(:update_mode=).with(true)
@installer.send(:analyze) @installer.send(:analyze)
...@@ -217,14 +217,37 @@ module Pod ...@@ -217,14 +217,37 @@ module Pod
describe "#prepare_pods_project" do describe "#prepare_pods_project" do
it "creates the Pods project" do before do
@installer.stubs(:aggregate_targets).returns([]) @installer.stubs(:aggregate_targets).returns([])
end
it "creates build configurations for all of the user's targets" do
config.integrate_targets = true
@installer.send(:analyze)
@installer.send(:prepare_pods_project)
@installer.pods_project.build_configurations.map(&:name).sort.should == ['App Store', 'Debug', 'Release', 'Test']
end
it "sets STRIP_INSTALLED_PRODUCT to NO for all configurations for the whole project" do
config.integrate_targets = true
@installer.send(:analyze)
@installer.send(:prepare_pods_project)
@installer.pods_project.build_settings('Debug')["STRIP_INSTALLED_PRODUCT"].should == "NO"
@installer.pods_project.build_settings('Test')["STRIP_INSTALLED_PRODUCT"].should == "NO"
@installer.pods_project.build_settings('Release')["STRIP_INSTALLED_PRODUCT"].should == "NO"
@installer.pods_project.build_settings('App Store')["STRIP_INSTALLED_PRODUCT"].should == "NO"
end
before do
@installer.stubs(:analysis_result).returns(stub(:all_user_build_configurations => {}))
end
it "creates the Pods project" do
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
@installer.pods_project.class.should == Pod::Project @installer.pods_project.class.should == Pod::Project
end end
it "adds the Podfile to the Pods project" do it "adds the Podfile to the Pods project" do
@installer.stubs(:aggregate_targets).returns([])
config.stubs(:podfile_path).returns(Pathname.new('/Podfile')) config.stubs(:podfile_path).returns(Pathname.new('/Podfile'))
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
@installer.pods_project['Podfile'].should.be.not.nil @installer.pods_project['Podfile'].should.be.not.nil
...@@ -243,6 +266,7 @@ module Pod ...@@ -243,6 +266,7 @@ module Pod
build_setting["IPHONEOS_DEPLOYMENT_TARGET"].should == '6.0' build_setting["IPHONEOS_DEPLOYMENT_TARGET"].should == '6.0'
end end
end end
end end
#--------------------------------------# #--------------------------------------#
...@@ -308,6 +332,7 @@ module Pod ...@@ -308,6 +332,7 @@ module Pod
before do before do
@installer.stubs(:aggregate_targets).returns([]) @installer.stubs(:aggregate_targets).returns([])
@installer.stubs(:analysis_result).returns(stub(:all_user_build_configurations => {}))
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
end end
......
...@@ -4,7 +4,7 @@ module Pod ...@@ -4,7 +4,7 @@ module Pod
describe Project do describe Project do
before do before do
@project = Project.new(config.sandbox) @project = Project.new(config.sandbox, nil)
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
......
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