I got the error to go away by changing the .onAppear modifier to .task on a SwiftUI view observing a published property.
Below the navigation title modifier of the view.
.navigationTitle("Where you're at")
.task {
// Fetch data from CloudKit here
viewModel.fetchData()
}
Post
Replies
Boosts
Views
Activity
I was getting the error: "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."
I realized the compiler was complaining about a parameter I had specified on a URLComponents object. The URLComponents object's .scheme paramater was set as "http", so I changed it to "https" and voila error goes away. Maybe somewhere in your url object, there is an "http", and the compiler wants "https". Hope this helps.
Also, make sure if you haven't already added the dictionary "App Transport Security Settings" to your main app targets info, inside this dictionary there should be a boolean value "Allows Arbitrary Loads", it's value should be set to "YES"
This was done on XCode 13 beta 1
I used krebera's example to solve the question I had. Wrap the view in Anyview by replacing CustomView with the view you want to use. So...
struct Whatever {
		 var view: AnyView
}
let myWhatever = Whatever(view: AnyView(Text("Bruh, krebera is rad, thank you sooooo much!")))