Tunyk Pavel
Tunyk Pavel

Reputation: 2493

Include ".framework" file to cocoapods

I'm trying to add "Custom.framework" to my pod (cocoapods). And I'm a bit stuck with pod spec setup. I've done following:


s.resources = ['Resources/Custom.framework']
s.preserve_paths = "Resources/Custom.framework"
s.frameworks  = "UIKit", "Custom"

But in project where I'm using this pod, I'm getting error

<Custom/Custom.h> not found

or something similar.

I'm stuck already for a few hours and I can't find answer to my question in google.

BR, Pavlo.

Upvotes: 11

Views: 5557

Answers (2)

M. Adam
M. Adam

Reputation: 108

Using vendored_frameworks did the inclusion as @Keith said. But the addition to his answer is that I added the custom framework as a 'Do Not Embed' option. and the pod was able to link it and provide it to the using Application.

How the framework is embedded

You can also provide more frameworks. The following line includes Custom. framework nad Custom2.framework frameworks and any Xcode framework .xcframework

s.vendored_frameworks = 'YourOwnFrameworksFolder/Custom.framework' , 'YourOwnFrameworksFolder/Custom2.framework', 'YourOwnFrameworksFolder/**.xcframework'

Also, if your Custom.framework needs another framework to work successfully, I think you will need to provide it also in the vendored_frameworks but you don't need to embed it in your pod framework project as the pod project itself does not use it directly.

So for example, if Custom.framework needs CustomDependency.framework, the vendored_frameworks will be :

s.vendored_frameworks = 'YourOwnFrameworksFolder/Custom.framework' , 'YourOwnFrameworksFolder/CustomDependency.framework'

Upvotes: 1

Keith Smiley
Keith Smiley

Reputation: 63984

What you want is the vendored_frameworks attribute. In your case it looks like you'd want to use it like this:

s.vendored_frameworks = 'Resources/Custom.framework'

This automatically deals with preserving the path and linking the framework itself so you don't need either of those attributes for your custom framework.

Upvotes: 11

Related Questions