PromiseKit icon indicating copy to clipboard operation
PromiseKit copied to clipboard

ObjC AnyPromise and SwiftPackageManager (SPM)

Open DG0BAB opened this issue 4 years ago • 10 comments

This PR makes AnyPromise available to Objective-C and Swift code when used with SPM.

To achieve this, the PromiseKit package now consists of two targets. PromiseKit and PromiseKitObjC. The existence of PromiseKitObjC is almost irrelevant to the client because a simple #import PromiseKit.h can be used in Objective-C files to get access to AnyPromise. If the client wants to use modules, @import PromiseKitObjC; must be used.

AnyPromise is now defined in Swift and uses the @objc attribute. It's made accessible to Objective-C, by adding the category @interface AnyPromise (ObjC) to it. All ObjC functionality defined in this category, delegates to the Swift AnyPromise.

Additional changes to other files were necessary to make everything work in the PromiseKit Xcode Project and while build as a SwiftPackage. All tests succeeded in the Xcode Project.

DG0BAB avatar Mar 17 '21 23:03 DG0BAB

As expected, the tests and/or build on Linux failed.

DG0BAB avatar Mar 17 '21 23:03 DG0BAB

My mistake: Not the Linux-Tests are failing. It's the Pretest and I got irritated by the --generate-linuxmain option....

DG0BAB avatar Mar 19 '21 13:03 DG0BAB

I tested it with Xcode 10.3 and got the same results as seen here while building with Travis. I currently don't know how to fix this and I don't have the time to further investigate this issue. However it works fine with Xcode 12. So maybe this PR could be used for some a later or special SPM version of PromiseKit. I don't know. Any help for fixing this Issue is greatly appreciated.

DG0BAB avatar Mar 29 '21 19:03 DG0BAB

Rebase for new CI infrastructure

mxcl avatar May 24 '21 16:05 mxcl

This is very intrusive. I cannot merge.

mxcl avatar May 26 '21 01:05 mxcl

Yeah, a lot of changes were necessary to make it work. I’m already using my fork in production code for two of my projects and it works without any problems so far.

I can think of a few simplifications but I don’t know if they work. The main problem is, that SPM does not support mixed code targets. So I had to clearly separate Swift and ObjC into to two targets and adapt the code accordingly.

Let me know what you find most intrusive. Maybe I find a way to change that.

DG0BAB avatar May 26 '21 07:05 DG0BAB

We need to run the full CI against this. I'll make that possible with a comment or something.

mxcl avatar May 26 '21 14:05 mxcl

I guess we would merge for v6 since v7 is now mainline and we don‘t intend to maintain v6 beyond fixes.

Ideally would be a little less intense though…

mxcl avatar Jul 13 '21 14:07 mxcl

Hi,

is there any update about this issue? How is possibile to use AnyPromise in an ObjC class using the SPM version?

Thanks.

mrcararia avatar Aug 26 '22 15:08 mrcararia

is there any update about this issue?

This PR is too much. I have to maintain the results and this is beyond my ability to comprehend it without significant work. So I can't merge it.

How is possibile to use AnyPromise in an ObjC class using the SPM version?

It is not possible without a patch like this. You could use the fork of OP. SwiftPM is decentralized by design.

mxcl avatar Sep 22 '22 01:09 mxcl