Akshay Agrawal
Akshay Agrawal

Reputation: 217

How to add Framework containing pods into another project

I am facing a problem and searched for it a lot but did not found any solution.

I had created a Swift framework that uses MQTTKit" that I added to my Framework using CocoaPods.

Now I had created a sample app that will use the above framework.

Then I created a workspace and added the xcodeproj file of framework as well as sample app to the workspace.

But now I am not able to use that framework in my sample app.

I am getting the error No such module MQTTKit inside my framework.

However there is no error in the framework if I build it separately?

So is there is any problem with the pods or something else?

Upvotes: 7

Views: 7528

Answers (3)

Aura
Aura

Reputation: 246

I know it's late answer, but maybe it will help someone.

I had the same problem when I wanted to use my framework project embedded into a demo project so I could test framework during development.

My framework was using cocoapods to download its dependencies, so if you want to use it as a subproject, you have to put everything in demo project: framework project, framework pods projects, workspace of framework project.

So demo project tree would look like this:

DemoApp project
    --- framework.xcodeproj
    --- pods.xcodeproj (the one from the framework project)
    --- framework.xcworkspace

Upvotes: 0

RodolfoAntonici
RodolfoAntonici

Reputation: 1635

If you're using multiple Xcode Projects in a single Workspace, you should use pod targets like this:

platform :ios, '9.0'
inhibit_all_warnings!
use_frameworks!

target "MyApp" do
  xcodeproj 'MyApp'
  pod 'MQTTKit'

  target "SampleApp" do
    xcodeproj 'SampleApp'
    inherit! :search_paths
    pod 'MQTTKit'
  end
end

To learn more, refer to Cocoapods Podfile Syntax Reference

Upvotes: 3

Akshay Agrawal
Akshay Agrawal

Reputation: 217

Hey I found another way of doing the above thing.
What we can do is instead of using cocoapods we can add the frameworks manually in our own framework.
Since cocoa pods is not playing well with embedded framework as mentioned in the following link.
http://samwize.com/2015/01/26/projects-workspace-embedded-framework-and-cocoapods/.
So I did the same things added the frameworks manually in my framework then I added the framework as a subproject in my app.
Now it is working fine.

Upvotes: 0

Related Questions