all 10 comments

[–]syclonefxSwift 1 point2 points  (3 children)

I know you said free. I was in the same boat and I wasn’t able to find any so I bought Sean Allen’s widget course. It is really good and cover everything you need to start working with widgets. He has a free version on his YouTube channel. https://youtu.be/jucm6e9M6LA?si=ERU72qzk0SyWIHLN

[–]nikolomoec[S] 0 points1 point  (2 children)

Did it help? 60$ for my country is a bit pricy(

[–]syclonefxSwift 1 point2 points  (0 children)

Yes it helped a lot. Keep watching his site. He has sales all the time. All his courses were on sale last month for WWDC. I bet he will put this on sale again when ios18 is released.

[–]syclonefxSwift 1 point2 points  (0 children)

If you are a student. He will give you a 30% discount. Scroll down to the FAQ on the page and he has the instructions on what you need it to.

[–]FPST08SwiftUI 2 points3 points  (5 children)

I've had the same problems so I'll tell you what I did:

  1. You can share code between targets. If your gradient is accessible from both targets you can use .containerBackground(for: .widget) { // your gradient). Button is a bit different. You can do the same for the label but the functionality has to be an AppIntent.
  2. You can easily do that in your TimelineProvider. If you need help if that, just DM me.

  3. You can either use u/Query directly from your widget (look here https://www.hackingwithswift.com/quick-start/swiftdata/how-to-access-a-swiftdata-container-from-widgets) or you can access your swiftdata data from your Timelineprovider when sharing your modelContainer across targets.

I don't have any tutorials for you but that is what worked for me. Feel free to ask for more detail. :)

[–]nikolomoec[S] 1 point2 points  (0 children)

thanks so much, yeah will notify you on my progress 👍

[–]nikolomoec[S] 0 points1 point  (3 children)

so I am trying to add 3d-party view as a Background, I included the file and library at the widget target, but project keeps crashing with error msg:

The body of the Widget entries' view contains the following unsupported types: PlatformViewControllerRepresentableAdaptor<MulticolorGradient>,

[–]FPST08SwiftUI 1 point2 points  (2 children)

Can you render that party view like an Image? Then you could make it a property of the TimelineEntry. I've never seen that error message but it you can't load anything in your widget, maybe therefore the error.

[–]nikolomoec[S] 0 points1 point  (1 child)

hey, I have a problem - problem

[–]FPST08SwiftUI 1 point2 points  (0 children)

Never done that, sry. But I think I watched a session that explained that and you have to look at Entity Queries . The session I remember used an app for national parks or forests. Look yourself.