Hello! I'm using PromiseKit 6.2.4, CocoaPods 1.5.0, and Xcode 9.3.
CocoaPods 1.5.0 introduced support for Swift static libraries in the Podfile. That is, the CocoaPods end-user can decide whether to configure Swift dependencies as dynamic or static libraries.
When configured this way, PromiseKit 6.2.4 fails to build. Line 1 of AnyPromise.m reads:
#import <PromiseKit/PromiseKit-Swift.h>
and the compile error I get is
/Users/nolanw/Desktop/Updog/Pods/PromiseKit/Sources/AnyPromise.m:1:9: 'PromiseKit/PromiseKit-Swift.h' file not found
if I change that line of AnyPromise.m to instead read
#import "PromiseKit-Swift.h"
then the build succeeds. Here is my Podfile in all its glory:
target 'Updog' do
pod 'PromiseKit'
end
I realize that using a system include is the recommended approach in Apple's docs for using Swift code in Objective-C in a Framework target, and I don't know what the ramifications would be for unilaterally changing to a user include. (I'm guessing the build would then fail for other installation methods.)
It's entirely possible that CocoaPods should be doing something with the build settings (or maybe we could add something to PromiseKit's .podspec to fiddle with build settings) so that the system include succeeds with this configuration? I don't mind opening an issue at CocoaPods if we think it's on them.
This seems to work ok as a replacement for line 1 of AnyPromise.m:
#if __has_include("PromiseKit-Swift.h")
#import "PromiseKit-Swift.h"
#else
#import <PromiseKit/PromiseKit-Swift.h>
#endif
or at least it still builds ok when installed via CocoaPods both as a dynamic library and a static library.
Kinda ugly but honestly I'm a bit shocked it's the only change needed to get a static library building under CocoaPods. Happy to open a PR if this looks workable!
OK, I can confirm that
#import "PromiseKit-Swift.h"
fails when installed via Carthage. I can confirm that the __has_include approach succeeds when installed via Carthage and when installed as dynamic and as static via CocoaPods.
Sorry for the rapid fire replies. I'm done for a little while :)
I'd like to hear what CocoaPods think here since presumably we aren't the only library that is affected by this issue.
#if __has_include("PromiseKit-Swift.h")
#import "PromiseKit-Swift.h"
#else
#import <PromiseKit/PromiseKit-Swift.h>
#endif
Seems safe, but I am hesitant, I have applied similar hacks before and then had three new bugs show up after release.
Looks like someone beat me to it: https://github.com/CocoaPods/CocoaPods/issues/7594
Thanks, I've added myself as a watcher on the thread.
Most helpful comment
This seems to work ok as a replacement for line 1 of
AnyPromise.m:or at least it still builds ok when installed via CocoaPods both as a dynamic library and a static library.
Kinda ugly but honestly I'm a bit shocked it's the only change needed to get a static library building under CocoaPods. Happy to open a PR if this looks workable!