Post

Replies

Boosts

Views

Activity

AVSpeechSynthesizer read Mandarin as Cantonese(iOS 26 beta 3))
In iOS 26, AVSpeechSynthesizer read Mandarin into Cantonese pronunciation. No matter how you set the language, and change the settings of my phone system, it doesn't work. let utterance = AVSpeechUtterance(string: "你好啊") //let voice = AVSpeechSynthesisVoice(language: "zh-CN") // not work let voice = AVSpeechSynthesisVoice(language: "zh-Hans") // not work too utterance.voice = voice et synth = AVSpeechSynthesizer() synth.speak(utterance)
1
0
250
Aug ’25
HKLiveWorkoutBuilder get wrong calorie data for iOS 26
In iOS 26, HKLiveWorkoutBuilder is supported, which we can use like HKWorkoutSession in watchOS - this is very exciting. However, it currently seems to have a bug in calculating calories. I tested it in my app, and for nearly 6 minutes with an average heart rate of 134, it only calculated 8 calories consumed (80 calories per hour), including basal consumption, which is obviously incorrect. (I used Powerboats Pro 2 connected to my phone, which includes heart rate data, and HKLiveWorkoutBuilder correctly collected the heart rate, which is great.) I think my code is correct. func workoutBuilder(_ workoutBuilder: HKLiveWorkoutBuilder, didCollectDataOf collectedTypes: Set<HKSampleType>) { for type in collectedTypes { guard let quantityType = type as? HKQuantityType else { return // Nothing to do. } let statistics = workoutBuilder.statistics(for: quantityType) if let statistics = statistics { switch statistics.quantityType { case HKQuantityType.quantityType(forIdentifier: .heartRate): /// - Tag: SetLabel let heartRateUnit = HKUnit.count().unitDivided(by: HKUnit.minute()) let value = statistics.mostRecentQuantity()?.doubleValue(for: heartRateUnit) let roundedValue = Double( round( 1 * value! ) / 1 ) if let avg = statistics.averageQuantity()?.doubleValue(for: heartRateUnit) { self.avgHeartRate = avg } self.delegate?.didUpdateHeartBeat(self, heartBeat: Int(roundedValue)) case HKQuantityType.quantityType(forIdentifier: .activeEnergyBurned): let energyUnit = HKUnit.kilocalorie() let value = statistics.sumQuantity()?.doubleValue(for: energyUnit) self.totalActiveEnergyBurned = Double(value!) print("didUpdate totalActiveEnergyBurned: \(self.totalActiveEnergyBurned)") self.delegate?.didUpdateEnergyBurned(self, totalEnergy: self.totalActiveEnergyBurned + self.totalBasalEneryBurned) return case HKQuantityType.quantityType(forIdentifier: .basalEnergyBurned): let energyUnit = HKUnit.kilocalorie() let value = statistics.sumQuantity()?.doubleValue(for: energyUnit) self.totalBasalEneryBurned = Double(value!) print("didUpdate totalBasalEneryBurned: \(self.totalBasalEneryBurned)") self.delegate?.didUpdateEnergyBurned(self, totalEnergy: self.totalActiveEnergyBurned + self.totalBasalEneryBurned) return default: print("unhandled quantityType=\(statistics.quantityType) when processing statistics") return } } I think I've found the source of the problem: let workoutConfiguration = HKWorkoutConfiguration() workoutConfiguration.activityType = .traditionalStrengthTraining //walking, running is ok workoutConfiguration.locationType = .outdoor When I set the activityType to walking or running, the calorie results are correct, showing several hundred calories per hour. However, when activityType is set to traditionalStrengthTraining or jumprope, the calculations are incorrect. PS: I'm currently using Xcode 26 beta3 and iOS 26 beta3. Hope this issue can be resolved. Thanks.
1
0
140
Jul ’25
Fitness app not now show saved routes
When I set the distanceFilter = 5 (5 meters) in the GPS CLLocationManager I can't display the workout routes in the Apple Fitness app after writing the recorded GPS data to HealthKit via HKWorkoutRouteBuilder. The smaller distanceFilter, Fitness will displays the route. Should I consider setting up a small distanceFilter when developing a workout app on watchOS?
5
0
138
Jul ’25
Cannot get Nintendo Switch Joycon accelerator motion data in iOS 16
Now I am using iOS 16 beta 6, I can get buttonA/buttonB is pressed event. but cannot get accelerator motion data info.      //work     buttonA?.valueChangedHandler = {(_ button: GCControllerButtonInput, _ value: Float, _ pressed: Bool) -> Void in       print(">>> ButtonA tapped")     }     //work     buttonB?.valueChangedHandler = {(_ button: GCControllerButtonInput, _ value: Float, _ pressed: Bool) -> Void in       print(">>> ButtonB tapped")     }           // this is not works     gameController.motion?.valueChangedHandler = { (motion: GCMotion)->() in       print(">>>> motion data \(motion.acceleration.x) \(motion.acceleration.y) \(motion.acceleration.z)")       if let delegate = self.motionDelegate {         delegate.motionUpdate(motion: motion)       }     } Is there any plan to support this?
4
3
3.3k
Jul ’24
SwiftData CloudKit integration requires that all attributes be optional, or have a default value set
After install XCode 15 beta 6: @Model class WordResult { var text = "" var translation:[String] = [] init(){ } } got this error: Variable 'self._$backingData' used before being initialized so I changed to : @Model class WordResult { var text:String var translation:[String] init(){ self.text = "" self.translation = [] } } Then got this: CloudKit integration requires that all attributes be optional, or have a default value set It seems it can not work with cloudkit now.
5
3
2.8k
Aug ’23
WidgetKit watch complication not shown on real device.
I updated my project from watch app + extension to single-execute project with Xcode 15. Then add a widget target to watch app. The new WidgetKit swiftUI complications works well on simulator, but not shown on the real device.(can not find on Apple Watch Face Complication Editor or rectangle widget) I tried: clean xcode build && Derived Data. reboot my watch/iphone delete all old clockkit complication settings & complicationcontroller.swift the watch still show old clockkit complicaton , that very buggy. so I try next: 4. restore my watch and pair it again. The new WidgetKit complication still not shown, it very frustrated. Do I have to change my old watch app to swiftUI lifecycle project to work? But code is works onthe simulator, which doesn't make sense. when I debug widget extension on Xcode, it show error: SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8 "Failed to show Widget 'hltek.***.watchkitapp.ComplicationWidget' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.Carousel" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (IOSSHLMainWorkspace) for reason: BadArgument., NSLocalizedDescription=The request to open "com.apple.Carousel" failed., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x15687310 {Error Domain=FBSOpenApplicationErrorDomain Code=2 "(null)" UserInfo={NSUnderlyingError=0x15696b00 {Error Domain=com.apple.Carousel.ComplicationExtensionDebuggingErrorDomain Code=3 "No widgets available to reload" UserInfo={NSLocalizedFailureReason=No widgets available to reload}}}}, FBSOpenApplicationRequestID=0x16e7}." UserInfo={NSUnderlyingError=0x15684f10 {Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.Carousel" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (IOSSHLMainWorkspace) for reason: BadArgument., NSLocalizedDescription=The request to open "com.apple.Carousel" failed., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x15687310 {Error Domain=FBSOpenApplicationErrorDomain Code=2 "(null)" UserInfo={NSUnderlyingError=0x15696b00 {Error Domain=com.apple.Carousel.ComplicationExtensionDebuggingErrorDomain Code=3 "No widgets available to reload" UserInfo=0x1567e360 (not displayed)}}}, FBSOpenApplicationRequestID=0x16e7}}, NSLocalizedDescription=Failed to show Widget 'hltek.***.watchkitapp.ComplicationWidget' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.Carousel" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (IOSSHLMainWorkspace) for reason: BadArgument., NSLocalizedDescription=The request to open "com.apple.Carousel" failed., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x15687310 {Error Domain=FBSOpenApplicationErrorDomain Code=2 "(null)" UserInfo={NSUnderlyingError=0x15696b00 {Error Domain=com.apple.Carousel.ComplicationExtensionDebuggingErrorDomain Code=3 "No widgets available to reload" UserInfo={NSLocalizedFailureReason=No widgets available to reload}}}}, FBSOpenApplicationRequestID=0x16e7}.} Domain: DTXMessage Code: 1 User Info: { DVTErrorCreationDateKey = "2023-07-06 03:36:45 +0000"; } -- System Information macOS Version 13.4.1 (Build 22F2083) Xcode 15.0 (22221.2) (Build 15A5195k) Timestamp: 2023-07-06T11:36:45+08:00 dyld[459]: Symbol not found: _$s21DeveloperToolsSupport15PreviewRegistryPAAE7previewAA0D0VvgZ Referenced from: <E835EDE1-190A-33B0-9462-EFD25999365D> /private/var/containers/Bundle/Application/F2DE6431-DF97-472D-934F-B2B3F76E660E/*** WatchKit App.app/PlugIns/ComplicationWidgetExtension.appex/ComplicationWidgetExtension Expected in: <E4C8E0EA-CF6C-381C-877C-716427DD3DFB> /System/Library/Frameworks/DeveloperToolsSupport.framework/DeveloperToolsSupport debug the extension on simulator with no error.
2
1
1.6k
Jul ’23
iOS 16 Live Activities cann't be refreshed in the background ?
I tried this: https://developer.apple.com/documentation/activitykit/displaying-live-data-on-the-lock-screen-with-live-activities I am building a workout app, the app can run in background , and I want to update the Live Activity realtime(once a second ) , so users can see the workout progress in realtime. But as I test, when app in foreground the activity widget refreshed perfectly. But when the app goes to the background, it is not refreshed.
8
5
4.8k
Oct ’22
How to implement vertical scroll page on watchOS with SwiftUI
I want to implement a vertical scroll page like system workout app. Now I can get a similar effect with this:     TabView {       page1         .rotationEffect(.degrees(90))       page2         .rotationEffect(.degrees(90))     }.tabViewStyle(.page(indexDisplayMode: .automatic))     .rotationEffect(.degrees(-90)) But not good as system workout app does. It supports digital crown and dynamic show indicator and custom color. So , how to implement that vertical scroll effect?
1
0
1.5k
Oct ’22
Remove node from ARSCNView cause random crash(btCollisionWorld::updateSingleAabb)
I made a ball drop animation on the ARSCNView, then after 1 second, then deleted the ball and re-added it to the original position on the view, but this occasionally crashes. something like this: private func dropBall(){ // do ball dropping animation let randomX = Float.random(in: -2...2) * 0.001 let randomY = Float.random(in: 3...10) * 0.001 ballNode?.physicsBody = SCNPhysicsBody(type: .dynamic, shape: nil) ballNode?.physicsBody?.mass = 0.005 let position = SCNVector3(x: 0.05, y: 0.05, z: 0.05) let force = SCNVector3(x: randomX, y: randomY , z: 0) ballNode?.physicsBody?.applyForce(force, at: position, asImpulse: true) let tv = SCNVector4(x: -0.2 + Float(0.4 * randomCGFloat()), y: 0 , z: 0.2, w: 0) ballNode?.physicsBody?.applyTorque(tv, asImpulse: true) //remove the ball DispatchQueue.main.asyncAfter(deadline: .now() + 1){ self.ballNode?.physicsBody = nil self.ballNode?.removeFromParentNode() self.ballNode = nil // add ball again let ballNode = SCNReferenceNode(named: "myscn.scn") contentNode?.addChildNode(ballNode) self.ballNode = ballNode } } crash stack: Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000068 Exception Codes: 0x0000000000000001, 0x0000000000000068 VM Region Info: 0x68 is not in any region. Bytes before following region: 68719476632 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---> commpage (reserved) 1000000000-7000000000 [384.0G] ---/--- SM=NUL ...(unallocated) Termination Reason: SIGNAL 11 Segmentation fault: 11 Terminating Process: exc handler [30984] Triggered by Thread: 11 Thread 11 name: Thread 11 Crashed: 0 SceneKit 0x00000001cf3ef998 btDbvtBroadphase::setAabb(btBroadphaseProxy*, btVector3 const&, btVector3 const&, btDispatcher*) + 52 1 SceneKit 0x00000001cf65126c btCollisionWorld::updateSingleAabb(btCollisionObject*) + 284 2 SceneKit 0x00000001cf65133c btCollisionWorld::updateAabbs() + 56 3 SceneKit 0x00000001cf3ff39c btCollisionWorld::performDiscreteCollisionDetection() + 32 4 SceneKit 0x00000001cf406964 btDiscreteDynamicsWorld::internalSingleStepSimulation(float) + 120 5 SceneKit 0x00000001cf3ff574 btDiscreteDynamicsWorld::stepSimulation(float, int, float) + 276 6 SceneKit 0x00000001cf507ad8 -[SCNPhysicsWorld _step:] + 156 (SCNPhysicsWorld.mm:1423) 7 SceneKit 0x00000001cf3ae9fc -[SCNRenderer _update:] + 932 (SCNRenderer.m:3814) 8 SceneKit 0x00000001cf3ae364 -[SCNRenderer _drawSceneWithNewRenderer:] + 152 (SCNRenderer.m:5303) 9 SceneKit 0x00000001cf3ae278 -[SCNRenderer _drawScene:] + 40 (SCNRenderer.m:5537) 10 SceneKit 0x00000001cf3a78b4 -[SCNRenderer _drawAtTime:] + 500 (SCNRenderer.m:5727) 11 SceneKit 0x00000001cf3a74cc -[SCNView _drawAtTime:] + 368 (SCNView.m:1542) 12 SceneKit 0x00000001cf4ba478 __83-[NSObject(SCN_DisplayLinkExtensions) SCN_setupDisplayLinkWithQueue:screen:policy:]_block_invoke + 44 (SCNDisplayLink_ARC.m:42) 13 SceneKit 0x00000001cf595fa0 -[SCNDisplayLink _displayLinkCallbackReturningImmediately] + 148 (SCNDisplayLink.m:381) 14 libdispatch.dylib 0x0000000190a267c8 _dispatch_client_callout + 16 (object.m:560) 15 libdispatch.dylib 0x00000001909fde7c _dispatch_continuation_pop$VARIANT$armv81 + 436 (inline_internal.h:2632) 16 libdispatch.dylib 0x0000000190a0f860 _dispatch_source_invoke$VARIANT$armv81 + 1552 (source.c:596) 17 libdispatch.dylib 0x0000000190a0172c _dispatch_lane_serial_drain$VARIANT$armv81 + 308 (inline_internal.h:0) 18 libdispatch.dylib 0x0000000190a022e4 _dispatch_lane_invoke$VARIANT$armv81 + 380 (queue.c:3940) 19 libdispatch.dylib 0x0000000190a0c000 _dispatch_workloop_worker_thread + 612 (queue.c:6846) 20 libsystem_pthread.dylib 0x00000001d0f3cb50 _pthread_wqthread + 284 (pthread.c:2618) 21 libsystem_pthread.dylib 0x00000001d0f3c67c start_wqthread + 8 How to fix this? This will only crash by chance and is not too easy to reproduce, is there a problem with me deleting this node in this way?
1
0
1.2k
Sep ’22
MusicKit can't play the playlist which created by myself in iOS 16 beta 7,error:Queue descriptor was not provided
Playlist 1: created by myself, id: pl.u-BNA6rpjIRXy7Dj https://music.apple.com/cn/playlist/i-jump-you-jump/pl.u-BNA6rpjIRXy7Dj Playlist 2: created by Apple Music, id:pl.e1bd354664a743d1ad3e10db21118dc7 https://music.apple.com/cn/playlist/jumping-rope/pl.e1bd354664a743d1ad3e10db21118dc7 When I play list 1: Failed to play with error: Error Domain=MPMusicPlayerControllerErrorDomain Code=1 "Queue descriptor was not provided." UserInfo={NSDebugDescription=Queue descriptor was not provided.}. It works well on iOS 15, but has this error on iOS 16 beta6 and beta7. The list2 works well both on iOS 15 and iOS 16 let tracks = try await loadTracks("pl.u-BNA6rpjIRXy7Dj") // not works, pl.e1bd354664a743d1ad3e10db21118dc7 this id works ApplicationMusicPlayer.shared.queue = ApplicationMusicPlayer.Queue(for: tracks) Task { do { try await ApplicationMusicPlayer.shared.play() } catch { print("Failed to play with error: \(error).") } } func loadTracks(plId:String) async throws -> MusicItemCollection<Track> { let playlistRequest = MusicCatalogResourceRequest<Playlist>(matching: \.id, equalTo: MusicItemID(rawValue: plId)) let playlistResponse = try await playlistRequest.response() if let playlist = playlistResponse.items.first { let detailedPlaylist = try await playlist.with([.tracks]) let tmpTracks = detailedPlaylist.tracks ?? [] return tmpTracks } else { print("Couldn't find playlist.") return [] } } FB: FB11426046
1
0
1.6k
Sep ’22
SwiftUI render wrong size on old devices like Apple Watch Series 4
Problem: SwiftUI render wrong size on old device like Apple Watch Series 4. The height was be cut, not well render as series 6 or simulator. Check the screenshots. BTW: But it works well both on watch series 6 real device or simulator. Reproduce: Download “Build a Workout App for Apple Watch”, run the code on a real device of watch series 4 https://developer.apple.com/videos/play/wwdc2021/10009/ On Watch4-44 mm (first line be clip) On Simulator or watch 6.
0
0
1k
Sep ’21