Hi.
I want to use CocoaPods on our new project, but I think I'm missing something. I want to have one Workspace containing a couple of projects, but it seems that CocoaPods does not support this.
Whenever I run pod install AppName.xcodeproj it generates a new workspace called AppName.xcworkspace and tells me to use this from now on. But what about the existing workspace? And how can I add additional CocoaPods based project to the same workspace?
Thanks
It certainly can be done, it’s only the part that configures your project which is a bit naive. I.e. it currently caters to the simplest common case, which is one app project.
For now you’ll have to configure each project that you will add to the workspace manually as described in the ‘What this does’ section.
Will each project require a different set of dependencies? If so, you’ll have to define targets as described in the ‘Multiple targets’ section.
All in all, we are still refining the process of configuring the projects for you. It would help greatly if you can explain a bit more about your setup and explain what you had to perform manually to configure it to work.
Our project is a "one app project", at least for now, having one workspace containing two projects. The first project is a "API" project which is linked in to the other project, which use the API projects services. Other projects will possibly be added later that also is going to use the API services.
Are the Pods dependencies of the API project, app project, or both (different sets of dependencies)?
(CC'ing @lukeredpath as he has experience with a similar setup.)
Funny that you added @lukeredpath to the discussion since the library I wanted to add to the project when I found CocoaPods was Kiwi :-)
The API project have dependencies to AFNetworking and JSONKit, and the "other" project has dependencies to a mapviewer library and the API project. Both will depend on Kiwi.
This will be interesting :)
So basically your Podfile should look something like the following (non-functional example):
target 'API', :exclusive => true do
link_with 'API lib', :project => 'API Project'
dependency 'AFNetworking'
target 'API-test' do
link_with 'API test', :project => 'API Project'
dependency 'Kiwi'
end
end
target 'other', :exclusive => true do
link_with 'Other target', :project => 'Other Project'
dependency 'SomeMapViewer'
target 'other-test' do
link_with 'Other test', :project => 'Other Project'
dependency 'Kiwi'
end
end
This means that:
project attribute for link_with, to specify the project in the workspace. Although if the target name is unique we should be able to figure it out without specifying the project name. Does this seem like the correct config for you scenario?
Let me first say that I'm not very experienced with Xcode4 and the build settings, but as far as I can see this could work.
Shouldn't the 'other' target have a dependency to 'API'?
Regarding the xcconfig munging, it might be a good idea to generate two files per target. One which defines the actual values, but with namespaced keys and the actual xcconfig file which just imports the other one and assigns the values to the actual keys. This will allow the user to create aggregate configs from multiple target configs easily.
Pods-definitions.xcconfig:
USER_HEADER_SEARCH_PATHS-Pods = "Pods/AFNetworking"
Pods-test.xcconfig:
#include "Pods-definitions.xcconfig"
USER_HEADER_SEARCH_PATHS = USER_HEADER_SEARCH_PATHS-Pods
Pods-test-definitions.xcconfig:
USER_HEADER_SEARCH_PATHS-Pods-test = "Pods/Kiwi"
Pods-test.xcconfig:
#include "Pods-test-definitions.xcconfig"
USER_HEADER_SEARCH_PATHS = USER_HEADER_SEARCH_PATHS-Pods-test
Say the user now wants to use both the Pods libs in one target, then they can easily combine the configs like so:
CustomAggregate.xcconfig:
#include "Pods-definitions.xcconfig"
#include "Pods-test-definitions.xcconfig"
USER_HEADER_SEARCH_PATHS = $(USER_HEADER_SEARCH_PATHS-Pods) $(USER_HEADER_SEARCH_PATHS-Pods-test)
_NOTE this is untested, but from reading about xcconfig files I think this is the way they work_
Shouldn't the 'other' target have a dependency to 'API'?
The name was getting a bit ambiguous, there are two libs involved in the API project. :)
In this case I meant that the API Pods lib will be linked to your API project’s product lib. Although it’s a lib as well, it’s outside of the scope of CocoaPods, so you will have to add that product lib to the ‘other’ project yourself.
Wow! I'll think I have to spend some time this weekend get get a better grip on xcconfig :-)
This thread might help to understand what I just described :)
Anyways, to be able to help your situation out as soon as possible, I think the most important thing is that nested targets work as shown in that example. All other things can be configured by hand (and configuring your projects to use the Pods libs is usually done only once). I’ll try to get this out tonight/tomorrow.
This is not actually fixed yet. Need to ensure we have separate tickets for the individual issues.
Ok, I think that when this fix is released (0.3.5), you should at least be able to do it, although you’d still have to do the hooking up to your projects targets yourself. (#76 & #80 describe the issues related to configuring projects.)
Let me know if I missed anything or you run into problems configuring the projects manually.
Thanks a lot. I'll try and come back to you.
Hello again.
I have read your comments and the examples several times, but I still don't understand how to create a workspace with more than one project.
Let say I want to have three projects in one workspace. App1, App2 and a API project which is used by both App1 and App2. Each of the projects can of course have dependencies to other libraries.
An example on how to solve this would be much appreciated.
Thanks...
I think it might be best to wait till we have support for the aforementioned link_with helper and allow xcconfig files to be mixed. Then I’ll create an example app too to illustrate this.
No problem, I'll wait :-)
Closed by 23626caaea8059eca36a0c5b499b0075c17a2a61.
Is there an example project on how to put accomplish this multi-project per workspace setup?
@tonyxiao If the target names match those in your projects, than it should automagically work. Otherwise you will have to specify the project inside the target block like so:
target 'My Target' do
xcodeproj 'My Project'
end
I tried using the following Podspec, then ran pod install, but it seems to have no effect.
platform :osx, '10.7'
workspace 'MyProj.xcworkspace'
inhibit_all_warnings!
pod 'AFNetworking'
pod 'RestKit', '0.10.1'
pod 'ConciseKit', '0.1.2'
#pod 'BlocksKit', '1.5.0'
pod 'NSLogger', :podspec => 'local'
target 'MyProj' do
xcodeproj 'MyProj.xcodeproj'
end
target 'MyPlugin' do
xcodeproj 'Plugins/MyPlugin/MyPlugin.xcodeproj'
end
I'm trying to accomplish a setup where a plugin app is in the same workspace is the primary app and have mostly the same dependencies. I've tried to manually add libPods.a to linked libraries, and created a PluginPods.xcconfig file as follow in the Plugins directory.
#include "../Pods/Pods.xcconfig"
PODS_ROOT = ${SRCROOT}/../../Pods
This seems to work, except it feels error prone and lacks a Copy Pods Resources build phase that executes the shell script "${SRCROOT}/Pods/Pods-resources.sh". I was hoping that perhaps there are built in support in the Podfile to accommodate setup.
I see. The two targets don’t contain any dependencies of their own, only inherited ones. For this reason they are considered empty and being ignored… Can you confirm this by adding an extra dependency to one of the targets and see if it does work then?
Ah, that seems to finally have some effect and modifies the projects. Now I get a libPods-MyProj.a and a libPods-MyPlugin.a library. My Podfile looks like this
platform :osx, '10.7'
workspace 'MyProj.xcworkspace'
inhibit_all_warnings!
pod 'AFNetworking'
pod 'RestKit', '0.10.1'
#pod 'BlocksKit', '1.5.0'
pod 'NSLogger', :podspec => 'local'
target 'MyProj' do
xcodeproj 'MyProj.xcodeproj'
pod 'ConciseKit', '0.1.2'
end
target 'MyPlugin' do
xcodeproj 'Plugins/MyPlugin/MyPlugin.xcodeproj'
pod 'ConciseKit', '0.1.2'
end
However, I'm not getting errors in my project that says ConciseKit/ConciseKit.h not found. Additionally, Is it possible to specify a set of pods that apply to an entire project rather than just specific targets? Pods that apply to targets can inherit from pods that apply to an entire project. Something along the lines of the following
platform :osx, '10.7'
workspace 'MyProj.xcworkspace'
inhibit_all_warnings!
pod 'AFNetworking'
pod 'RestKit', '0.10.1'
#pod 'BlocksKit', '1.5.0'
pod 'NSLogger', :podspec => 'local'
xcodeproj 'MyProj.xcodeproj' do
pod 'ConciseKit', '0.1.2'
target 'MyProj' do
pod 'Mixpanel'
end
target 'MyProjTests' do
pod 'Kiwi'
end
end
xcodeproj 'Plugins/MyPlugin/MyPlugin.xcodeproj' do
pod 'ConciseKit', '0.1.2'
target 'MyPlugin' do
pod 'Mixpanel'
end
target 'MyPluginTests' do
pod 'Kiwi'
end
end
This doesn't seem to work. Can we reopen this ticket ?
I tired this myself with no success. Can you reopen this ticket or post a podfile that works?
I am trying to have multiple projects in one podfile with different pods.
@krawftyone See https://github.com/CocoaPods/CocoaPods/issues/738#issuecomment-12415578 there is an example by @dperetti showing what he found does and does not work.
Yes, this need to re-opened since it's not working as expected.
I am having the same problem as well. Would love to get some information on how to proceed from here.
@marquezzy Can you post your Podfile and describe the exact issue?
@irrationalfab
The podfile is super simple.
platform :ios, '5.0'
pod 'AFNetworking', :head
I already have a workspace for my project with four static libraries added as additional projects in the workspace. When I run pod install my existing projects are removed from the workspace. The references are there in red indicating something is missing. I was able to work around it by re-adding them to the workspace and add libPods to my build scheme.
I received an error:
[!] The target MyAppName [Debug - Release - Distribution]' overrides theALWAYS_SEARCH_USER_PATHS' build setting defined in Pods/Pods.xcconfig'.
- Use the$(inherited)' flag, or
- Remove the build settings from the target.
[!] The target MyAppName [Debug - Release - Distribution]' overrides theHEADER_SEARCH_PATHS' build setting defined in Pods/Pods.xcconfig'.
- Use the$(inherited)' flag, or
- Remove the build settings from the target.
My project builds and runs in the simulator but I am getting file not found for headers in my projects when archiving. How can I resolve these issues?
The podfile is super simple.
You need to specify all the targets that you wan't to integrate with, you also may want to use the xcodeproj and the workspace directives. This documentation should get you on the right track.
I received an error.
You are overriding some of the settings of the xcconfigs generated by CocoaPods and you should edit your build settings as indicated to the warning.
As this is not a bug in CP, please use the mailing list or stack overflow for more clarification.
@irrationalfab Thanks.
I have a workspace with two projects. First project is a library project and used by second project as a static library.
I want to integrate my workspace with Cocopods. Basically I want to integrate my Library project with Cocoapods and I want to link MyApp to MyLibrary project. I came up with different combinations of Podfile with no success.
My latest Podfile is like this:
platform :ios, '5.1'
workspace 'MyWorkspace.xcworkspace'
xcodeproj 'MyLibraryProj.xcodeproj'
inhibit_all_warnings!
pod 'AFNetworking', '1.3.3'
pod 'JSONKit', '~> 1.4'
pod 'Reachability', '~> 3.1.1'
pod 'TTTAttributedLabel', '~> 1.7.1'
pod 'UrbanAirship-iOS-SDK', '~> 3.0.0'
pod 'ZipArchive', '~> 1.2.0'
pod 'ZXing', '~> 2.1'
pod 'MKNumberBadgeView', '~> 0.0.1'
pod 'SVStatusHUD', '~> 0.0.1'
target 'MyApp', :exclusive => true do
platform :ios, '5.1'
xcodeproj 'MyApp.xcodeproj'
pod 'SSToolkit', '~> 1.0.4'
end
I solved the problem and posting my Podfile:
platform :ios, '5.1'
workspace 'MyWorkspace.xcworkspace'
xcodeproj 'MyLibraryProj.xcodeproj'
inhibit_all_warnings!
target 'MyLibraryProj' do
xcodeproj 'MyLibraryProj.xcodeproj'
pod 'NSLogger', '~> 1.1'
pod 'TouchXML', '~> 0.1'
pod 'AFNetworking', '1.3.3'
pod 'JSONKit', '~> 1.4'
pod 'Reachability', '~> 3.1.1'
pod 'TTTAttributedLabel', '~> 1.7.1'
pod 'UrbanAirship-iOS-SDK', '~> 3.0.0'
pod 'ZipArchive', '~> 1.2.0'
pod 'ZXing', '~> 2.1'
pod 'MKNumberBadgeView', '~> 0.0.1'
pod 'SVStatusHUD', '~> 0.0.1'
target 'MyApp', :exclusive => true do
platform :ios, '5.1'
xcodeproj 'MyApp.xcodeproj'
pod 'SSToolkit', '~> 1.0.4'
end
end
Not: in Pods project and all targets change the settings to "Compiler Default" for C++ Language Dialect and C++ Language Library.
Thanks a lot! @conqueror it looks like your spec file really has created a workspace with two projects in it. I've been able to set up Kiwi testing for one of those projects at least. Great stuff!
Can anyone provide a valid working podfile for two-project workspace? All of the above are not working.
Okay, got this working with the following pod file:
workspace 'Projects.xcworkspace'
platform :ios, '8.0'
use_frameworks!
# ignore all warnings from all pods
inhibit_all_warnings!
def shared_pods
# all the pods go here
# pod 'Parse' etc.
end
xcodeproj 'Project1.xcodeproj'
xcodeproj 'Project2/Project2.xcodeproj'
target :Project1 do
xcodeproj 'Project1'
shared_pods
end
target :Project2 do
xcodeproj 'Project2/Project2.xcodeproj'
shared_pods
end
@andrew8712 I've also managed to make a minimal demo project for this at https://github.com/fatuhoku/demo-modular-ios-with-cocoapods-frameworks-and-xcprojects.
Please don't comment on three year old closed issues.
@segiddins why not? I googled about this issue and came here. I believe this is how many of us looking for a solution.
If you're having an issue, please open one with all of the information requested in the contributing guidelines.
... @segiddins I posted a link because I originally got my demo setup working using @andrew8712's code snippet. I was not raising a new issue. I cannot imagine why starting another issue would help anybody.
Most helpful comment
Okay, got this working with the following pod file: