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

Make markymark safe to use in extensions #71

Closed
mhoeller-clue opened this issue Nov 13, 2018 · 6 comments
Closed

Make markymark safe to use in extensions #71

mhoeller-clue opened this issue Nov 13, 2018 · 6 comments

Comments

@mhoeller-clue
Copy link

Currently, when trying to use markymark via cocoapods, and linking it into a framework, we get the compiler error 'shared' is unavailable: Use view controller based solutions where appropriate instead.. This is because UIApplication cannot be used from extensions or dynamically linked frameworks.
A possible solution to make markymark extension safe is outlined here: https://gist.github.com/natecook1000/151d8de423eb77fc87bf#gistcomment-1656503

@jvanzummeren
Copy link
Contributor

jvanzummeren commented Nov 13, 2018

Thanks for your input.

Is it possible to be any more specific? Which parts of markymark are not safe for extensions/frameworks and what solution are you proposing?

Regards,

Jim

@mhoeller-clue
Copy link
Author

The problem is the use of UIApplication.shared.openURL(url) in AttributedInteractiveLabel. UIApplication is not extension safe.
The proposed solution is to "hide" the API usage by using NSClassFromString(@"UIApplication") instead of UIApplication directly. This approach apparently also worked for SDWebImage.

@mhoeller-clue
Copy link
Author

An alternate, less hacky, solution could be delegation, where AttributedInteractiveLabel would have a delegate that gets informed about opening the url, but that might be a breaking change in the API. Also the AttributedInteractiveLabel will not be a drop-in solution any more if link handling is required.

@jvanzummeren
Copy link
Contributor

Thanks for your input @mhoeller-clue, i looked into your pull-request and made #74 inspired by your approach.

This pull request will allow markymark to compile in extension by using NSSelectorFromString("sharedApplication") instead using UIApplication.shared directly.

Also, this pull request will allow customization of the open url behavior by providing an implementation of URLOpener

My collegues will review the pull request and i will let you know as soon as i release a new version. Also, let me know what you think of this approach!

@mhoeller-clue
Copy link
Author

Looks perfect! It has much deeper integration throughout the system and extends the example project too 👍
Thanks for putting the work into this library! Looking forward to the new version.

@jvanzummeren
Copy link
Contributor

Just release the new version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants