Skip to content

Commit

Permalink
Add static libraries to root of project if no Frameworks group exists.
Browse files Browse the repository at this point in the history
…#431

Better to allow the user to choose how to organize her project.
  • Loading branch information
alloy committed Aug 10, 2012
1 parent 4b1f0c3 commit 8f0b491
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
6 changes: 2 additions & 4 deletions lib/cocoapods/installer/user_project_integrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,8 @@ def add_xcconfig_base_configuration
end

def add_pods_library
framework_group = user_project.group("Frameworks")
raise Informative, "Cannot add pod library to project. Please check if the project have a 'Frameworks' group in the root of the project." unless framework_group

pods_library = framework_group.files.new_static_library(@target_definition.label)
group = user_project.group("Frameworks") || user_project.main_group
pods_library = group.files.new_static_library(@target_definition.label)
targets.each do |target|
target.frameworks_build_phases.each { |build_phase| build_phase << pods_library }
end
Expand Down
31 changes: 23 additions & 8 deletions spec/functional/user_project_integrator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
describe Pod::Installer::UserProjectIntegrator do
extend SpecHelper::TemporaryDirectory

def integrate!
@integrator = Pod::Installer::UserProjectIntegrator.new(@podfile)
@integrator.integrate!
@sample_project = Xcodeproj::Project.new(@sample_project_path)
end

before do
config.silent = true
@sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
Expand All @@ -23,12 +29,26 @@
end
end

@integrator = Pod::Installer::UserProjectIntegrator.new(@podfile)
@integrator.integrate!

@sample_project = Xcodeproj::Project.new(@sample_project_path)
end

it 'adds references to the Pods static libraries to the root of the project if the Frameworks group does not exist' do
@sample_project.group('Frameworks').destroy
@sample_project.save_as(@sample_project_path)
integrate!
@sample_project.main_group.files.where(:name => "libPods.a").should.not == nil
@sample_project.main_group.files.where(:name => "libPods-test_runner.a").should.not == nil
end

before do
integrate!
end

it 'adds references to the Pods static libraries to the Frameworks group' do
@sample_project.group('Frameworks').files.where(:name => "libPods.a").should.not == nil
@sample_project.group('Frameworks').files.where(:name => "libPods-test_runner.a").should.not == nil
end

it 'creates a workspace with a name matching the project' do
workspace_path = @sample_project_path.dirname + "SampleProject.xcworkspace"
workspace_path.should.exist
Expand All @@ -54,11 +74,6 @@
end
end

it 'adds references to the Pods static libraries' do
@sample_project.files.where(:name => "libPods.a").should.not == nil
@sample_project.files.where(:name => "libPods-test_runner.a").should.not == nil
end

it 'adds the libPods static library to the "Link binary with libraries" build phase of each target' do
@podfile.target_definitions.each do |_, definition|
target = @sample_project.targets.where(:name => definition.link_with.first)
Expand Down

0 comments on commit 8f0b491

Please sign in to comment.