Using CocoaPods with multiple projects Using CocoaPods with multiple projects xcode xcode

Using CocoaPods with multiple projects


I have 2 projects in my Workspace and the accepted answer didn't work for me. But finally I've managed how to get Cocoapods working properly with 2 projects. Here is how my pod file looks like:

workspace 'Projects.xcworkspace'platform :ios, '8.0'use_frameworks!# ignore all warnings from all podsinhibit_all_warnings!def shared_pods    # all the pods go here    # pod 'Parse' etc.endxcodeproj 'Project1.xcodeproj'xcodeproj 'Project2/Project2.xcodeproj'target :Project1 do  xcodeproj 'Project1'  shared_podsendtarget :Project2 do  xcodeproj 'Project2/Project2.xcodeproj'  shared_podsend


With current syntax it looks like this

use_frameworks!workspace 'myWorkspace'project 'myiPhone'project 'sharedStuff/sharedStuff'target 'myiPhone' do    project 'myiPhone'    pod 'MBProgressHUD', '~> 0.6'endtarget 'sharedStuff' do    project 'sharedStuff/sharedStuff'    pod 'MBProgressHUD', '~> 0.6'end


The first targets in your xcode projects have a build phase to perform a diff on two lock files. But it seems like your xcode projects configurations are not referencing the user defined settings configured in Pods/Pods-libPods.xcconfig.

It looks like you are trying to link a Pod with specific targets in multiple xcodeprojs. If my assumption is correct, you are using the target attribute incorrectly. The target attribute creates a new static library within the Pods project that includes the Pods you configured within that target.

The default target for the Pods xcodeproj is libPods which generates the libPods.a static library. This is generated if you do not specify a target. So if you don't care about generating multiple static libaries in the Pods xcodeproj, don't bother defining a target and use the link_with attribute to link the default libPods target (static library) to the targets in your xcodeprojs.

For example, the following Podfile will create a libPods target in Pods.xcodeproj which will add MBProgressHUD sources to the compile phase then add the xcconfig file defining PODS_ROOT and the PODS_HEADER_SEARCH_PATH for example to each of your xcodeprojs. It will then link this static library to the targets you specified with link_with and xcodeproj

workspace 'myWorkspace.xcworkspace'platform :iosxcodeproj 'myiPhone.xcodeproj'link_with 'myiPhone'xcodeproj 'sharedStuff/sharedStuff.xcodeproj'link_with 'sharedStuff'pod 'MBProgressHUD', '~> 0.6'