Cocoapods: single pod file with multiple projects in one workspace

Created on 24 Nov 2015  Â·  7Comments  Â·  Source: CocoaPods/CocoaPods

I've create a workpace and added two projects in it. The directory structure of my project is:

  • root

    • testworkspace.xcworkspace

    • root/project1

    • root/project1/project1.xcodeproj

    • root/project2

    • root/project2/project2.xcodeproj

How can I've single podfile for both the projects? I created one pod file under project1 and manually moved it under root directory. Here is how pod file looks like.

workspace ‘testworkspace’

xcodeproj ‘project1/project1.xcodeproj’
target ‘project1’ do
pod 'testworkspace', :path => '.'
pod ‘AFNetworking’
end

xcodeproj ‘project2/project2.xcodeproj’
target ‘project2’ do
pod 'testworkspace', :path => '.'
pod ‘MBProgressHUD’
end

_pod install --verbose_ gives me error: Unable to find a target named project1

Most helpful comment

platform :ios, '9.0'

workspace 'TestWorkSpace'
xcodeproj 'Project1/Project1.xcodeproj'
xcodeproj 'Project2/Project2.xcodeproj'

target 'Project1' do
    xcodeproj 'Project1/Project1.xcodeproj'
   #Pods for Project1
    pod 'SwiftyJSON', '~> 4.0'
end

target 'Project2' do
    xcodeproj 'Project2/Project2.xcodeproj'
   #Pods for Project2
    pod 'SwiftyJSON', '~> 4.0'
end

All 7 comments

Offhand, not at a computer, I think you want to use the targets as scopes for the xcproject/workspaces. So something like this per target to integrate

target ‘project1’ do
   workspace ‘testworkspace’
   xcodeproj ‘project1/project1.xcodeproj’
   pod 'testworkspace', :path => '.'
   pod ‘AFNetworking’
end

tried above solution but its still giving me same issue as I specified in question.

@artiy can you please share your modified podfile?

updated pod file is :

workspace 'testworkspace'

xcodeproj 'project1/project1.xcodeproj'

target 'project1' do

workspace 'testworkspace'
pod 'AFNetworking'
end

xcodeproj 'proj2/proj2.xcodeproj'

workspace 'testworkspace'
target 'proj2' do
pod 'MBProgressHUD'
end

Try putting the xcodeproj directives inside the target blocks.

Solved my issue. Thanks a lot!!!

platform :ios, '9.0'

workspace 'TestWorkSpace'
xcodeproj 'Project1/Project1.xcodeproj'
xcodeproj 'Project2/Project2.xcodeproj'

target 'Project1' do
    xcodeproj 'Project1/Project1.xcodeproj'
   #Pods for Project1
    pod 'SwiftyJSON', '~> 4.0'
end

target 'Project2' do
    xcodeproj 'Project2/Project2.xcodeproj'
   #Pods for Project2
    pod 'SwiftyJSON', '~> 4.0'
end

Was this page helpful?
0 / 5 - 0 ratings