New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why is AnyPromise not available with SPM? #1192
Comments
AnyPromise is Objective C, initially you couldn't build any objc with SwiftPM and I believe it is still problematic. I imagine you can copy the sources for AnyPromise into your project. |
Copying the sources seems reasonable. Thanks for that tip. But on the other hand, are you sure about that Objc thing? I'm using two form libraries in my project: XLForm for Objective-C and Eureka for Swift. I migrated both from CocoaPods to SPM. The XLForm is 100% Objective-C and it works flawlessly with SPM. Both are from xmartlabs. |
I’m not sure no. A PR that added AnyPromise would be welcome. I fear however it is as I fear here, we do some serious shit in some of those sources. |
I already got it working! SPM and AnyPromise in both worlds Swift and ObjC. Just forked the Repo. I'm currently busy to integrate my changes into it. If all is well I'll create a PR soon. It's not as shitty as you fear :-) |
Be sure to add all the AnyPromise tests to the package. I expect the tests to fail on Linux, as well as the build. |
I wasn't able to add the AnyPromise tests to the package. SPM needs a strict separation of swift and Objective-C files within a target. Which means a target can only consist of Swift-Files or ObjC-Files but not both. I tried to create separate ObjC and Swift Test-Targets, but since they are depending on each other, I couldn't get it to work. I believe the only way to solve this, is adding the Test-Targets to the Product-Package but then they would be visible to the client. But, I was able to change PromiseKit.xcodeproject in a way that all tests are running on cmd+U. And guess what? All the Bridging and AnyPromise tests succeeded! I'm going to create a PR now. Please let me know the results of your review. |
Your expectations about failing on Linux were correct! |
The command |
Just tested it on my machine with Xcode 10.3 and it's failing as well. I currently have no idea how to work around this problem. It works flawlessly with Xcode 12 and it solves my problem. I can use AnyPromise with SPM, Swift and Objective-C. Maybe someone else can come up with a solution? Would be nice if the solution in my Fork could be merged into the main repo. Sadly I currently don't have the time, to further investigate this issue. @mxcl would be nice, if you could link this Issue to my PR. Thank you. |
Closing in lieu of #1193 |
Is there a status on how this issue (and the PR) is coming along? I've tried to just copy the ObjC files into my project, while using the SPM. But eventually that end up failing with Next attempt was to try the fork @DG0BAB is working on. I can get the SPM just fine (just pointing to master for now), but I don't have any Any ideas/suggestions would be greatly appreciated. |
Hey Niels, normally you can just use my fork at https://github.com/DG0BAB/PromiseKit, pointing to If problems remain, I'm glad to help! |
Thanks @DG0BAB - I did try to point to master of your fork. So far only from my own SPM module (where there is no ObjC), so I haven't tried to Making my own SPM is new to me, so I'm not expert in defining the Packages, but I'm wondering if this one https://github.com/DG0BAB/PromiseKit/blob/master/Package%40swift-5.3.swift. should be similar to https://github.com/DG0BAB/PromiseKit/blob/master/Package%40swift-5.0.swift and have multiple targets, and if that could be the reason I don't see the |
In Swift as well in ObjectiveC you just have to import PromiseKit to get both - If you just use Xcode to point to my fork's master, you should not have the I have the same setup as you. In my main Project, which is mixed ObjectiveC and Swift, I'm using, besides others, my Backchat Swift framework. Which in turn has a dependency to So, just forget about |
Sorry, I had a cached version lying around. After updating I can see |
I have now tested it with the I do have one problem in an ObjC file, where I'm creating a Promise like this
When I have that code enabled I get a
I'm not really sure what could be causing that issue 🤔 But as far as the changes in the |
@DG0BAB it appears the Will you merge the develop branch to master, for the |
Hey! I never had to create the I'm going to merge |
I also worked around the problem with ObjC for now - it was only in one place, which I could easy extract into a Swift extension to create the AnyPromise. I'll switch back to the master branch from your fork 😄 |
@DG0BAB would it be possible to tag the current state on master of your fork, so I can reference a specific version rather han a branch (or a revision for a specific commit, which I'm currently using)? I bump into some SPM issues, where my own modules cannot be referenced with a specific version, because it depends on an "unstable version" of Promisekit. And I would prefer using versions for my internal modules rather than different branches. 😄
|
@DG0BAB Would the idea above ☝️ be possible, so I can avoid doing a fork of a fork? 😄 |
Sorry for the delay... I'll create a version as soon as I find the time. Most possibly by the end of this week. I'll let you know. So stay tuned 😉 |
@DG0BAB any update on creating a version? 🙂 |
@DG0BAB just a friendly request/reminder about the tagging with a version, so I can avoid making a fork of a fork 😄 |
Please specify the PromiseKit major version you are using
6
Please specify how you installed PromiseKit, ie. Carthage, CocoaPods, SwiftPM or other. If other provide DETAILED information about how you are integrating PromiseKit.
CocoaPods and indirectly with SPM (see text)
AnyPromise
is not available when using Swift PackageManager. But why?I read in another issue that this is documented but I can't find anything regarding this fact.
My Problem:
I'm using PromiseKit in a mixed Swift/ObjC project. I'm including PromiseKit using CocoaPods but trying to successively switch to SPM. Since I need
AnyPromise
, I wasn't able to move PromiseKit from CocoaPods to SPM so far.But now I ran into another Problem: I'm using a SwiftPackage, which itself has a dependency to PromiseKit. Now my main project is complaining that
AnyPromise
isn't available, because the SPM (internal) dependency to PromiseKit is "overriding" the CocoaPods dependency. As far as I know, there is no way, to create something like a "private" dependency within a Swift Package. All dependencies are automatically "re-exported" and visible to the main project.I was searching through the Swift Forums already but there currently seems to be no way to avoid re-exporting SPM package dependencies. Maybe if I understand why
AnyPromise
isn't available when using SPM I might be able to find a workaround.The text was updated successfully, but these errors were encountered: