Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using CocoaPods with multiple projects

I have a workspace that contains:

  • myiPhone.xcodeproj
  • sharedStuff/sharedStuff.xcodeproj

sharedStuff.xcodeproj builds a static library that is a dependency to myiPhone.xcodeproj (for simplicity assume that each project has a single target).

Now I want to add a library through CocoaPods that should be available to both projects.

My Podsfile looks like this:

workspace 'myWorkspace.xcworkspace'
platform :ios

target :myiPhone do
    xcodeproj 'myiPhone.xcodeproj'
    pod 'MBProgressHUD', '~> 0.6'
end


target :sharedStuff do
    xcodeproj 'sharedStuff/sharedStuff.xcodeproj'
    pod 'MBProgressHUD', '~> 0.6'
end

When I build I get these errors:

diff: /../Podfile.lock: No such file or directory diff: /Manifest.lock: No such file or directory error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

Anyone have a clue what's going on here?

UPDATE: From the looks of it the PODS_ROOT variable is not set when the "Check Pods Manifest.lock" build phase is executed.

like image 335
Mihai Damian Avatar asked May 28 '13 14:05

Mihai Damian


2 Answers

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 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
like image 133
Andrey Gordeev Avatar answered Oct 16 '22 09:10

Andrey Gordeev


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'
end


target 'sharedStuff' do
    project 'sharedStuff/sharedStuff'
    pod 'MBProgressHUD', '~> 0.6'
end
like image 30
Yesbol Kulanbekov Avatar answered Oct 16 '22 11:10

Yesbol Kulanbekov