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
# 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 '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 'claide', :git => 'https://github.com/CocoaPods/CLAide.git', :branch => 'master'
......
......@@ -17,8 +17,8 @@ GIT
GIT
remote: https://github.com/CocoaPods/Xcodeproj.git
revision: 9d2f8cef72466cb3f155a9a5a3cfb12c94802656
branch: master
revision: 00c89436cd64b9e26db60fcf8ca99dbd62b01b58
branch: paths-refactor
specs:
xcodeproj (0.9.0)
activesupport (~> 3.2.13)
......
......@@ -36,7 +36,7 @@ module Pod
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)
@xcode_project = Xcodeproj::Project.open(@project_path)
end
def run
......
......@@ -169,7 +169,7 @@ module Pod
if config.integrate_targets?
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)
target.user_project_path = project_path
......@@ -449,7 +449,7 @@ module Pod
podfile.target_definition_list.each do |target_definition|
if config.integrate_targets?
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)
platform = compute_platform_for_target_definition(target_definition, targets)
else
......
......@@ -66,14 +66,14 @@ module Pod
# other TargetIntegrators might have modified it.
#
def user_project
@user_project ||= Xcodeproj::Project.new(target.user_project_path)
@user_project ||= Xcodeproj::Project.open(target.user_project_path)
end
# Read the pods project from the disk to ensure that it is up to date as
# other TargetIntegrators might have modified it.
#
def pods_project
@pods_project ||= Xcodeproj::Project.new(target.sandbox.project_path)
@pods_project ||= Xcodeproj::Project.open(target.sandbox.project_path)
end
# @return [String] a string representation suitable for debugging.
......
......@@ -18,21 +18,15 @@ module Pod
# @param [Sandbox] sandbox @see #sandbox
#
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
raise unless sandbox.is_a?(Sandbox)
@sandbox = sandbox
@path = sandbox.project_path
@support_files_group = new_group('Targets Support Files')
@refs_by_absolute_path = {}
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.
#
def root
......
......@@ -17,8 +17,8 @@ module Pod
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')
Xcodeproj::Project.new('path').save_as(temporary_directory + 'test1.xcodeproj')
Xcodeproj::Project.new('path').save_as(temporary_directory + 'test2.xcodeproj')
lambda { run_command('init') }.should.raise Informative
end
end
......@@ -26,14 +26,14 @@ module Pod
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')
Xcodeproj::Project.new('path').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')
Xcodeproj::Project.new('path').save_as(temporary_directory + 'test1.xcodeproj')
run_command('init')
Pathname.new(temporary_directory + 'Podfile').exist?.should == true
end
......@@ -41,8 +41,8 @@ module Pod
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')
Xcodeproj::Project.new('path').save_as(temporary_directory + 'test1.xcodeproj')
Xcodeproj::Project.new('path').save_as(temporary_directory + 'test2.xcodeproj')
run_command('init', 'test2.xcodeproj')
Pathname.new(temporary_directory + 'Podfile').exist?.should == true
config.podfile.nil?.should == false
......@@ -51,7 +51,7 @@ module Pod
it "creates a Podfile with targets from the project" do
Dir.chdir(temporary_directory) do
project = Xcodeproj::Project.new
project = Xcodeproj::Project.new('path')
target1 = project.new_target(:application, "AppA", :ios)
target2 = project.new_target(:application, "AppB", :ios)
project.save_as(temporary_directory + 'test.xcodeproj')
......@@ -73,7 +73,7 @@ module Pod
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.save_as(temporary_directory + 'test.xcodeproj')
......@@ -92,7 +92,7 @@ module Pod
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.save_as(temporary_directory + 'test.xcodeproj')
......@@ -111,7 +111,7 @@ module Pod
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.save_as(temporary_directory + 'test.xcodeproj')
......
......@@ -111,7 +111,7 @@ end
#
def run_post_execution_actions(folder)
Dir.glob("#{TMP_DIR + folder}/**/*.xcodeproj") do |project_path|
xcodeproj = Xcodeproj::Project.new(project_path)
xcodeproj = Xcodeproj::Project.open(project_path)
require 'yaml'
pretty_print = xcodeproj.pretty_print
sections = []
......@@ -225,8 +225,8 @@ end
# @param [Pathname] produced @see #yaml_should_match
#
# def xcodeproj_should_match(expected, produced)
# expected_proj = Xcodeproj::Project.new(expected + '..')
# produced_proj = Xcodeproj::Project.new(produced + '..')
# expected_proj = Xcodeproj::Project.open(expected + '..')
# produced_proj = Xcodeproj::Project.open(produced + '..')
# diff = produced_proj.to_tree_hash.recursive_diff(expected_proj.to_tree_hash, "#produced#", "#reference#")
# desc = "Project comparison error `#{expected}`"
# if diff
......
......@@ -87,7 +87,7 @@ module Pod
target.user_project_path.to_s.should.include 'SampleProject/SampleProject'
target.client_root.to_s.should.include 'SampleProject'
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'
target.user_build_configurations.should == { "Test" => :release, "App Store" => :release }
target.platform.to_s.should == 'iOS 6.0'
......@@ -231,7 +231,7 @@ module Pod
it "does not take aggregate targets into consideration" do
aggregate_class = Xcodeproj::Project::Object::PBXAggregateTarget
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)
native_targets = @analyzer.send(:native_targets, sample_project).map(&:class)
......@@ -246,7 +246,7 @@ module Pod
it "returns the targets specified in the target definition" do
target_definition = Podfile::TargetDefinition.new(:default, nil)
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, 'UserTarget', :ios)
......@@ -257,7 +257,7 @@ module Pod
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.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.message.should.match /Unable to find the targets/
......@@ -265,7 +265,7 @@ module Pod
it "returns the target with the same name of the target definition" do
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, 'UserTarget', :ios)
......@@ -275,8 +275,7 @@ module Pod
it "raises if the name of the target definition does not match any file" do
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.message.should.match /Unable to find a target named/
end
......@@ -284,7 +283,7 @@ module Pod
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.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, 'UserTarget', :ios)
......@@ -294,8 +293,7 @@ module Pod
it "raises if the default target definition cannot be linked because there are no user targets" do
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.message.should.match /Unable to find a target/
end
......@@ -307,7 +305,7 @@ module Pod
describe "#compute_user_build_configurations" 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)
configuration = user_project.new(Xcodeproj::Project::Object::XCBuildConfiguration)
configuration.name = 'AppStore'
......@@ -345,7 +343,7 @@ module Pod
end
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)
configuration = target.build_configuration_list.build_configurations.first
configuration.build_settings = {
......@@ -361,7 +359,7 @@ module Pod
end
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)
configuration1 = target1.build_configuration_list.build_configurations.first
configuration1.build_settings = {
......@@ -383,7 +381,7 @@ module Pod
end
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)
configuration1 = target1.build_configuration_list.build_configurations.first
configuration1.build_settings = {
......
......@@ -12,8 +12,8 @@ module Pod
#
before do
sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
@sample_project = Xcodeproj::Project.new sample_project_path
Xcodeproj::Project.new.save_as(config.sandbox.project_path)
@sample_project = Xcodeproj::Project.open(sample_project_path)
Xcodeproj::Project.new('path').save_as(config.sandbox.project_path)
@target = @sample_project.targets.first
target_definition = Podfile::TargetDefinition.new('Pods', nil)
target_definition.link_with_first_target = true
......
......@@ -17,7 +17,7 @@ module Pod
end
end
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.client_root = sample_project_path.dirname
@library.user_project_path = sample_project_path
......@@ -39,7 +39,7 @@ module Pod
it "integrates the user targets" do
@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.frameworks_build_phase.files.map(&:display_name).should.include('libPods.a')
end
......
......@@ -398,7 +398,7 @@ module Pod
pod_target = PodTarget.new([spec], lib_definition, config.sandbox)
target.pod_targets = [pod_target]
project = Xcodeproj::Project.new
project = Xcodeproj::Project.new('path')
pods_target = project.new_target(:static_library, target.name, :ios)
native_target = project.new_target(:static_library, pod_target.name, :ios)
@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