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 #122

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

billbonney
Copy link

Hi.

This pull-request merges the current bug fixes and support for Swift Package Manager into a working code base.

You may consider merging the changes in a different order, but for now this works as reference for others looking for a working package with SPM support.

Hope this helps :) 👍

@hiroraba
Copy link
Contributor

Hello @kylef.

I just wanted to let you know how much I appreciate your open-source project. It has proven to be incredibly useful and has become an essential tool for me.

As I plan to continue using it in the future, I would like to kindly request that you consider adding support for the Swift Package Manager. This would greatly enhance its usability and make it even more valuable for users like myself.

Thank you for your hard work and dedication to the project, and I look forward to seeing it continue to evolve.

@implementation MockingjayURLConfiguration

+ (void)load {
[NSURLSessionConfiguration mockingjaySwizzleDefaultSessionConfiguration];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This *.m file should be moved into YourProjectTests target, otherwise swizzling happens too lately. I understand the reason why you have removed this file, because SPM cannot compile source files in mixed languages. But it dramatically breaks swizzling

@@ -40,7 +40,9 @@ public class MockingjayProtocol: URLProtocol {
stubs.append(stub)

if !registered {
URLProtocol.registerClass(MockingjayProtocol.self)
MockingjayURLSessionConfiguration.swizzleDefaultSessionConfiguration()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the problem, that swizzling happens too lately. Previously it was called right after the app instance has been loaded into memory in [NSObject load]; method, and then app used swizzled version of URLSessionConfiguration.default in tests target. Have to move MockingjayURLSessionConfiguration.m file into MyProjectTests target and add @import Mockingjay;

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.

6 participants