Reputation: 411
I like Xcode workspaces and CocoaPods. So I want to stick to them and their setup and want to create a workspace, containing other projects, like this structure:
- MyApp.workspace
|-- MyApp.project
|-- Pods.project
|-- AnotherApp.project
Most of the posts about adding dependencies to existing projects suggests nesting them, like:
- MyApp.workspace
|-- MyApp.project
|-- AnotherApp.project
|-- Pods.project
But, I'm not sure if this is the correct approach. I think I should put them to the same level as both Pods and AnotherApp provide libs/reusable codes to MyApp.
Which one do you suggest and why? And also if you provide any walkthroughs or tutorials about the first setup I would be very appreciated, because most of them gives examples like the second one but without the workspace.
Upvotes: 6
Views: 1533
Reputation: 1624
I am not sure if I fully understand the question so please forgive if I miss something.
I desired a similar setup, multiple projects in a workspace, but all managed by Cocoapods. I needed the projects to link to each other. My motive was promoting MVC separation, so I had an App project (view), a Controller project, a Model project. The shell of a project is here: https://github.com/premosystems/iOSMVCTemplate/tree/1.0/MVC-Example/iOS/MVCApp
Here are the basic steps:
Create your projects, and add a podspec to each one. (e.g. controller podspec like this one: https://github.com/premosystems/iOSMVCTemplate/blob/1.0/MVC-Example/iOS/MVCApp/Controller/ProximityController/ProximityController.podspec)
Add a Podfile that links all of the podspecs together. https://github.com/premosystems/iOSMVCTemplate/blob/1.0/MVC-Example/iOS/MVCApp/Podfile
And of course pod install :)
Be sure to reference the podspecs you create in the Podfile using the :path=> development directive before they are referenced by any podspecs so cocoapods will know not to look in the public repository.
I have been using this a month or so, and it works pretty well. Only drawback is that indexing and compile time take longer than I would like, and pod update is really slow. Before adding and new files, .h, .m to any podspecs you must run pod update.
Best of luck!
Upvotes: 4