29

I am working on a project which is composed of three other projects in a workspace. I want to use CocoaPods to manage my dependecies in the workspace, but CocoaPods always creates its own workspace with only one addtional project. What I want to do is to add CocoaPods project to the workspace that already exists. Is there any simple way to achive that?

swiftBoy
  • 35,607
  • 26
  • 136
  • 135
pawel.kalisz
  • 1,246
  • 1
  • 18
  • 26

2 Answers2

52

In terminal go to directory with your xcworkspace-file.

$ touch Podfile

then in Podfile :

workspace 'YourWorkspace'

target 'YourProjectName' do
    platform :ios, '8.0'
    pod 'your pod' 
    project 'Path to your Project in your workspace'
end

$ pod install

Axel Guilmin
  • 11,454
  • 9
  • 54
  • 64
Illya Krit
  • 925
  • 1
  • 8
  • 9
  • why do you add an answer to an old question with an accepted answer, which is almost the same as your answer? – FelixSFD Aug 01 '16 at 14:15
  • 23
    It has more details. The old answer doesn't help me in my search – Illya Krit Aug 01 '16 at 14:56
  • 1
    A mix between this answer and https://medium.com/@youvalv/cocoapods-for-an-existing-multi-project-workspace-1fb73f46fede helped me to build this. Beware though, once `pod install` has been run, clean the project and relaunch XCode. Sometimes it fails updating dependencies. Thanks mate – Olympiloutre Nov 06 '18 at 13:47
  • 3
    The path in the `project` should **not** begin with "/". For me this worked: `project 'pathTo/MyProject'` but this didn't: `project '/pathTo/MyProject'`. – Georgios Aug 07 '19 at 09:44
15

You can specify a workspace in your podfile.

workspace 'MyWorkspace'

Please consult this link for more info: http://guides.cocoapods.org/syntax/podfile.html#workspace

Thomas Keuleers
  • 6,075
  • 2
  • 32
  • 35