Post

Replies

Boosts

Views

Activity

Reply to Projecting a Cube with a Number in ARKit
Thank you for your kind assistance, Vision Pro Engineer. No. 1, it seems that NSAttributedString.Key.backgroundColor has nothing to do with my issue. No. 2, I think you only suggest that I change the modelEntity.model?.materials line as follows. modelEntity.model?.materials = [unlitMaterial] into modelEntity.model?.materials = [material, unlitMaterial] Yes, I do get a material color other than black with or without NSAttributedString.Key.backgroundColor. I then lose the text material. So the text number is MIA. func placeObject(at position: SIMD3<Float>) { let mesh = MeshResource.generateBox(size: 0.3) let material = SimpleMaterial(color: UIColor.systemRed, roughness: 0.3, isMetallic: true) let modelEntity = ModelEntity(mesh: mesh, materials: [material]) var unlitMaterial = UnlitMaterial() if let textureResource = generateTextResource(text: "1", textColor: UIColor.white) { unlitMaterial.color = .init(tint: .white, texture: .init(textureResource)) modelEntity.model?.materials = [material, unlitMaterial] let id = UUID().uuidString modelEntity.name = id modelEntity.transform.scale = [0.3, 0.1, 0.3] modelEntity.generateCollisionShapes(recursive: true) let anchorEntity = AnchorEntity(world: position) anchorEntity.addChild(modelEntity) self.scene.addAnchor(anchorEntity) } } func generateTextResource(text: String, textColor: UIColor) -> TextureResource? { if let image = text.image(withAttributes: [NSAttributedString.Key.foregroundColor: textColor, NSAttributedString.Key.backgroundColor: UIColor.clear], size: CGSize(width: 18, height: 18)), let cgImage = image.cgImage { let textureResource = try? TextureResource(image: cgImage, options: TextureResource.CreateOptions.init(semantic: nil)) return textureResource } return nil }
Topic: Spatial Computing SubTopic: ARKit Tags:
Jun ’25
Reply to Can SwiftUI View Receive a Call When Window Will Close?
import SwiftUI struct ContentView: View { var body: some View { VStack { Text("Hello, world!") } .windowResizeBehavior(.disabled) .windowMinimizeBehavior(.disabled) //.windowDismissBehavior(.disabled) .onReceive(NotificationCenter.default.publisher(for: NSWindow.willCloseNotification), perform: { _ in print("Window will close") }) } } I guess calling NSWindow.willCloseNotification with .onReceive will do it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’25
Reply to NWPathMonitor Failing
I appreciate your kind recommendation. I realize that NWPathMonitor can return unexpected results. That has initiated this question in the first place. In my app, I have employed a measure as to what to do when it ges an unexpected connection result. Yet, I'll see if I need additional measures.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’25
Reply to NWPathMonitor Failing
Hello. Thank you for your feedback, The Eskimo. It's well noted. I'll take a deeper look. I check the network connection with it (NWPathMonitor) so that the users are able to access App Store to make in-app purchases. If they are not connected, I just show some text with a progress guy, never showing the purchase list.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’25
Reply to Projecting a Cube with a Number in ARKit
Thank you for your kind help, Vision Pro Engineer. With the lines of code you have provided, I get the following cube, which is quite close to what I need. What I want to have is a cube with a number on each surface. I guess that's cannot be achieved.
Topic: Spatial Computing SubTopic: ARKit Tags:
Replies
Boosts
Views
Activity
Jul ’25
Reply to Projecting a Cube with a Number in ARKit
Thank you for your kind assistance, Vision Pro Engineer. No. 1, it seems that NSAttributedString.Key.backgroundColor has nothing to do with my issue. No. 2, I think you only suggest that I change the modelEntity.model?.materials line as follows. modelEntity.model?.materials = [unlitMaterial] into modelEntity.model?.materials = [material, unlitMaterial] Yes, I do get a material color other than black with or without NSAttributedString.Key.backgroundColor. I then lose the text material. So the text number is MIA. func placeObject(at position: SIMD3<Float>) { let mesh = MeshResource.generateBox(size: 0.3) let material = SimpleMaterial(color: UIColor.systemRed, roughness: 0.3, isMetallic: true) let modelEntity = ModelEntity(mesh: mesh, materials: [material]) var unlitMaterial = UnlitMaterial() if let textureResource = generateTextResource(text: "1", textColor: UIColor.white) { unlitMaterial.color = .init(tint: .white, texture: .init(textureResource)) modelEntity.model?.materials = [material, unlitMaterial] let id = UUID().uuidString modelEntity.name = id modelEntity.transform.scale = [0.3, 0.1, 0.3] modelEntity.generateCollisionShapes(recursive: true) let anchorEntity = AnchorEntity(world: position) anchorEntity.addChild(modelEntity) self.scene.addAnchor(anchorEntity) } } func generateTextResource(text: String, textColor: UIColor) -> TextureResource? { if let image = text.image(withAttributes: [NSAttributedString.Key.foregroundColor: textColor, NSAttributedString.Key.backgroundColor: UIColor.clear], size: CGSize(width: 18, height: 18)), let cgImage = image.cgImage { let textureResource = try? TextureResource(image: cgImage, options: TextureResource.CreateOptions.init(semantic: nil)) return textureResource } return nil }
Topic: Spatial Computing SubTopic: ARKit Tags:
Replies
Boosts
Views
Activity
Jun ’25
Reply to Can SwiftUI View Receive a Call When Window Will Close?
import SwiftUI struct ContentView: View { var body: some View { VStack { Text("Hello, world!") } .windowResizeBehavior(.disabled) .windowMinimizeBehavior(.disabled) //.windowDismissBehavior(.disabled) .onReceive(NotificationCenter.default.publisher(for: NSWindow.willCloseNotification), perform: { _ in print("Window will close") }) } } I guess calling NSWindow.willCloseNotification with .onReceive will do it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’25
Reply to Constraining Beacon with CLBeaconIdentityCondition
I get it. The Swift equivalent of CLBeaconIdentityCondition is CLMonitor.BeaconIdentityCondition.
Replies
Boosts
Views
Activity
Jun ’25
Reply to Constraining Beacon with CLBeaconIdentityCondition
I find it odd that the online document about CLBeaconIdentityConstraint in Swift leads to the online document for CLBeaconIdentityCondition in Objective-C.
Replies
Boosts
Views
Activity
Jun ’25
Reply to Opening FileDocument with URL → should only be called in the main thread
I've upgraded my system to macOS 15.5. The bug has been system.
Topic: UI Frameworks SubTopic: General Tags:
Replies
Boosts
Views
Activity
May ’25
Reply to App Stuck waiting for review for 24+ days
There really isn't anything that you can do other than waiting. I had my app submission stuck for days because the app used a new API introduced by Apple that had never gone through the review team if I remember correctly. That was several years ago.
Replies
Boosts
Views
Activity
May ’25
Reply to NWPathMonitor Failing
I appreciate your kind recommendation. I realize that NWPathMonitor can return unexpected results. That has initiated this question in the first place. In my app, I have employed a measure as to what to do when it ges an unexpected connection result. Yet, I'll see if I need additional measures.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’25
Reply to NWPathMonitor Failing
Okay. I've found some time going over your comments, The Eskimo. You are right. The initial lines of code I have shown are unnecessarily redundant. Thank you.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’25
Reply to Can You Debug a Widget on Actual Device?
Houston, now, the Widget appears on my iPhone and iPad. I don't get it. I did change the deployment target to iOS 17.6 before it appeared on my devices. The OS version on my iPad is 18.5. I don't know why it didn't appear on my iPad earlier.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’25
Reply to Can You Debug a Widget on Actual Device?
Houston, I think I have a problem. If I run a sample iOS app with a Widget, I can search and find it. This isn't good.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’25
Reply to CoreData Data Sharing with AppGroup
Oops... let container: NSPersistentContainer should be let container: NSPersistentCloudKitContainer I've made a silly mistake two days in a row. I wish I could find a cave to hide myself.
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
May ’25
Reply to NWPathMonitor Failing
Hello. Thank you for your feedback, The Eskimo. It's well noted. I'll take a deeper look. I check the network connection with it (NWPathMonitor) so that the users are able to access App Store to make in-app purchases. If they are not connected, I just show some text with a progress guy, never showing the purchase list.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’25
Reply to NWPathMonitor Failing
I didn't notice, but I guess I have to see the status change with onChange(of:initial:_:). Silly me...
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’25
Reply to NWPathMonitor Failing
Safari does return the web content if I use an iPhone simulator. Yet, NWPathMonitor fails.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’25