Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obj-C CocoaPods + Swift Framework

I'm creating a Swift framework in the latest Xcode 6 DP4. I need to internally use AFNetworking in my framework, but can't figure out a way to compile it.

I know how to use bridging headers, but those aren't supported in Swift frameworks.


My framework, Core.framework, looks like this:

> Core.h     #import <UIKit/UIKit.h>     #import <AFNetworking/AFNetworking.h>      //! Project version number for Core.     FOUNDATION_EXPORT double CoreVersionNumber;      //! Project version string for Core.     FOUNDATION_EXPORT const unsigned char CoreVersionString[];   > SomeFileThatNeedsAFNetworking.swift 

And I'm using a podfile to bring in AFNetworking. However, when I compile, I get the following error:

<unknown>:0: error: ~/Core/Source/Core.h:2: include of non-modular header inside framework module 'Core' 

because of the AFNetworking import. But if I don't include that, then I get compilation errors everywhere referencing AFNetworking.

Has anyone figured out the right combination?

like image 366
Ryan Avatar asked Jul 22 '14 00:07

Ryan


People also ask

How do you use Swift CocoaPods in Objective-C?

Support Objective-C pods in a Swift project First, create your Podfile and add the pods you need as usual. Install them using the pod install command and open the . xcworkspace file created in your project folder. Pods should now be included in your workspace.

Is CocoaPods a framework?

🎉 Cocoapods is a popular tool that simplifies installing and sharing Swift frameworks. In this post we will walk through the process of sharing a Swift framework through Cocoapods. Later we will consume it inside an app. We will host our framework in a git repository which Cocoapods will access.

How do you make a CocoaPods framework in Swift?

Implement the podIn the project navigator, right click on the SwiftyLab target and select New File... Choose Swift File as the new file template, click on Next … Name the file as SwiftyLib , make sure this file belongs to the SwiftyLib target and save it in the SwiftyLib folder as shown in the screenshot below.


1 Answers

Well, based on what I'm seeing here and here I don't think it is possible to compile anything from a pod file just yet. I have tried to do this with the SCLAlertView-Swift library with similar errors. I think you will just have to wait for the code to get developed by the cocoapods team.

like image 149
user3832611 Avatar answered Sep 20 '22 23:09

user3832611