Commit 3a9f5197 authored by Fabio Pelosin's avatar Fabio Pelosin

[Xcodeproj] Adapt for Project initialization changes

parent c95e3cf4
...@@ -9,7 +9,7 @@ group :development do ...@@ -9,7 +9,7 @@ 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 # 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 => 'paths-refactor'
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'
gem 'claide', :git => 'https://github.com/CocoaPods/CLAide.git', :branch => 'master' gem 'claide', :git => 'https://github.com/CocoaPods/CLAide.git', :branch => 'master'
......
...@@ -17,8 +17,8 @@ GIT ...@@ -17,8 +17,8 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Xcodeproj.git remote: https://github.com/CocoaPods/Xcodeproj.git
revision: 9d2f8cef72466cb3f155a9a5a3cfb12c94802656 revision: 00c89436cd64b9e26db60fcf8ca99dbd62b01b58
branch: master branch: paths-refactor
specs: specs:
xcodeproj (0.9.0) xcodeproj (0.9.0)
activesupport (~> 3.2.13) activesupport (~> 3.2.13)
......
...@@ -36,7 +36,7 @@ module Pod ...@@ -36,7 +36,7 @@ module Pod
raise Informative, "Multiple xcode projects found, please specify one" unless @project_paths.length == 1 raise Informative, "Multiple xcode projects found, please specify one" unless @project_paths.length == 1
@project_path = @project_paths.first @project_path = @project_paths.first
end end
@xcode_project = Xcodeproj::Project.new(@project_path) @xcode_project = Xcodeproj::Project.open(@project_path)
end end
def run def run
......
...@@ -169,7 +169,7 @@ module Pod ...@@ -169,7 +169,7 @@ module Pod
if config.integrate_targets? if config.integrate_targets?
project_path = compute_user_project_path(target_definition) project_path = compute_user_project_path(target_definition)
user_project = Xcodeproj::Project.new(project_path) user_project = Xcodeproj::Project.open(project_path)
native_targets = compute_user_project_targets(target_definition, user_project) native_targets = compute_user_project_targets(target_definition, user_project)
target.user_project_path = project_path target.user_project_path = project_path
...@@ -449,7 +449,7 @@ module Pod ...@@ -449,7 +449,7 @@ module Pod
podfile.target_definition_list.each do |target_definition| podfile.target_definition_list.each do |target_definition|
if config.integrate_targets? if config.integrate_targets?
project_path = compute_user_project_path(target_definition) project_path = compute_user_project_path(target_definition)
user_project = Xcodeproj::Project.new(project_path) user_project = Xcodeproj::Project.open(project_path)
targets = compute_user_project_targets(target_definition, user_project) targets = compute_user_project_targets(target_definition, user_project)
platform = compute_platform_for_target_definition(target_definition, targets) platform = compute_platform_for_target_definition(target_definition, targets)
else else
......
...@@ -66,14 +66,14 @@ module Pod ...@@ -66,14 +66,14 @@ module Pod
# other TargetIntegrators might have modified it. # other TargetIntegrators might have modified it.
# #
def user_project def user_project
@user_project ||= Xcodeproj::Project.new(target.user_project_path) @user_project ||= Xcodeproj::Project.open(target.user_project_path)
end end
# Read the pods project from the disk to ensure that it is up to date as # Read the pods project from the disk to ensure that it is up to date as
# other TargetIntegrators might have modified it. # other TargetIntegrators might have modified it.
# #
def pods_project def pods_project
@pods_project ||= Xcodeproj::Project.new(target.sandbox.project_path) @pods_project ||= Xcodeproj::Project.open(target.sandbox.project_path)
end end
# @return [String] a string representation suitable for debugging. # @return [String] a string representation suitable for debugging.
......
...@@ -18,21 +18,15 @@ module Pod ...@@ -18,21 +18,15 @@ module Pod
# @param [Sandbox] sandbox @see #sandbox # @param [Sandbox] sandbox @see #sandbox
# #
def initialize(sandbox, build_configurations) def initialize(sandbox, build_configurations)
super(nil, build_configurations) # Recreate the project from scratch for now. super(sandbox.project_path, 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
@path = sandbox.project_path
@support_files_group = new_group('Targets Support Files') @support_files_group = new_group('Targets Support Files')
@refs_by_absolute_path = {} @refs_by_absolute_path = {}
end end
# @return [Pathname] the path of the xcodeproj file which stores the
# project.
#
attr_reader :path
# @return [Pathname] the directory where the project is stored. # @return [Pathname] the directory where the project is stored.
# #
def root def root
......
...@@ -17,8 +17,8 @@ module Pod ...@@ -17,8 +17,8 @@ module Pod
it "complains if more than one project exists and none is specified" do it "complains if more than one project exists and none is specified" do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
Xcodeproj::Project.new.save_as(temporary_directory + 'test1.xcodeproj') Xcodeproj::Project.new('path').save_as(temporary_directory + 'test1.xcodeproj')
Xcodeproj::Project.new.save_as(temporary_directory + 'test2.xcodeproj') Xcodeproj::Project.new('path').save_as(temporary_directory + 'test2.xcodeproj')
lambda { run_command('init') }.should.raise Informative lambda { run_command('init') }.should.raise Informative
end end
end end
...@@ -26,14 +26,14 @@ module Pod ...@@ -26,14 +26,14 @@ module Pod
it "complains if a Podfile already exists" do it "complains if a Podfile already exists" do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
(Pathname.pwd + 'Podfile').open('w') { |f| f << "pod 'AFNetworking'" } (Pathname.pwd + 'Podfile').open('w') { |f| f << "pod 'AFNetworking'" }
Xcodeproj::Project.new.save_as(temporary_directory + 'test1.xcodeproj') Xcodeproj::Project.new('path').save_as(temporary_directory + 'test1.xcodeproj')
lambda { run_command('init') }.should.raise Informative lambda { run_command('init') }.should.raise Informative
end end
end end
it "creates a Podfile for a project in current directory" do it "creates a Podfile for a project in current directory" do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
Xcodeproj::Project.new.save_as(temporary_directory + 'test1.xcodeproj') Xcodeproj::Project.new('path').save_as(temporary_directory + 'test1.xcodeproj')
run_command('init') run_command('init')
Pathname.new(temporary_directory + 'Podfile').exist?.should == true Pathname.new(temporary_directory + 'Podfile').exist?.should == true
end end
...@@ -41,8 +41,8 @@ module Pod ...@@ -41,8 +41,8 @@ module Pod
it "creates a Podfile for a specified project" do it "creates a Podfile for a specified project" do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
Xcodeproj::Project.new.save_as(temporary_directory + 'test1.xcodeproj') Xcodeproj::Project.new('path').save_as(temporary_directory + 'test1.xcodeproj')
Xcodeproj::Project.new.save_as(temporary_directory + 'test2.xcodeproj') Xcodeproj::Project.new('path').save_as(temporary_directory + 'test2.xcodeproj')
run_command('init', 'test2.xcodeproj') run_command('init', 'test2.xcodeproj')
Pathname.new(temporary_directory + 'Podfile').exist?.should == true Pathname.new(temporary_directory + 'Podfile').exist?.should == true
config.podfile.nil?.should == false config.podfile.nil?.should == false
...@@ -51,7 +51,7 @@ module Pod ...@@ -51,7 +51,7 @@ module Pod
it "creates a Podfile with targets from the project" do it "creates a Podfile with targets from the project" do
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
project = Xcodeproj::Project.new project = Xcodeproj::Project.new('path')
target1 = project.new_target(:application, "AppA", :ios) target1 = project.new_target(:application, "AppA", :ios)
target2 = project.new_target(:application, "AppB", :ios) target2 = project.new_target(:application, "AppB", :ios)
project.save_as(temporary_directory + 'test.xcodeproj') project.save_as(temporary_directory + 'test.xcodeproj')
...@@ -73,7 +73,7 @@ module Pod ...@@ -73,7 +73,7 @@ module Pod
open(config.default_podfile_path, 'w') { |f| f << "pod 'AFNetworking'" } open(config.default_podfile_path, 'w') { |f| f << "pod 'AFNetworking'" }
project = Xcodeproj::Project.new project = Xcodeproj::Project.new('path')
project.new_target(:application, 'AppA', :ios) project.new_target(:application, 'AppA', :ios)
project.save_as(temporary_directory + 'test.xcodeproj') project.save_as(temporary_directory + 'test.xcodeproj')
...@@ -92,7 +92,7 @@ module Pod ...@@ -92,7 +92,7 @@ module Pod
open(config.default_test_podfile_path, 'w') { |f| f << "pod 'Kiwi'" } open(config.default_test_podfile_path, 'w') { |f| f << "pod 'Kiwi'" }
project = Xcodeproj::Project.new project = Xcodeproj::Project.new('path')
project.new_target(:application, "AppTests", :ios) project.new_target(:application, "AppTests", :ios)
project.save_as(temporary_directory + 'test.xcodeproj') project.save_as(temporary_directory + 'test.xcodeproj')
...@@ -111,7 +111,7 @@ module Pod ...@@ -111,7 +111,7 @@ module Pod
open(config.default_test_podfile_path, 'w') { |f| f << "pod 'Kiwi'" } open(config.default_test_podfile_path, 'w') { |f| f << "pod 'Kiwi'" }
project = Xcodeproj::Project.new project = Xcodeproj::Project.new('path')
project.new_target(:application, "App", :ios) project.new_target(:application, "App", :ios)
project.save_as(temporary_directory + 'test.xcodeproj') project.save_as(temporary_directory + 'test.xcodeproj')
......
...@@ -111,7 +111,7 @@ end ...@@ -111,7 +111,7 @@ end
# #
def run_post_execution_actions(folder) def run_post_execution_actions(folder)
Dir.glob("#{TMP_DIR + folder}/**/*.xcodeproj") do |project_path| Dir.glob("#{TMP_DIR + folder}/**/*.xcodeproj") do |project_path|
xcodeproj = Xcodeproj::Project.new(project_path) xcodeproj = Xcodeproj::Project.open(project_path)
require 'yaml' require 'yaml'
pretty_print = xcodeproj.pretty_print pretty_print = xcodeproj.pretty_print
sections = [] sections = []
...@@ -225,8 +225,8 @@ end ...@@ -225,8 +225,8 @@ end
# @param [Pathname] produced @see #yaml_should_match # @param [Pathname] produced @see #yaml_should_match
# #
# def xcodeproj_should_match(expected, produced) # def xcodeproj_should_match(expected, produced)
# expected_proj = Xcodeproj::Project.new(expected + '..') # expected_proj = Xcodeproj::Project.open(expected + '..')
# produced_proj = Xcodeproj::Project.new(produced + '..') # produced_proj = Xcodeproj::Project.open(produced + '..')
# diff = produced_proj.to_tree_hash.recursive_diff(expected_proj.to_tree_hash, "#produced#", "#reference#") # diff = produced_proj.to_tree_hash.recursive_diff(expected_proj.to_tree_hash, "#produced#", "#reference#")
# desc = "Project comparison error `#{expected}`" # desc = "Project comparison error `#{expected}`"
# if diff # if diff
......
...@@ -87,7 +87,7 @@ module Pod ...@@ -87,7 +87,7 @@ module Pod
target.user_project_path.to_s.should.include 'SampleProject/SampleProject' target.user_project_path.to_s.should.include 'SampleProject/SampleProject'
target.client_root.to_s.should.include 'SampleProject' target.client_root.to_s.should.include 'SampleProject'
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.open(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'
...@@ -231,7 +231,7 @@ module Pod ...@@ -231,7 +231,7 @@ module Pod
it "does not take aggregate targets into consideration" do it "does not take aggregate targets into consideration" do
aggregate_class = Xcodeproj::Project::Object::PBXAggregateTarget aggregate_class = Xcodeproj::Project::Object::PBXAggregateTarget
sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject') sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
sample_project = Xcodeproj::Project.new(sample_project_path) sample_project = Xcodeproj::Project.open(sample_project_path)
sample_project.targets.map(&:class).should.include(aggregate_class) sample_project.targets.map(&:class).should.include(aggregate_class)
native_targets = @analyzer.send(:native_targets, sample_project).map(&:class) native_targets = @analyzer.send(:native_targets, sample_project).map(&:class)
...@@ -246,7 +246,7 @@ module Pod ...@@ -246,7 +246,7 @@ module Pod
it "returns the targets specified in the target definition" do it "returns the targets specified in the target definition" do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.link_with = ['UserTarget'] target_definition.link_with = ['UserTarget']
user_project = Xcodeproj::Project.new user_project = Xcodeproj::Project.new('path')
user_project.new_target(:application, 'FirstTarget', :ios) user_project.new_target(:application, 'FirstTarget', :ios)
user_project.new_target(:application, 'UserTarget', :ios) user_project.new_target(:application, 'UserTarget', :ios)
...@@ -257,7 +257,7 @@ module Pod ...@@ -257,7 +257,7 @@ module Pod
it "raises if it is unable to find the targets specified by the target definition" do it "raises if it is unable to find the targets specified by the target definition" do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.link_with = ['UserTarget'] target_definition.link_with = ['UserTarget']
user_project = Xcodeproj::Project.new user_project = Xcodeproj::Project.new('path')
e = lambda { @analyzer.send(:compute_user_project_targets, target_definition, user_project) }.should.raise Informative e = lambda { @analyzer.send(:compute_user_project_targets, target_definition, user_project) }.should.raise Informative
e.message.should.match /Unable to find the targets/ e.message.should.match /Unable to find the targets/
...@@ -265,7 +265,7 @@ module Pod ...@@ -265,7 +265,7 @@ module Pod
it "returns the target with the same name of the target definition" do it "returns the target with the same name of the target definition" do
target_definition = Podfile::TargetDefinition.new('UserTarget', nil) target_definition = Podfile::TargetDefinition.new('UserTarget', nil)
user_project = Xcodeproj::Project.new user_project = Xcodeproj::Project.new('path')
user_project.new_target(:application, 'FirstTarget', :ios) user_project.new_target(:application, 'FirstTarget', :ios)
user_project.new_target(:application, 'UserTarget', :ios) user_project.new_target(:application, 'UserTarget', :ios)
...@@ -275,8 +275,7 @@ module Pod ...@@ -275,8 +275,7 @@ module Pod
it "raises if the name of the target definition does not match any file" do it "raises if the name of the target definition does not match any file" do
target_definition = Podfile::TargetDefinition.new('UserTarget', nil) target_definition = Podfile::TargetDefinition.new('UserTarget', nil)
user_project = Xcodeproj::Project.new user_project = Xcodeproj::Project.new('path')
e = lambda { @analyzer.send(:compute_user_project_targets, target_definition, user_project) }.should.raise Informative e = lambda { @analyzer.send(:compute_user_project_targets, target_definition, user_project) }.should.raise Informative
e.message.should.match /Unable to find a target named/ e.message.should.match /Unable to find a target named/
end end
...@@ -284,7 +283,7 @@ module Pod ...@@ -284,7 +283,7 @@ module Pod
it "returns the first target of the project if the target definition is named default" do it "returns the first target of the project if the target definition is named default" do
target_definition = Podfile::TargetDefinition.new('Pods', nil) target_definition = Podfile::TargetDefinition.new('Pods', nil)
target_definition.link_with_first_target = true target_definition.link_with_first_target = true
user_project = Xcodeproj::Project.new user_project = Xcodeproj::Project.new('path')
user_project.new_target(:application, 'FirstTarget', :ios) user_project.new_target(:application, 'FirstTarget', :ios)
user_project.new_target(:application, 'UserTarget', :ios) user_project.new_target(:application, 'UserTarget', :ios)
...@@ -294,8 +293,7 @@ module Pod ...@@ -294,8 +293,7 @@ module Pod
it "raises if the default target definition cannot be linked because there are no user targets" do it "raises if the default target definition cannot be linked because there are no user targets" do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
user_project = Xcodeproj::Project.new user_project = Xcodeproj::Project.new('path')
e = lambda { @analyzer.send(:compute_user_project_targets, target_definition, user_project) }.should.raise Informative e = lambda { @analyzer.send(:compute_user_project_targets, target_definition, user_project) }.should.raise Informative
e.message.should.match /Unable to find a target/ e.message.should.match /Unable to find a target/
end end
...@@ -307,7 +305,7 @@ module Pod ...@@ -307,7 +305,7 @@ module Pod
describe "#compute_user_build_configurations" do describe "#compute_user_build_configurations" do
it "returns the user build configurations of the user targets" do it "returns the user build configurations of the user targets" do
user_project = Xcodeproj::Project.new user_project = Xcodeproj::Project.new('path')
target = user_project.new_target(:application, 'Target', :ios) target = user_project.new_target(:application, 'Target', :ios)
configuration = user_project.new(Xcodeproj::Project::Object::XCBuildConfiguration) configuration = user_project.new(Xcodeproj::Project::Object::XCBuildConfiguration)
configuration.name = 'AppStore' configuration.name = 'AppStore'
...@@ -345,7 +343,7 @@ module Pod ...@@ -345,7 +343,7 @@ module Pod
end end
it "infers the platform from the user targets" do it "infers the platform from the user targets" do
user_project = Xcodeproj::Project.new user_project = Xcodeproj::Project.new('path')
target = user_project.new_target(:application, 'Target', :ios) target = user_project.new_target(:application, 'Target', :ios)
configuration = target.build_configuration_list.build_configurations.first configuration = target.build_configuration_list.build_configurations.first
configuration.build_settings = { configuration.build_settings = {
...@@ -361,7 +359,7 @@ module Pod ...@@ -361,7 +359,7 @@ module Pod
end end
it "uses the lowest deployment target of the user targets if inferring the platform" do it "uses the lowest deployment target of the user targets if inferring the platform" do
user_project = Xcodeproj::Project.new user_project = Xcodeproj::Project.new('path')
target1 = user_project.new_target(:application, 'Target', :ios) target1 = user_project.new_target(:application, 'Target', :ios)
configuration1 = target1.build_configuration_list.build_configurations.first configuration1 = target1.build_configuration_list.build_configurations.first
configuration1.build_settings = { configuration1.build_settings = {
...@@ -383,7 +381,7 @@ module Pod ...@@ -383,7 +381,7 @@ module Pod
end end
it "raises if the user targets have a different platform" do it "raises if the user targets have a different platform" do
user_project = Xcodeproj::Project.new user_project = Xcodeproj::Project.new('path')
target1 = user_project.new_target(:application, 'Target', :ios) target1 = user_project.new_target(:application, 'Target', :ios)
configuration1 = target1.build_configuration_list.build_configurations.first configuration1 = target1.build_configuration_list.build_configurations.first
configuration1.build_settings = { configuration1.build_settings = {
......
...@@ -12,8 +12,8 @@ module Pod ...@@ -12,8 +12,8 @@ module Pod
# #
before do before do
sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject') sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
@sample_project = Xcodeproj::Project.new sample_project_path @sample_project = Xcodeproj::Project.open(sample_project_path)
Xcodeproj::Project.new.save_as(config.sandbox.project_path) Xcodeproj::Project.new('path').save_as(config.sandbox.project_path)
@target = @sample_project.targets.first @target = @sample_project.targets.first
target_definition = Podfile::TargetDefinition.new('Pods', nil) target_definition = Podfile::TargetDefinition.new('Pods', nil)
target_definition.link_with_first_target = true target_definition.link_with_first_target = true
......
...@@ -17,7 +17,7 @@ module Pod ...@@ -17,7 +17,7 @@ module Pod
end end
end end
config.sandbox.project = Project.new(config.sandbox, nil) config.sandbox.project = Project.new(config.sandbox, nil)
Xcodeproj::Project.new.save_as(config.sandbox.project_path) Xcodeproj::Project.new('path').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
@library.user_project_path = sample_project_path @library.user_project_path = sample_project_path
...@@ -39,7 +39,7 @@ module Pod ...@@ -39,7 +39,7 @@ module Pod
it "integrates the user targets" do it "integrates the user targets" do
@integrator.integrate! @integrator.integrate!
user_project = Xcodeproj::Project.new(@sample_project_path) user_project = Xcodeproj::Project.open(@sample_project_path)
target = user_project.objects_by_uuid[@library.user_target_uuids.first] target = user_project.objects_by_uuid[@library.user_target_uuids.first]
target.frameworks_build_phase.files.map(&:display_name).should.include('libPods.a') target.frameworks_build_phase.files.map(&:display_name).should.include('libPods.a')
end end
......
...@@ -398,7 +398,7 @@ module Pod ...@@ -398,7 +398,7 @@ module Pod
pod_target = PodTarget.new([spec], lib_definition, config.sandbox) pod_target = PodTarget.new([spec], lib_definition, config.sandbox)
target.pod_targets = [pod_target] target.pod_targets = [pod_target]
project = Xcodeproj::Project.new project = Xcodeproj::Project.new('path')
pods_target = project.new_target(:static_library, target.name, :ios) pods_target = project.new_target(:static_library, target.name, :ios)
native_target = project.new_target(:static_library, pod_target.name, :ios) native_target = project.new_target(:static_library, pod_target.name, :ios)
@installer.stubs(:pods_project).returns(project) @installer.stubs(:pods_project).returns(project)
......
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