Bring widgets to new places

RSS for tag

Discuss the WWDC23 Session Bring widgets to new places

Posts under wwdc2023-10027 tag

9 Posts

Post

Replies

Boosts

Views

Activity

WidgetExtension Crashes on launch in Xcode 15 Beta 3
When applied .contentMarginsDisabled() modifier to WidgetConfiguration, Widget extension crashes on launch in Xcode 15 Beta 3. struct TestWidget: Widget { let kind: String = "TestWidget" var body: some WidgetConfiguration { return IntentConfiguration(kind: kind, intent: TestIntent.self, provider: TestProvider()) { entry in TestView(entry: entry) } .configurationDisplayName("TestWidget") .description("This is TestWidget.") .supportedFamilies([.systemMedium]) .contentMarginsDisabled() // << Here } } Though it works in Xcode 15 Beta 2. Anyone facing same issue ?
4
0
1.8k
Oct ’23
Widget showsWidgetContainerBackground fallback
To bring my widgets to iPad lock screen, i need to detect my widget that has a background to display different contents, watch the wwdc 23 video it tells we can use .showsWidgetContainerBackground environment to apply that goal, but the problem is this code wouldn't compile because .showsWidgetContainerBackground only available in iOS 17 @available(iOS 14.0, *) struct MyWidgetView: View { @Environment(\.showsWidgetContainerBackground) var showsBackground var body: some View { ... } } So, my solution is use a environment wrapper, like this: @available(iOS 17.0, *) struct EnvironmentWrapper: View { @Environment(\.showsWidgetContainerBackground) var showsWidgetContainerBackground var body: some View { VStack(alignment: .leading) { Text("Wrapper Has Background: \(showsWidgetContainerBackground ? "YES" : "NO")") } } } extension View { var showsWidgetContainerBackground: Bool { if #available(iOS 17.0, *) { return EnvironmentWrapper().showsWidgetContainerBackground } else { return true } } } But it didn't work, this is the example: @available(iOS 17.0, *) struct EnvironmentWrapper: View { @Environment(\.showsWidgetContainerBackground) var showsWidgetContainerBackground var body: some View { VStack(alignment: .leading) { Text("Wrapper has background: \(showsWidgetContainerBackground ? "YES" : "NO")") } } } @available(iOS 17.0, *) struct ExampleView: View { @Environment(\.showsWidgetContainerBackground) var showsBackground var body: some View { VStack(alignment: .leading) { Text("Read from self: \(showsBackground ? "YES" : "NO")") EnvironmentWrapper() Text("Read from wrapper: \(EnvironmentWrapper().showsWidgetContainerBackground ? "YES" : "NO")") } .font(.system(size: 12, weight: .medium)) } } As you can see, if i read it directly from self, it works, but if i read from outside, it always return true i also try to load a view first in the wrapper, but it didn't work either func getShowsBackground() -> Bool { let _ = body return showsWidgetContainerBackground }
8
2
3k
Sep ’23
How to use AccessoryWidgetBackground with containerBackground API on iOS 17
I have an accessoryCircular Lock Screen widget built for iOS 16: ZStack { AccessoryWidgetBackground() VStack { Text("MON") .font(.caption) Text("6") .font(.title) } } When run on iOS 17 it renders an error “Please adopt containerBackground API”. So I changed it to: VStack { Text("MON") .font(.caption) Text("6") .font(.title) } .containerBackground(for: .widget) { AccessoryWidgetBackground() } This causes the error to go away but the circular background is no longer visible (tested with iPadOS 17b2). What’s the right way to implement this?
2
1
2.6k
Sep ’23
iOS LiveActivityIntent can not find in TestFlight
hi, all I'm in the process of adapting a new feature to my live activity, which allows users to interact directly with the live activity using button(intent), without having to jump to the app. I've implemented an intent using LiveActivityIntent, the intent code is included in the main app and widget target, and all the functionality and logic works perfectly in the debug mode. After I submitted it to testflight in release mode and installed it on the real machine, I tested the above functionality and found that it doesn't work. I checked the logs of the phone and found that there is a similar error in the console Could not find an intent with identifier xxxxxIntent, mangledTypeName: Optional("xxxxxV"), the TypeName in the last part of the log has one more "V" than my real code, and I made sure that there is no such V in the code.
1
0
958
Sep ’23
ios 17 interactive widget api call in background
ios 17 interactive widget api call in background An API request is being made through Interactive widget in iOS 17.0 version. The desired situation is to request an API through the widget's Intent and receive a response from the server. (Because it is opened from Intent, the app does not open.) But a problem occurred here. When both the main app and the widget are built, the above request works well. However, even if the build is stopped, the request is made normally if the app is in the foreground state. However, when the app is in the background, API calls are not made through Intent. How can I solve this? Desired situation: API call request through App Intent under any network condition when the app is turned off (may not be reflected separately in the widget) Problem Situation: API call through Celluar data fails when the app is turned off. What's currently working properly: Successful API call through Wi-Fi when the app is turned off Api call is successful under any network conditions when the app is turned on.
0
0
1.3k
Sep ’23
showsWidgetContainerBackground crashes on iOS17 beta 6 on a real device
When using @Environment(.showsWidgetContainerBackground) inside any view, the app and widgets crash in a real device with iOS17 beta 6. The same build works perfectly on simulators and a real device running iOS17 beta 5. Using XCode 15 beta 6 to build the app. I am getting this error: Symbol not found: _$s7SwiftUI17EnvironmentValuesV9WidgetKitE05showsE19ContainerBackgroundSbvg I just created a new blank project and only added that line and it crashes. Filled a feedback report. I am the only one? struct ContentView: View { @Environment(\.showsWidgetContainerBackground) var showsBackground: Bool var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") } .padding() } }
4
0
1.1k
Aug ’23
Widget does not show up in search widget menu after .contentMarginsDisabled() in ios16
Hi, I'm playing with the new xcode 15 beta and am trying to solve the extra paddings around the widget by adding .contentMarginsDisabled() at the end as instructed by https://developer.apple.com/videos/play/wwdc2023/10027/ IntentConfiguration(...) ... .contentMarginsDisabled() } it works fine for ios17 and actually fixed my extra padding problem, but on ios16 the app is not shown in the search widget menu anymore, anyone ran into the same issue?
3
2
2.4k
Jul ’23
How in interactive widgets in ios 17 to prevent the opening of the application by clicking on the widget?
How in interactive widgets in ios 17 to prevent the opening of the application by clicking on the widget? Sometimes the user may miss the button and opening the application is inappropriate in this case
Replies
10
Boosts
2
Views
5.2k
Activity
Mar ’24
WidgetExtension Crashes on launch in Xcode 15 Beta 3
When applied .contentMarginsDisabled() modifier to WidgetConfiguration, Widget extension crashes on launch in Xcode 15 Beta 3. struct TestWidget: Widget { let kind: String = "TestWidget" var body: some WidgetConfiguration { return IntentConfiguration(kind: kind, intent: TestIntent.self, provider: TestProvider()) { entry in TestView(entry: entry) } .configurationDisplayName("TestWidget") .description("This is TestWidget.") .supportedFamilies([.systemMedium]) .contentMarginsDisabled() // << Here } } Though it works in Xcode 15 Beta 2. Anyone facing same issue ?
Replies
4
Boosts
0
Views
1.8k
Activity
Oct ’23
Widget showsWidgetContainerBackground fallback
To bring my widgets to iPad lock screen, i need to detect my widget that has a background to display different contents, watch the wwdc 23 video it tells we can use .showsWidgetContainerBackground environment to apply that goal, but the problem is this code wouldn't compile because .showsWidgetContainerBackground only available in iOS 17 @available(iOS 14.0, *) struct MyWidgetView: View { @Environment(\.showsWidgetContainerBackground) var showsBackground var body: some View { ... } } So, my solution is use a environment wrapper, like this: @available(iOS 17.0, *) struct EnvironmentWrapper: View { @Environment(\.showsWidgetContainerBackground) var showsWidgetContainerBackground var body: some View { VStack(alignment: .leading) { Text("Wrapper Has Background: \(showsWidgetContainerBackground ? "YES" : "NO")") } } } extension View { var showsWidgetContainerBackground: Bool { if #available(iOS 17.0, *) { return EnvironmentWrapper().showsWidgetContainerBackground } else { return true } } } But it didn't work, this is the example: @available(iOS 17.0, *) struct EnvironmentWrapper: View { @Environment(\.showsWidgetContainerBackground) var showsWidgetContainerBackground var body: some View { VStack(alignment: .leading) { Text("Wrapper has background: \(showsWidgetContainerBackground ? "YES" : "NO")") } } } @available(iOS 17.0, *) struct ExampleView: View { @Environment(\.showsWidgetContainerBackground) var showsBackground var body: some View { VStack(alignment: .leading) { Text("Read from self: \(showsBackground ? "YES" : "NO")") EnvironmentWrapper() Text("Read from wrapper: \(EnvironmentWrapper().showsWidgetContainerBackground ? "YES" : "NO")") } .font(.system(size: 12, weight: .medium)) } } As you can see, if i read it directly from self, it works, but if i read from outside, it always return true i also try to load a view first in the wrapper, but it didn't work either func getShowsBackground() -> Bool { let _ = body return showsWidgetContainerBackground }
Replies
8
Boosts
2
Views
3k
Activity
Sep ’23
How to use AccessoryWidgetBackground with containerBackground API on iOS 17
I have an accessoryCircular Lock Screen widget built for iOS 16: ZStack { AccessoryWidgetBackground() VStack { Text("MON") .font(.caption) Text("6") .font(.title) } } When run on iOS 17 it renders an error “Please adopt containerBackground API”. So I changed it to: VStack { Text("MON") .font(.caption) Text("6") .font(.title) } .containerBackground(for: .widget) { AccessoryWidgetBackground() } This causes the error to go away but the circular background is no longer visible (tested with iPadOS 17b2). What’s the right way to implement this?
Replies
2
Boosts
1
Views
2.6k
Activity
Sep ’23
iOS LiveActivityIntent can not find in TestFlight
hi, all I'm in the process of adapting a new feature to my live activity, which allows users to interact directly with the live activity using button(intent), without having to jump to the app. I've implemented an intent using LiveActivityIntent, the intent code is included in the main app and widget target, and all the functionality and logic works perfectly in the debug mode. After I submitted it to testflight in release mode and installed it on the real machine, I tested the above functionality and found that it doesn't work. I checked the logs of the phone and found that there is a similar error in the console Could not find an intent with identifier xxxxxIntent, mangledTypeName: Optional("xxxxxV"), the TypeName in the last part of the log has one more "V" than my real code, and I made sure that there is no such V in the code.
Replies
1
Boosts
0
Views
958
Activity
Sep ’23
ios 17 interactive widget api call in background
ios 17 interactive widget api call in background An API request is being made through Interactive widget in iOS 17.0 version. The desired situation is to request an API through the widget's Intent and receive a response from the server. (Because it is opened from Intent, the app does not open.) But a problem occurred here. When both the main app and the widget are built, the above request works well. However, even if the build is stopped, the request is made normally if the app is in the foreground state. However, when the app is in the background, API calls are not made through Intent. How can I solve this? Desired situation: API call request through App Intent under any network condition when the app is turned off (may not be reflected separately in the widget) Problem Situation: API call through Celluar data fails when the app is turned off. What's currently working properly: Successful API call through Wi-Fi when the app is turned off Api call is successful under any network conditions when the app is turned on.
Replies
0
Boosts
0
Views
1.3k
Activity
Sep ’23
showsWidgetContainerBackground crashes on iOS17 beta 6 on a real device
When using @Environment(.showsWidgetContainerBackground) inside any view, the app and widgets crash in a real device with iOS17 beta 6. The same build works perfectly on simulators and a real device running iOS17 beta 5. Using XCode 15 beta 6 to build the app. I am getting this error: Symbol not found: _$s7SwiftUI17EnvironmentValuesV9WidgetKitE05showsE19ContainerBackgroundSbvg I just created a new blank project and only added that line and it crashes. Filled a feedback report. I am the only one? struct ContentView: View { @Environment(\.showsWidgetContainerBackground) var showsBackground: Bool var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") } .padding() } }
Replies
4
Boosts
0
Views
1.1k
Activity
Aug ’23
WidgetKit_Simulator.WidgetDocument.Error
While I try to run the widgetKit extension in xcode 15.0 beta versions, I am facing the "WidgetKit_Simulator.WidgetDocument.Error" error. Even after the app is run successfully, the app widget is not showing on the home screen to add it.
Replies
0
Boosts
0
Views
803
Activity
Aug ’23
Widget does not show up in search widget menu after .contentMarginsDisabled() in ios16
Hi, I'm playing with the new xcode 15 beta and am trying to solve the extra paddings around the widget by adding .contentMarginsDisabled() at the end as instructed by https://developer.apple.com/videos/play/wwdc2023/10027/ IntentConfiguration(...) ... .contentMarginsDisabled() } it works fine for ios17 and actually fixed my extra padding problem, but on ios16 the app is not shown in the search widget menu anymore, anyone ran into the same issue?
Replies
3
Boosts
2
Views
2.4k
Activity
Jul ’23