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

Fails to build when accessed via notification content extension #278

Closed
3 tasks done
grosch opened this issue Oct 31, 2020 · 15 comments
Closed
3 tasks done

Fails to build when accessed via notification content extension #278

grosch opened this issue Oct 31, 2020 · 15 comments
Labels

Comments

@grosch
Copy link
Contributor

grosch commented Oct 31, 2020

New Issue Checklist

Issue Description

I'm using a new SwiftUI app to update my existing project. The only place I use CalendarKit is in the notification content extension, which is still UIKit. I added your library via SPM and made sure to point at the master branch. I'm using the exact same code as the original version used. The only difference is that one was done via CocoaPods and this one is of course using Swift Package Manager.

As soon as I use something like TimelineView I'm getting tons of errors.

Code I'm using with CalendarKit
let timeline = TimelineView()

That line, for example, will result in these errors:

Undefined symbol: type metadata accessor for CalendarKit.TimelineView
Undefined symbol: CalendarKit.TimelineView.__allocating_init() -> CalendarKit.TimelineView

NotificationViewController.txt

@grosch
Copy link
Contributor Author

grosch commented Oct 31, 2020

Here's a minimal example showing it.

I create a new app, added a content extension, added your package, and it builds fine. Then edit NotificationViewController.swift to create a TimelineView and the errors appear.

example.zip

@richardtop
Copy link
Owner

Thanks for reporting it, I'll look into it. Does it work well when used with CocoaPods?

@richardtop richardtop added the bug label Oct 31, 2020
@grosch
Copy link
Contributor Author

grosch commented Oct 31, 2020

Another data point as I keep playing. If I access it from the primary app target it's fine. So it appears to be something to do with accessing it from the other target specifically. I've seen issues reported where SPM fails when new targets are added later, and I explicitly made sure that all the targets were created before I added your package.

I would assume it would still work OK with cocoapods as that's how it was originally done. This seems to be specific to SPM, which I definitely want to use, as I'm updating the Push Notifications book from raywenderlich.com to be current.

@richardtop
Copy link
Owner

What's the Xcode version you're using?
Are there going to be some CalendarKit Ray Wenderlich tutorials?

@grosch
Copy link
Contributor Author

grosch commented Oct 31, 2020

Version 12.2 beta 2 (12B5025f)

Tutorials, no. But in my Push Notifications book, in chapter 12 where I show a "real world" full example, it uses CalendarKit to handle showing the calendar in the push notification itself.

@richardtop
Copy link
Owner

Thanks for the info.
I was able to find the sample, looks good! Never thought this is mentioned in a book. I'd appreciate a copy if possible just to keep it.

Also, if you wish I might review the way CK is used in the book to see if something could be improved.

Overall, could you please triangulate the root cause of this problem, more precisely, is it an Xcode BETA issue or a CK issue?

@grosch
Copy link
Contributor Author

grosch commented Oct 31, 2020

Chuckle, you just don't remember. I bugged the crap out of you a few years ago figuring out how to make this work. It only does cause you pointed me at the timeline stuff :) I'd love to have you review how it works though. Might be better ways now. The complete code is in the NotificationViewController.txt attachment I did when opening the issue.

It's seems to be explicitly a bug with how SPM is working with CK. I found a bunch of articles saying if you remove the dead code stripping it'll work, but that's not fixing it, and is also bad for SwiftUI projects as it depends on that for removing all the preview related code.

@richardtop
Copy link
Owner

I do remember.
On the surface, your code looks correct, without any significant issues.

This might be related to referencing DateTools, although I'm not sure about it. Are you including the library into the project?

@richardtop
Copy link
Owner

Also, build fails for me in the attached example

@grosch
Copy link
Contributor Author

grosch commented Nov 1, 2020

When I include CK it automatically adds DateToolsSwift as a dependency as well. I did try and explicitly add that one as an import but it made no difference.

@grosch
Copy link
Contributor Author

grosch commented Nov 1, 2020

Oh, and I asked the publisher about getting you a copy of the book.

@richardtop
Copy link
Owner

richardtop commented Nov 1, 2020

Thank you. Okay, could this be related to the latest pull request? #277
We could just wait for the Xcode 12.2 to go out of beta and use CocoaPods right now. The problem is likely to resolve itself.

@grosch
Copy link
Contributor Author

grosch commented Nov 1, 2020

Nope. However, I found a workaround. I realized I'm only using your package in the other target, so I delete and re-added your package but this time noticed that I can pick which target to add as a dependency, so I picked the content extension and now I'm good.

As to the book...If you give me your email address the publisher will get you hooked up with a book.

@richardtop
Copy link
Owner

Ok, so just to be clear: the issue is resolved now and everything works as expected.
My email is topchiy@protonmail.ch

@grosch
Copy link
Contributor Author

grosch commented Nov 1, 2020

Yes, the issue is resolved and had nothing to do with your package.

@grosch grosch closed this as completed Nov 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants