Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I specify multiple targets and projects in my podfile for my Xcode project?

I have one workspace that contains 3 projects (Project1, Project2), which Project1 contains 2 targets (Target1, Target2), and Project2 contains 1 target (target3). And the directory structure looks like the diagram below.

How do I setup Podfile so every target has the pod 'RestKit'?

I don't know what 'link_with' and Please write me the podfile and explain to me, thank you a lot.

    MyApp
|
+-- MyApp.xcworkspace
|
+-- Project1
|    |
|    +-- Target1.xcodeproj
|    +-- (source code)
|    |
|    +-- Target2
|    +-- (source code)
|
|
+-- Project2
|    |
|    +-- Target3.xcodeproj
|    +-- (source code)
|
+-- Target3
     |
     +-- (source code)
like image 765
allenlinli Avatar asked Dec 31 '13 07:12

allenlinli


People also ask

What is the difference between project and target in Xcode?

An project is a repository for all the files, resources, and information required to build one or more software products. A target specifies a product to build and contains the instructions for building the product from a set of files in a project or workspace.


2 Answers

This Podfile hasn't been verified, but may show you a basic idea of multiple projects and targets setting.

workspace 'MyApp'
xcodeproj 'Project1/Project1.xcodeproj'
xcodeproj 'Project2/Project2.xcodeproj'

target :Target1 do
    platform :ios, '6.0'
    pod 'RestKit'
    xcodeproj 'Project1/Project1.xcodeproj'
end

target :Target2 do
    platform :ios, '6.0'
    pod 'RestKit'
    xcodeproj 'Project2/Project2.xcodeproj'
end

target :Target3 do
    platform :ios, '6.0'
    pod 'RestKit'
    xcodeproj 'Project1/Project1.xcodeproj'
end

The first line specifies your workspace. Check http://guides.cocoapods.org/syntax/podfile.html#workspace

Second line and third line specify your xcodeprojs. http://guides.cocoapods.org/syntax/podfile.html#xcodeproj

And then, specify pod dependencies for targets one by one.

like image 72
vampirewalk Avatar answered Oct 23 '22 11:10

vampirewalk


Here's a working example from https://github.com/dblock/ARASCIISwizzle:

workspace 'ARASCIISwizzle'

pod 'ARASCIISwizzle', :path => 'ARASCIISwizzle.podspec'

xcodeproj 'Demo.xcodeproj'

target 'Demo' do
  pod 'FLKAutoLayout', '~> 0.1.1'
  xcodeproj 'Demo.xcodeproj'
end

target 'IntegrationTests' do
  pod 'Specta', '~> 0.2.1'
  pod 'Expecta', '~> 0.2.3'
  pod 'FBSnapshotTestCase', :head
  pod 'EXPMatchers+FBSnapshotTest', :head
  xcodeproj 'Demo.xcodeproj'
end

target 'Tests' do
  pod 'Specta', '~> 0.2.1'
  pod 'Expecta', '~> 0.2.3'
  pod 'FBSnapshotTestCase', :head
  pod 'EXPMatchers+FBSnapshotTest', :head
  pod 'OCMock', '~> 2.2.3'
  xcodeproj 'Tests.xcodeproj'
end

Note the discussion in https://github.com/CocoaPods/CocoaPods/issues/1922, the CocoaPods team is reworking this DSL to be less backwards.

like image 29
dB. Avatar answered Oct 23 '22 10:10

dB.