Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed a framework without module in a Pod

I'm using a 3rd party library provided as a framework : Library.framework. Apparently, it can only be used in my Swift project via the Bridging Header by doing #import <Library/Library.h>. Which is fine in most cases.

However, I'm currently developing a Pod in which I want to use Library.framework. This means that I cannot rely on the Bridging Header.

I tried to link the Library.framework in my Pod target (see General > Linked Frameworks and Libraries) but then, once the Pod is installed in my app, Xcode says the Pod cannot compile because some files in Library are not found.

What would be the best strategy to adopt here ?

like image 463
aimak Avatar asked Apr 01 '16 14:04

aimak


2 Answers

I think I made it.

The trick was to add the .h files in both source_files and public_header_files in the Pod.podspec.

Like this :

s.source_files = 'Library.framework/Headers/*.h'
s.public_header_files = 'Library.framework/Headers/*.h'

This way, all the header files appear in the Pod-umbrella.h and can now be used in my app.

like image 140
aimak Avatar answered Oct 02 '22 07:10

aimak


In your pod project I assume you have a file named [PodName].h, it will look similar to the file below. You could try to add the header in this file.

//
//  PodName.h
//  PodName
//
//  Created by John Doe on 06.04.2016.
//  Copyright © 2016 John Doe Inc. All rights reserved.
//

#import <UIKit/UIKit.h>

//! Project version number for PodName.
FOUNDATION_EXPORT double PodNameVersionNumber;

//! Project version string for PodName.
FOUNDATION_EXPORT const unsigned char PodNameVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <PodName/PublicHeader.h>

#import <Library/Library.h> // Add framework header here.
like image 22
Laffen Avatar answered Oct 02 '22 08:10

Laffen