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!
Post
Replies
Boosts
Views
Activity
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?
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.
Thank you very much for your profound answer!
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.
I tried to remove all Watches from the iPhone Simulators. Doesn't work.
I can run the Project in iOS Simulator and Watch Simulator just fine. I can run the Project on iOS and WatchOS Devices just fine.
Previewing iOS and WatchOS side by side in the same preview canvas would really be a nice addition.
Very helpful! Thank you.
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!