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?
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.
🎉 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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With