Post

Replies

Boosts

Views

Activity

Watch app works fine in Simulator but crashes on Watch
My app crashes as soon as I try to launch it from my Watch, even though it works completely fine in various simulators. How do I go about finding out what is causing it to crash?Note that I've had my app run on my watch before, but all the iOS/WatchOS/Catalina updates as late caused an issue where I couldn't install my app to my Watch. After the latest update I can still it to my watch again except it just crashes on startup.
0
0
622
Dec ’19
Text alignment in an actionsheet
.actionSheet(isPresented: $showingExampleSentences) { ActionSheet(title: Text("Example Sentence"), message: Text(sentence_foreign_language + "\n" + .sentence_english), buttons: [.default(Text("OK"))]); }I've got a SwiftUI action sheet where it displays two lines of text, but by default they are centre-aligned. Is there a way to make it aligned to the top-left?
1
0
1.6k
Mar ’20
GeometryReader broken after update
I've downloaded the new Xcode 11.4 update and it's broken my codebase. I use GeometryReader to determine the user's Watch screen size so it can draw a frame that fills up most of the frame.Say if I wrote this to draw a rectangular frame:var body: some View { GeometryReader {geometry in ZStack { // Draw rounded rectangle flashcard background RoundedRectangle(cornerRadius: 15, style: .continuous) .frame(width: geometry.size.width, height: geometry.size.height*0.9) } } }It looks fine at the moment. But my main view usually uses subviews more like this:var body: some View { GeometryReader {geometry in ZStack { // Draw rounded rectangle flashcard background Frontside(id: self.$settings.randomNum, sheet: self.$showingSheet, rotate: self.$fullRotation, invis: self.$showNextCard, col: self.$colour, width: geometry.size.width*0.9, height: geometry.size.height).environmentObject(self.settings) .rotation3DEffect(.degrees(self.showResults ? 180.0 : 0.0), axis: (x: 0.0, y: 1.0, z: 0.0)) .rotation3DEffect(.degrees(self.fullRotation ? 360.0 : 0.0), axis: (x: 0.0, y: 1.0, z: 0.0)) .opacity(self.showResults ? 0 : 1) .zIndex(self.showResults ? 0 : 1) } } }public struct Frontside: View { @EnvironmentObject var settings: UserSettings @Binding public var id: Int @Binding public var sheet: Bool @Binding public var rotate: Bool @Binding public var invis: Bool @Binding public var col: Int public var width: CGFloat public var height: CGFloat public var body: some View { ZStack { // Draw rounded rectangle flashcard background RoundedRectangle(cornerRadius: 15, style: .continuous) .frame(width: self.width, height: self.height) .zIndex(0) } } }For some reason this causes an error when I call Frontside. Does anyone know why? There doesn't seem to be a real difference between the two code snippets other than using a subview in the second example.
0
0
1.2k
Mar ’20
Local notifications with variable text
Hi, I did a watchOS lab today where I asked how to create a local notification (which repeats at a regular interval), but I want to change the text so that that the message is relevant "You currently have x number of words to revise". I have setup the notification in my extension delegate as follows: notificationCenter = UNUserNotificationCenter.current() notificationCenter.removeAllPendingNotificationRequests() let options: UNAuthorizationOptions = [.alert, .sound, .badge] notificationCenter.requestAuthorization(options: options) { (didAllow, error) in if !didAllow { print("User has declined notifications") } } let content = UNMutableNotificationContent() content.title = "Overdue cards" content.body = "You have " + String(wordsOverdue) + " words to revise. " content.sound = UNNotificationSound.default content.userInfo = ["Overdue": database.getWordsOverdue()] The Apple engineer suggested I add the last line as the variable number/content. Then he said to use the NotificationController where there is a didReceive method that is called when a notification comes in, and I can update my notification view. The problem is, didReceive never gets called. When I test my app, it always just sends the original notification that I setup. What do I need to do for notification controller to know when a local notification has come in? I'm open to alternative solutions, since I just have a single value that needs to be updated.
0
0
620
Jun ’20
How to chain speech utterances
Hi, I spoke to someone during the audio lab today in relation to audio output of Chinese dialects. So I can now get cantonese and mandarin outputted. But now I'm trying to read the same line of text in both dialects, and the audio overlaps each other. What do I need to change in my code to create a pause between the two utterances rather than reading both at the same time? let cantoUtterance = AVSpeechUtterance(string: chinese) 						//utterance.voice = AVSpeechSynthesisVoice(language: "zh-HK") 						cantoUtterance.voice = AVSpeechSynthesisVoice(identifier: "com.apple.ttsbundle.Sin-Ji-compact") 						// utterance.rate = 0.1 						let cantoSynthesizer = AVSpeechSynthesizer() 						cantoSynthesizer.speak(cantoUtterance) 						let mandoUtterance = AVSpeechUtterance(string: chinese) 						mandoUtterance.voice = AVSpeechSynthesisVoice(language: "zh-CN") 						let mandoSynthesizer = AVSpeechSynthesizer() 						mandoSynthesizer.speak(mandoUtterance)
6
0
1.8k
Jun ’20
RevenueCat and watchOS
Has anyone had any luck with RevenueCat and independent watchOS apps? I am having trouble retrieving SKProducts that i setup on app store connect. Is there something different about Watch apps that I need to factor in the configuration of RevenueCat. For example, when it asks for Bundle ID - which bundle ID do i input? My watch app has 3 bundle IDs for the app, the watch app, watchkit extension. There's no documentation out there, it's very confusing.
0
0
685
Jul ’20
Highlight synthesized speech missing words
Hi, I'm using one of the delegate methods to determine when words are about to be spoken and then trying to provide a color background to indicate what is about to be spoken: func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, willSpeakRangeOfSpeechString characterRange: NSRange, utterance: AVSpeechUtterance) { 		guard let rangeInString = Range(characterRange, in: utterance.speechString) else { return } 		print("Will speak: \(utterance.speechString[rangeInString])") 		let attributes: [NSAttributedString.Key: Any] = [ 			.foregroundColor: UIColor.darkText, 			.font: UIFont.systemFont(ofSize: 16) 		] 		let mutableAttributedString = NSMutableAttributedString(string: utterance.speechString, attributes: attributes) 		mutableAttributedString.addAttribute(.backgroundColor, value: UIColor.yellow, range: characterRange) 		jpTextView.attributedText = mutableAttributedString 	} Based on the debug log I can see that it is reading every word in my UITextView, but when it comes to the yellow background highlighting, it's quite inconsistent and seems to skip around half the words. Is this an inherent issue related to the language I'm using (Japanese) or is there something fundamental in my code that needs to be fixed?
5
0
1.2k
Jul ’20
Rename 'Cancel' on modal sheet in SwiftUI
The Apple documentation gives some user interface design tips on modal sheets including renaming Cancel to something like Dismiss where relevant. But there's no guide whether this is possible in SwiftUI. There's a link that takes you to setTitle for Watchkit: https://developer.apple.com/documentation/watchkit/wkinterfacecontroller/1619570-settitle But is there something equivalent for SwiftUI on a Watch app?
0
0
582
Oct ’20
NLTagger support for Japanese
Hi, I am trying to use the natural language tagger for Japanese. I used this sample code: var stringToRecognize = jpTextView.text &#9;&#9;let range = stringToRecognize!.startIndex ..< stringToRecognize!.endIndex &#9;&#9;let tagger = NLTagger(tagSchemes: [.lexicalClass]) &#9;&#9;tagger.string = stringToRecognize &#9;&#9;tagger.enumerateTags(in: range, unit: .word, scheme: .lexicalClass) { (tag, range) -> Bool in &#9;&#9;&#9;print("Word [\(stringToRecognize![range])] : \(tag!.rawValue)") &#9;&#9;&#9;return true &#9;&#9;} and applied it on some dummy data: 東京では11月から、コロナウイルスの病気で入院する人が多くなっています。このため、お腹の中に赤ちゃんがいる看護師も仕事を続けています。家に小さな子どもがいる看護師は、子どもにウイルスがうつらないか心配しながら仕事をしています。 The output was: Word [東京] : OtherWord Word [で] : OtherWord Word [は] : OtherWord Word [11] : OtherWord Word [月] : OtherWord Word [から] : OtherWord Word [、] : Punctuation Word [コロナ] : OtherWord Word [ウイルス] : OtherWord Word [の] : OtherWord Word [病気] : OtherWord Word [で] : OtherWord Word [入院] : OtherWord Word [する] : OtherWord Word [人] : OtherWord Word [が] : OtherWord Word [多く] : OtherWord Word [なっ] : OtherWord Word [て] : OtherWord Word [い] : OtherWord Word [ます] : OtherWord Word [。] : SentenceTerminator Word [この] : OtherWord Word [ため] : OtherWord Word [、] : Punctuation Word [お腹] : OtherWord Word [の] : OtherWord Word [中] : OtherWord Word [に] : OtherWord Word [赤ちゃん] : OtherWord Word [が] : OtherWord Word [いる] : OtherWord Word [看護] : OtherWord Word [師] : OtherWord Word [も] : OtherWord Word [仕事] : OtherWord Word [を] : OtherWord Word [続] : OtherWord Word [け] : OtherWord Word [て] : OtherWord Word [い] : OtherWord Word [ます] : OtherWord Word [。] : SentenceTerminator Word [家] : OtherWord Word [に] : OtherWord Word [小さな] : OtherWord Word [子ども] : OtherWord Word [が] : OtherWord Word [いる] : OtherWord Word [看護] : OtherWord Word [師] : OtherWord Word [は] : OtherWord Word [、] : Punctuation Word [子ども] : OtherWord Word [に] : OtherWord Word [ウイルス] : OtherWord Word [が] : OtherWord Word [うつら] : OtherWord Word [ない] : OtherWord Word [か] : OtherWord Word [心配] : OtherWord Word [し] : OtherWord Word [ながら] : OtherWord Word [仕事] : OtherWord Word [を] : OtherWord Word [し] : OtherWord Word [て] : OtherWord Word [い] : OtherWord Word [ます] : OtherWord Word [。] : SentenceTerminator It looks like every word is just being picked up as OtherWord, and it can detect some punctuation. Is this correct, or will there be an improvement to the Japanese tagger soon so we can differentiate between nouns, verbs, conjunctions, particles, etc. ?
1
0
832
Dec ’20
Custom offer codes - no sales revenue
Hi, I recently adopted custom offer codes to offer a free month trial which then converts to an annual subscription. When the conversion occurs, I can see in the Trends section a unit of the annual subscription, but there is no sales revenue. I reached out to technical support, which sent me around in circles to different reports, but still did not show any sales revenue. Then I went to a lab during WWDC, and the two engineers agreed that it was odd and they took down my case number (101707403851). I still have not heard back from them. I recently had another custom offer code convert to a subscription and the same thing has happened again. I have another 15-20 converting soon, and I suspect the same will happen. So am I making any sales from these custom offer codes, or should I stop offering them? Thanks.
1
2
1.1k
Jul ’22