Post

Replies

Boosts

Views

Activity

Xcode Error: displayModeButtonItem is internally managed and not exposed for DoubleColumn style. Returning an empty, disconnected UIBarButtonItem to fulfill the non-null contract
I am working a lot with SwiftUI recently and encountered a problem when controlling NavigationLinks from outside the NavigationView with a @State. Error Message: [Assert] displayModeButtonItem is internally managed and not exposed for DoubleColumn style. Returning an empty, disconnected UIBarButtonItem to fulfill the non-null contract What Do I do? I am using a Button outside a NavigationView to control a hierarchy of NavigationLinks inside the NavigationView via @State Properties which the Button is manipulating. struct OnboardingRoot: View { 		@State var didCompletFirstView: Bool = false 		@State var didCompleteSecondView: Bool = false 		@State var didCompleteThirdView: Bool = false 		var body: some View { 				ZStack { 						 						NavigationView { 								Text("View 1") 										.background( 												NavigationLink(destination: Text("View 2"), isActive: $didCompleteFirstView) { EmptyView() } 										) 								/* This Hierarchy contains a Total of 4 Screens !!! */ 						} 						 						VStack { 								Spacer() 								Button(action: { print("Calls a Function that updates the States accordingly.") }) { CustomButton(text: "Start") } 						} 				} 		} } The Problem: As soon as I move to the Third Screen, I get the Error Message above. And also when moving between the Third and Fourth Screen, thee behavior is changing more or less to Random. *For example when finishing Screen 3, it comes again instead of Screen 4 and more.* My Solution for this Problem: I was browsing for possible Solutions and found one Solution that seems to does the Job .navigationViewStyle(StackNavigationViewStyle()) My Question: Although this Line of Code does the Job, removes the Error Messages and prevents this Random Behavior, I could't find an Explanation of what causes the Error and why this is able to solve it. So if you have an Idea, please share it with me. Thanks for your Help.
5
0
4.9k
Sep ’21
Swift: How to change DetailView depending on SideBar Selection State with SwiftUI 4?
Context I have a problem with the new SwiftUI SideBar / NavigationLink concept. I have created a simple 2 Column NavigationSplitView with a SideBar and a DetailView. Once the App is launched, the preselected Timeline RootView appears as the DetailView. However, when I select a different SideBar Item, the DetailView does not change accordingly. Code struct SideBar: View { @State private var navigationItem: NavigationItem? = .timeline var body: some View { NavigationSplitView { List(NavigationItem.allCases, id: \.self, selection: $navigationItem) { navigationItem in NavigationLink(value: navigationItem) { Label(navigationItem.name, systemImage: navigationItem.symbol) } } } detail: { if let safeNavigationItem = navigationItem { safeNavigationItem.rootView } else { Text(String(localized: "select.an.option", defaultValue: "Select an Option")) } } } } Question Do you have any idea how I can solve this issue? Thanks a lot for your support in advance. Note: Just ran it on macOS, it is working there. However, still not working on iPadOS.
1
0
1.8k
Jul ’22
Swift: How to use an Array of a Protocol Type inside a SwiftUI ForEach?
Context Hey there, I am currently working with Protocols in SwiftUI and encountered a Problem. I have an Array of a Protocol Type and would like to use it to populate a SwiftUI ForEach View. However, this throws the following error: Type 'any Component' cannot conform to 'Identifiable' Code protocol Component: ObservableObject, Identifiable { var name: String { get } } struct ComponentsView: View { var body: some View { ForEach(components) { component in // Error in this Line Text(component.name) } } private var components: [any Component] { return [] } } Question How can I populate my SwiftUI ForEach View with the Array of Components?
1
1
2.6k
Aug ’22
How to pass a Swift Type into an Generic SwiftUI View?
Context I am working with Generic SwiftUI Views and encountered a problem. I have a Generic SwiftUI View and when calling it, I need to specify the Type. However, I get this Type only as a return parameter from a method in an any format. The following Code produces the following Compiler Error: Failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project Cannot find type 'componentType' in scope Code protocol Component { var name: String { get } } struct GenericView<C: Component>: View { var component: C? var body: some View { Text(component.name) } } struct MainView: View { var body: some View { GenericView<componentType>() } private var componentType: any Component.Type { // This returns a specific Component Type, e.g. ComponentA.self } } Question How can I achieve my goal of adjusting the Generic Type of GenericView depending on a Parameter / Method Return Value?
1
1
1.8k
Aug ’22
How to check if Data Type equals Generic Data Type and assign to Property if True?
Context I have a Generic Swift Class containing a component Property of the Generic Type. A few other Variables with different Data Types are passed through the Initializer, however, all of them are conforming to the Generic Protocol. However, I get the following Compiler Error in Line 11: 'ComponentA' is not convertible to 'C' Code protocol Component { ... } struct ComponentA: Component { ... } struct ComponentB: Component { ... } class Main&lt;C: Component&gt; { var component: C init(componentA: ComponentA, componentB: ComponentB) { // I am trying to check, whether componentA equals the Generic Data Type and assign it to the component Property if true. if case let safeComponent = componentA as C { self.component = safeComponent } } } Question How can I achieve my goal of checking whether a Data Type equals the Generic Data Type and assign it to the component Property if true?
1
0
940
Aug ’22
How to automatically update SwiftUI View depending on an ObservableObject hidden as an Associated Value of an Enum Property?
Context I have an Enum where one of its Cases has an ObservableObject as an Associated Value. I also have a SwiftUI View with a Property of this Enum. This View displays Data of the associated ObservableObject, if applicable. However, since I can't define the Enum itself as an ObservedObject, the UI does not change when the associated ObservableObject changes. Code // This is actually a CoreData NSManagedObject. class CustomComponent: ObservableObject { ... } enum Component { case componentA case componentB case custom(_ customComponent: CustomComponent) static func getComponents(with customComponents: FetchedResults<CustomComponent>) -> [Component] { var components = [.componentA, .componentB] for customComponent in customComponents { components.append(.custom(customComponent)) } return components } var name: String { switch self { case .componentA: return "Component A" case .componentB: return "Component B" case .custom(let customComponent): return customComponent.name } } } struct ComponentsView: View { @FetchRequest(sortDescriptors: [SortDescriptor(\.name)]) private var customComponents: FetchedResults<CustomComponent> var body: some View { ForEach(Component.getComponents(with: customComponents)) { component in ComponentView(with: component) } } } struct ComponentView: View { // I can't define this as ObservedObject, however, this View should update when the associated ObservableObject updates. let component: Component var body: some View { Text(component.name) } } Question How can I achieve my goal, that, even though the ObservableObject is hidden as an Associated Value of an Enum, the ComponentView updates when the Associated Value changes?
0
0
843
Sep ’22
Visibility on the App Store Option of In-App Purchases
Context When adding an Advertising Graphic to an In-App Purchase in App Store Connect, a new option called Visibility on the App Store pops up, however, I am not quite sure what this means. The two available options are the following: This promotion will be shown to all App Store users, including those who have not installed your app. This promotion will be shown only to users who meet your conditions in the app. Question What is the difference between these two options and which should be used for basically just displaying In-App Purchases on the App Store?
0
1
1.1k
Nov ’22
Apple Search Ads and App Store Connect
Hello there, I am running an Apple Search Ads campaign and am wondering whether these anorganic downloads generated from this campaign are included on App Store Connect. You have two different places in App Store Connect where you can find Download / App Unit informations: Analytics and Trends. Question: Are Search Ads campaign downloads included in these two spots, or just in one of them or in none of them? Thanks a lot for your help!
1
0
1.3k
Apr ’23
Xcode Error: displayModeButtonItem is internally managed and not exposed for DoubleColumn style. Returning an empty, disconnected UIBarButtonItem to fulfill the non-null contract
I am working a lot with SwiftUI recently and encountered a problem when controlling NavigationLinks from outside the NavigationView with a @State. Error Message: [Assert] displayModeButtonItem is internally managed and not exposed for DoubleColumn style. Returning an empty, disconnected UIBarButtonItem to fulfill the non-null contract What Do I do? I am using a Button outside a NavigationView to control a hierarchy of NavigationLinks inside the NavigationView via @State Properties which the Button is manipulating. struct OnboardingRoot: View { &#9;&#9;@State var didCompletFirstView: Bool = false &#9;&#9;@State var didCompleteSecondView: Bool = false &#9;&#9;@State var didCompleteThirdView: Bool = false &#9;&#9;var body: some View { &#9;&#9;&#9;&#9;ZStack { &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;NavigationView { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text("View 1") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;.background( &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;NavigationLink(destination: Text("View 2"), isActive: $didCompleteFirstView) { EmptyView() } &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;/* This Hierarchy contains a Total of 4 Screens !!! */ &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;VStack { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Spacer() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Button(action: { print("Calls a Function that updates the States accordingly.") }) { CustomButton(text: "Start") } &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;} &#9;&#9;} } The Problem: As soon as I move to the Third Screen, I get the Error Message above. And also when moving between the Third and Fourth Screen, thee behavior is changing more or less to Random. *For example when finishing Screen 3, it comes again instead of Screen 4 and more.* My Solution for this Problem: I was browsing for possible Solutions and found one Solution that seems to does the Job .navigationViewStyle(StackNavigationViewStyle()) My Question: Although this Line of Code does the Job, removes the Error Messages and prevents this Random Behavior, I could't find an Explanation of what causes the Error and why this is able to solve it. So if you have an Idea, please share it with me. Thanks for your Help.
Replies
5
Boosts
0
Views
4.9k
Activity
Sep ’21
Swift: How to change DetailView depending on SideBar Selection State with SwiftUI 4?
Context I have a problem with the new SwiftUI SideBar / NavigationLink concept. I have created a simple 2 Column NavigationSplitView with a SideBar and a DetailView. Once the App is launched, the preselected Timeline RootView appears as the DetailView. However, when I select a different SideBar Item, the DetailView does not change accordingly. Code struct SideBar: View { @State private var navigationItem: NavigationItem? = .timeline var body: some View { NavigationSplitView { List(NavigationItem.allCases, id: \.self, selection: $navigationItem) { navigationItem in NavigationLink(value: navigationItem) { Label(navigationItem.name, systemImage: navigationItem.symbol) } } } detail: { if let safeNavigationItem = navigationItem { safeNavigationItem.rootView } else { Text(String(localized: "select.an.option", defaultValue: "Select an Option")) } } } } Question Do you have any idea how I can solve this issue? Thanks a lot for your support in advance. Note: Just ran it on macOS, it is working there. However, still not working on iPadOS.
Replies
1
Boosts
0
Views
1.8k
Activity
Jul ’22
Swift: How to use an Array of a Protocol Type inside a SwiftUI ForEach?
Context Hey there, I am currently working with Protocols in SwiftUI and encountered a Problem. I have an Array of a Protocol Type and would like to use it to populate a SwiftUI ForEach View. However, this throws the following error: Type 'any Component' cannot conform to 'Identifiable' Code protocol Component: ObservableObject, Identifiable { var name: String { get } } struct ComponentsView: View { var body: some View { ForEach(components) { component in // Error in this Line Text(component.name) } } private var components: [any Component] { return [] } } Question How can I populate my SwiftUI ForEach View with the Array of Components?
Replies
1
Boosts
1
Views
2.6k
Activity
Aug ’22
How to pass a Swift Type into an Generic SwiftUI View?
Context I am working with Generic SwiftUI Views and encountered a problem. I have a Generic SwiftUI View and when calling it, I need to specify the Type. However, I get this Type only as a return parameter from a method in an any format. The following Code produces the following Compiler Error: Failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project Cannot find type 'componentType' in scope Code protocol Component { var name: String { get } } struct GenericView<C: Component>: View { var component: C? var body: some View { Text(component.name) } } struct MainView: View { var body: some View { GenericView<componentType>() } private var componentType: any Component.Type { // This returns a specific Component Type, e.g. ComponentA.self } } Question How can I achieve my goal of adjusting the Generic Type of GenericView depending on a Parameter / Method Return Value?
Replies
1
Boosts
1
Views
1.8k
Activity
Aug ’22
How to check if Data Type equals Generic Data Type and assign to Property if True?
Context I have a Generic Swift Class containing a component Property of the Generic Type. A few other Variables with different Data Types are passed through the Initializer, however, all of them are conforming to the Generic Protocol. However, I get the following Compiler Error in Line 11: 'ComponentA' is not convertible to 'C' Code protocol Component { ... } struct ComponentA: Component { ... } struct ComponentB: Component { ... } class Main&lt;C: Component&gt; { var component: C init(componentA: ComponentA, componentB: ComponentB) { // I am trying to check, whether componentA equals the Generic Data Type and assign it to the component Property if true. if case let safeComponent = componentA as C { self.component = safeComponent } } } Question How can I achieve my goal of checking whether a Data Type equals the Generic Data Type and assign it to the component Property if true?
Replies
1
Boosts
0
Views
940
Activity
Aug ’22
How to automatically update SwiftUI View depending on an ObservableObject hidden as an Associated Value of an Enum Property?
Context I have an Enum where one of its Cases has an ObservableObject as an Associated Value. I also have a SwiftUI View with a Property of this Enum. This View displays Data of the associated ObservableObject, if applicable. However, since I can't define the Enum itself as an ObservedObject, the UI does not change when the associated ObservableObject changes. Code // This is actually a CoreData NSManagedObject. class CustomComponent: ObservableObject { ... } enum Component { case componentA case componentB case custom(_ customComponent: CustomComponent) static func getComponents(with customComponents: FetchedResults<CustomComponent>) -> [Component] { var components = [.componentA, .componentB] for customComponent in customComponents { components.append(.custom(customComponent)) } return components } var name: String { switch self { case .componentA: return "Component A" case .componentB: return "Component B" case .custom(let customComponent): return customComponent.name } } } struct ComponentsView: View { @FetchRequest(sortDescriptors: [SortDescriptor(\.name)]) private var customComponents: FetchedResults<CustomComponent> var body: some View { ForEach(Component.getComponents(with: customComponents)) { component in ComponentView(with: component) } } } struct ComponentView: View { // I can't define this as ObservedObject, however, this View should update when the associated ObservableObject updates. let component: Component var body: some View { Text(component.name) } } Question How can I achieve my goal, that, even though the ObservableObject is hidden as an Associated Value of an Enum, the ComponentView updates when the Associated Value changes?
Replies
0
Boosts
0
Views
843
Activity
Sep ’22
Visibility on the App Store Option of In-App Purchases
Context When adding an Advertising Graphic to an In-App Purchase in App Store Connect, a new option called Visibility on the App Store pops up, however, I am not quite sure what this means. The two available options are the following: This promotion will be shown to all App Store users, including those who have not installed your app. This promotion will be shown only to users who meet your conditions in the app. Question What is the difference between these two options and which should be used for basically just displaying In-App Purchases on the App Store?
Replies
0
Boosts
1
Views
1.1k
Activity
Nov ’22
Apple Search Ads and App Store Connect
Hello there, I am running an Apple Search Ads campaign and am wondering whether these anorganic downloads generated from this campaign are included on App Store Connect. You have two different places in App Store Connect where you can find Download / App Unit informations: Analytics and Trends. Question: Are Search Ads campaign downloads included in these two spots, or just in one of them or in none of them? Thanks a lot for your help!
Replies
1
Boosts
0
Views
1.3k
Activity
Apr ’23