Skip to content
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

Swift package manager support #643

Merged
merged 5 commits into from Jan 3, 2017
Merged

Swift package manager support #643

merged 5 commits into from Jan 3, 2017

Conversation

AndrewSB
Copy link
Member

@AndrewSB AndrewSB commented Sep 16, 2016

Things we're still waiting for:

@AndrewSB AndrewSB changed the base branch from swift-3.0 to spm-root-dir-layout October 25, 2016 23:47
@AndrewSB
Copy link
Member Author

AndrewSB commented Oct 26, 2016

Both ReactiveSwift & RxSwift vend through spm now, trying to see if I can get Alamofire to work, running into some issues related to Alamofire/Alamofire#1544

After that we should be ready to go 🎉

We still can't import Foundation, but I think we can go ahead without that for now, until @apple figures out how they want to handle that

@VivienGiraud
Copy link

Any update ?

@AndrewSB
Copy link
Member Author

@VivienGiraud still waiting on the folks at Alamofire.

I opened Alamofire/Alamofire#1815, since they previously closed Alamofire/Alamofire#1544

@scottrhoyt
Copy link
Contributor

I'd love to get this working as well. However, short of some fragile hackery, I don't see it as a possibility while SPM doesn't support setting the deployment target and doesn't support non Mac/Linux platforms or depending on Apple Frameworks.

The best long term solution would be hassle the SPM folks to add this in time for the next Swift version.

If SPM support is high priority, the other option is to depend instead on an Alamofire fork with the offending functionality removed (if possible) until the underlying issue in SPM is resolved. This could even be the beginning of replacing Alamofire with a Moya-specific URLSession wrapper. That would obviously come with it's own list of pros and cons.

@AndrewSB
Copy link
Member Author

@scottrhoyt: I was able to use spm to deploy an iOS app (I only had one private dependency), but it was very similar to using a submodule. swift package update pulled down the files and built a binary (that I ignored), and then I dragged the source files into my iOS xcodeproj

not ideal, but it worked

@scottrhoyt
Copy link
Contributor

Thanks @AndrewSB. That is good to know. Like you said, you were using it very similarly to a submodule. I suspect you could get Moya to build just fine using a similar method. Even though swift build might fail, you can drag the resolved dependencies' source files into an Xcode project and build from there. To get swift build to work is another matter.

The core of the issue holding up Alamofire seems to be a dependency on a newer version of Foundation than the version SPM defaults to. The solution proposed by the Alamofire maintainers is to basically use Xcode configurations to override this behavior. A pure SPM solution would involve being able to depend upon specific Apple frameworks within Package.swift--this is what currently doesn't exist.

If the goal of getting SPM working for Moya is to add Linux support (as opposed to another macOS-based dependency manager), then the Foundation dependencies within Alamofire will likely only cause even more headaches. This is because of the how Foundation is deployed on Linux (bundled with Swift and not available via SPM) and how it is out of sync with Foundation on Apple platforms in terms of both API naming conventions and missing functionality. This makes smaller projects a hassle to port to Linux and maintain that support. I can imagine Alamofire would be a much larger undertaking.

@scottrhoyt
Copy link
Contributor

Hey @AndrewSB, I took a look at this and realized it just needed one small change to build correctly via SPM. Might be a good idea to add an SPM build job to CI to catch these kind of things in the future (could be a separate PR), but this is looking good! 👍

@AndrewSB
Copy link
Member Author

AndrewSB commented Jan 2, 2017

I'm going to retarget this PR to come off #885.
Hopefully we'll have Alamofire cooperating soon so we can merge this in 👌

@scottrhoyt
Copy link
Contributor

Try a swift build with that commit that I pushed. I think it builds fine now.

@AndrewSB
Copy link
Member Author

AndrewSB commented Jan 3, 2017

I'll check it out

@AndrewSB
Copy link
Member Author

AndrewSB commented Jan 3, 2017

Woah, that was awesome. Cool, I'll cherry pick two commits onto Moya's master and we should be ready to go here

@AndrewSB AndrewSB changed the base branch from spm-root-dir-layout to master January 3, 2017 01:20
@MoyaBot
Copy link

MoyaBot commented Jan 3, 2017

1 Warning
⚠️ Consider adding supporting documentation to this change. Documentation can be found in the docs directory.

Generated by 🚫 danger

@codecov-io
Copy link

codecov-io commented Jan 3, 2017

Current coverage is 73.46% (diff: 100%)

Merging #643 into master will not change coverage

@@             master       #643   diff @@
==========================================
  Files            19         19          
  Lines           701        701          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits            515        515          
  Misses          186        186          
  Partials          0          0          

Powered by Codecov. Last update ea1406d...fc99d7e

@AndrewSB AndrewSB changed the title [WIP] Swift package manager support Swift package manager support Jan 3, 2017
@AndrewSB AndrewSB merged commit d0e2edc into master Jan 3, 2017
@AndrewSB AndrewSB deleted the swift-package-manager branch January 3, 2017 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants