Adding pods to nested targets in iOS Xcode

I had this confusion on how to add a dependency to a nested target via Cocoapods. This may helps someone. Here is how I did it.

I had this weird structure in one of my project.

SO, I wanted to add a framework to the InnerTarget via pods.

The InnerTarget is a framework target inside TalkTab project which is added as a subproject to the MainTarget workspace.

I tried different ways. Like the given podfile below.

This might work . But for the custom pods framework that I had to add, it was throwing some error.

This is what I ended up doing.

# Uncomment the next line to define a global platform for your project
# platform :ios, ‘9.0’
workspace ‘MainTarget’target ‘MainTarget’ do
# Comment the next line if you don’t want to use dynamic frameworks
use_frameworks!
target 'Ucc' do
project 'TalkTab/TalkTab.xcodeproj'
target 'InnerTarget' do
inherit! :search_paths
end
end
end

In the below line, we need to follow the folderName/Projectname.xcodeproj format.

project 'TalkTab/TalkTab.xcodeproj'

You can know more about configuring the podfile from the cocoapods official documentation here:

  1. https://guides.cocoapods.org/using/the-podfile.html
  2. https://guides.cocoapods.org/syntax/podfile.html#podfile

Hope it might help someone. thanks for reading.

That’s it.

Enjoy!!

If you enjoyed reading this post, please share and give some claps so others can find it 👏👏👏👏👏 !!!!

You can follow me on Medium for fresh articles. Also, connect with me on LinkedIn.

If you have any comment, question, or recommendation, feel free to post them in the comment section below!

--

--