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

ref #623 - add SwiftUI example #635

Closed

Conversation

lvnkmn
Copy link
Contributor

@lvnkmn lvnkmn commented Nov 4, 2019

Adds example which shows how to use Hero in combination with SwiftUI, like asked for in #623.

Screenshot 2019-11-04 at 10 23 06

8E94FEC5-DAA1-4412-89E6-F028058D2BBE 2019-11-04 10_35_12

@lvnkmn
Copy link
Contributor Author

lvnkmn commented Nov 4, 2019

I see some checks here are failing. I'm pretty sure this has to do with me setting the example target to iOS 13, without it, the SwiftUI previews would not work.

@iDevid
Copy link
Collaborator

iDevid commented Nov 4, 2019

you can use if #available(iOS 13.0, *) instead of change iOS Target

@lvnkmn
Copy link
Contributor Author

lvnkmn commented Nov 4, 2019

@iDevid on it 👌

@lvnkmn
Copy link
Contributor Author

lvnkmn commented Nov 4, 2019

Ok, I've made the suggested change. However like I mentioned earlier, the downside of this is that the SwiftUI previews won't show within Xcode using this approach.

In order to make the previews show, the target has to (temporarily) be set to iOS 13 +

@kuyazee
Copy link
Member

kuyazee commented Nov 4, 2019

Ok, I've made the suggested change. However like I mentioned earlier, the downside of this is that the SwiftUI previews won't show within Xcode using this approach.

In order to make the previews show, the target has to (temporarily) be set to iOS 13 +

I think that's okay, normally we won't use SwiftUI with UIKit anyway.

@lvnkmn
Copy link
Contributor Author

lvnkmn commented Nov 4, 2019

Ok, I've made the suggested change. However like I mentioned earlier, the downside of this is that the SwiftUI previews won't show within Xcode using this approach.
In order to make the previews show, the target has to (temporarily) be set to iOS 13 +

I think that's okay, normally we won't use SwiftUI with UIKit anyway.

Cool, will leave it like this then. Regarding the failing tests, I don’t know how I’d have to resolve them since everything seemed to just work on my machine...

@@ -0,0 +1,90 @@
import UIKit
import SwiftUI
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you wrap this while class in,

#if canImport(SwiftUI)
...
#endif

So that persons using older versions of XCode don't receive build errors.

You may need to wrap other code in the same block if they reference these classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will do that tomorrow 👌

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've done what you suggested, however the checks related to that are still failing. I have no clue why that is. Hope you do.

I will still attempt to fix this one:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, that last check is fixed now. Clueless on how to improve this code now. Looking forward to hearing an update from you @JoeMatt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JoeMatt do you have any updates for me on how we can get this merged?

@JoeMatt
Copy link
Collaborator

JoeMatt commented Dec 11, 2019

/rebase

@JoeMatt
Copy link
Collaborator

JoeMatt commented Dec 12, 2019

Tested and merged externally of github #9631cb96fde7a0045422647fc1ec8481df968bd1

@JoeMatt JoeMatt closed this Dec 12, 2019
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.

4 participants