Obj-C CocoaPods + Swift Framework Obj-C CocoaPods + Swift Framework swift swift

Obj-C CocoaPods + Swift Framework


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.


So I have something working. My goal was to use a shared code framework across multiple targets with cocoapod libraries for support in sharedCode. Problems I had were the non-modular header issue and the duplicate symbols issue.

MainTarget-swift files

SharedCode-swift files-objc files-cocoapods lib

Add a 'Run Script Phase' to the top of the 'framework' target

set -eRESOURCES_TO_COPY=${PODS_ROOT}/headers-to-copy-${TARGETNAME}.txt> "$RESOURCES_TO_COPY"ls -d -1 ${PODS_ROOT}/Headers/Public/**/*.h >> "$RESOURCES_TO_COPY"rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Headers"rm -f "$RESOURCES_TO_COPY"

In the framework main header put

#import <{SHARED_FRAMEWORK_NAME}/PixateFreestyle.h>#import <{SHARED_FRAMEWORK_NAME}/Lockbox.h>#import <{SHARED_FRAMEWORK_NAME}/etc.h>

Voila, the classes are now available to your framework code and to your framework dependencies if needed. This does expose all of the cocoapods headers and the copy script is not smart so you may run into a path issue. So far so good for me though. This is certainly a work-around since the non-modular header thing blocks the compiler.