Post

Replies

Boosts

Views

Activity

Reply to How to add Images to Swift Playground for iPad?
Wow, that works. Thank you! So basically I just had to include a uiImage: which wasn’t in the original code and add your three line to get the image to display properly. Took me some try and error - because some of the code displays as a thumbnail and I had to figure out which code to include and which is included in the [Thumb]. When I copy&paste my working code here it looks like this: struct CircleImage: View {     var body: some View {         Image(uiImage:  imageLiteral(resourceName: "Foto.png"))             .resizable()             .frame(width: 200, height: 200)             .clipShape(Circle())     } } in the playground App the line Image(uiImage.... looks like this: Image(uiImage:  [Thumbnail]) Thanks again, big help!
Nov ’20
Reply to Preview of SwitftUI View used in multiple targets
I have a workaround: pinned preview. Tested with a sample custom view in shared group: struct CustomTextView: View {     let caption: String     let foreground: Color     var body: some View {         VStack {             Text(caption)                 .padding()             Text("Colored\r" + caption)                 .foregroundColor(foreground)                 .padding()         }     } } //struct CustomTextView_Previews: PreviewProvider { //    static var previews: some View { //        CustomTextView(caption: "Shared Preview", foreground: .blue) //    } //} And a preview container inside the WatchkitExtension: struct CustomTextViewWatchPreview: View {     var body: some View {         CustomTextView(caption: "Watch Preview Wrapper", foreground: .red)     } } struct CustomTextViewWatchPreview_Previews: PreviewProvider {     static var previews: some View {         CustomTextViewWatchPreview()     } } Then when previewing Watch just pin this preview and modify the CustomTextView. The (iOS) Preview inside the CustomTextView .swift file should be commented out at this time. It's not ideal but at least it kinda works.
Jan ’21
Reply to SwiftUI Runtime Error from if condition { Text() } in watchOS
It seems we have encountered different problems with the same error message? I have not posted my full code, but the main difference between yours and mine is that Consts.myCondition is never changed after compiling. I originally wanted to do a #ifdef but I found that's not supported by swift. Just now I read about Build Configurations - will have to look into this. At least it seems more and more clear that it's not my understanding of SwiftUI that's at fault here... like you said if I can find the time I'll post a bug report.
Mar ’21
Reply to How to combine updating of Text(date, style: .relative) with styling of formatter:
Thank you for your reply. That's a good start and I'll use it for now. Maybe later I can think of a way to increase the timer intervals - like when the update was hours ago then I'll set the interval to 1 minute or something. Strange: in Swift Playgrounds it doesn't work (the timer doesn't fire at all, but the relDateText is set to the initial interval.) Probably a quirk of Playgrounds, I guess. In Xcode Previews it only works in "live" preview which is as expected. Couldn't find a quick way to fix that other than hardcode an initial value instead of "". In Simulator it works quite well. I didn't try onDevice yet but why would it fail there?
Mar ’21
Reply to My app listed as inactive under the Data Sources and Access of Health App
I am assuming iPhone app. Go to Health app, then your data type, scroll down to "Data Sources & Access". Make sure your app is enabled in the read section. tap edit in the upper right corner (navigation bar) scroll down to "data sources" section and make sure your app is marked with a checkmark. If it isn't checked tap on your list row to add the checkmark. Tap done in the navigation bar. If you're talking about watchOS my suggestion is to do it on the iPhone like above but I'm not 100% sure it will work... Hope it helps!
Mar ’21
Reply to SwiftUI Runtime Error from if condition { Text() } in watchOS
Apparently this has been fixed by iOS 15 Beta 4: on my test device I had the error prior to the Beta 4 update, using a test app compiled with Xcode 13 Beta 3. After the update to iOS 15 Beta 4 the error is gone. (Xcode Beta 4 is still downloading currently.) So I think it’s reasonable to say that the update to iOS 15 Beta 4 did fix the error. Apple Feedback ID FB9063694 If any1 would like to confirm…?
Jul ’21
Reply to ObservableObject Array data not updating
This line @StateObject var graph = graphData() initializes a new graph instance in either of your views. They don't communicate with each other. Better use @ObservedObject var graph = GraphData.shared in the views and class GraphData: ObservableObject { static let shared = GraphData() ... } in your model class.
Aug ’21