Post

Replies

Boosts

Views

Activity

How to Use RealityKitContent Package for App Targets Lower Than iOS 18.0
I am trying to display a 3D model in iOS app using RealityView. The same 3D model is displayed successfully in the visionOS app. Everything works perfectly only when I set my project’s minimum deployment target to iOS 18.0. However, my app’s minimum deployment target is iOS 15.0. When I use the RealityKitContent package to load the 3D model, it fails to compile and gives me the following error: Compiling for iOS 15.0, but module 'RealityKitContent' has a minimum deployment target of iOS 18.0: /Users/Library/Developer/Xcode/DerivedData/RealityViewForiOS-cbfkgimsqngtuegqwvezusvscllf/Index.noindex/Build/Products/Debug-iphonesimulator/RealityKitContent.swiftmodule/arm64-apple-ios-simulator.swiftmodule I have made the RealityKitContent package optional and tried importing using the following condition: #if canImport(RealityKitContent) import RealityKitContent #endif Despite this, it still fails to compile and produces the same error. I have not found a workaround for using the RealityKitContent package with app targets lower than iOS 18.0. Here is my package definition: let package = Package( name: "RealityKitContent", platforms: [ .visionOS(.v1), .macOS(.v15), .iOS(.v18) ], products: [ .library( name: "RealityKitContent", targets: ["RealityKitContent"]), ], dependencies: [], targets: [ .target( name: "RealityKitContent", dependencies: []), ] ) Here is the code I am using to load the 3D model with RealityView using the RealityKitContent package: import SwiftUI import RealityKit #if canImport(RealityKitContent) import RealityKitContent #endif struct ContentView: View { var body: some View { VStack { if #available(iOS 18.0, *) { RealityView { content in if let scene = try? await Entity(named: "Scene", in: realityKitContentBundle) { content.add(scene) } } update: { content in if let scene = content.entities.first { let uniformScale: Float = 3.0 scene.transform.scale = [uniformScale, uniformScale, uniformScale] } } } else { // Fallback for earlier versions } } } } #Preview { ContentView() } Any help or guidance on how to use the RealityKitContent package for app targets lower than iOS 18.0 would be greatly appreciated.
0
2
468
Jul ’24
Combining Matched Geometry with New Zoom Navigation Transitions in iOS 18
With the introduction of the new matchedTransitionSource from iOS 18, we can apply a zoom transition in the navigation view using .navigationTransition(.zoom) This works well for zoom animations. However, when I try to apply a matched geometry effect to views that are similar in the source and destination views, the zoom transition works, but those views don't transition seamlessly as they do with a matched geometry effect. Is it possible to still use matched geometry for subviews of the source and destination views along with the new navigationTransition? Here’s a little demo that reproduces this behaviour: struct ContentView: View { let colors: [[Color]] = [ [.red, .blue, .green], [.yellow, .purple, .brown], [.cyan, .gray] ] @Namespace() var namespace var body: some View { NavigationStack { Grid(horizontalSpacing: 50, verticalSpacing: 50) { ForEach(colors, id: \.hashValue) { rowColors in GridRow { ForEach(rowColors, id: \.self) { color in NavigationLink { DetailView(color: color, namespace: namespace) .navigationTransition( .zoom( sourceID: color, in: namespace ) ) .edgesIgnoringSafeArea(.all) } label: { ZStack { RoundedRectangle(cornerRadius: 5) .foregroundStyle(color) .frame(width: 48, height: 48) Image(systemName: "star.fill") .foregroundStyle(Material.bar) .matchedGeometryEffect(id: color, in: namespace, properties: .frame, isSource: false) } } .matchedTransitionSource(id: color, in: namespace) } } } } } } } struct DetailView: View { var color: Color let namespace: Namespace.ID var body: some View { ZStack { color Image(systemName: "star.fill") .resizable() .foregroundStyle(Material.bar) .matchedGeometryEffect(id: color, in: namespace, properties: .frame, isSource: false) .frame(width: 100, height: 100) } .navigationBarHidden(false) } } #Preview { ContentView() }
0
4
713
Jun ’24
Detecting the Anchor/Position of the Scene Glass Window in an Immersive View in VisionOS
I have a main app window that presents an Immersive style in Mixed Reality. I am trying to determine the anchor/position of this glass window in the 3D space and place a Sphere entity right next to it. The goal is to ensure that if the user moves the window, the Sphere entity remains attached to it. Does anyone have insights on how to achieve this? The below code snippet provides the position of the device, and I have positioned it 0.5 meters away from the z-axis. However, my objective is to obtain the position of the glass window and anchor the sphere to it. Any guidance on achieving this would be appreciated. import RealityKit import RealityKitContent import ARKit struct ImmersiveView: View { let visionProPose = VisionProPose() var body: some View { RealityView { content in Task { await visionProPose.runArSession() } // Add the initial RealityKit content if let scene = try? await Entity(named: "Immersive", in: realityKitContentBundle) { content.add(scene) } } update: { content in if let scene = content.entities.first { if let sphere = scene.findEntity(named: "Sphere") as? ModelEntity { Task { let transfrom = await visionProPose.getTransform() sphere.position = [Float((transfrom?.columns.3.x)!), Float((transfrom?.columns.3.y)!), Float((transfrom?.columns.3.z)!) - 1 ] } } } } } } @Observable class VisionProPose { let session = ARKitSession() let worldTracking = WorldTrackingProvider() func runArSession() async { Task { try? await session.run([worldTracking]) } } func getTransform() async -> simd_float4x4? { guard let deviceAnchor = worldTracking.queryDeviceAnchor(atTimestamp: 1) else { return nil } let transform = deviceAnchor.originFromAnchorTransform return transform } }
0
0
723
Feb ’24
How to apply a different texture to the Rear face of the material in Reality Composer Pro?
I would like to apply different textures to the front and back faces of a 3D material. Specifically, when applying a texture that cuts the object in half through opacity, I want to be able to observe the back face of the object and apply a different color to it compared to the front face. In Unity, there is a 'isFrontFace' boolean node that allows for applying different colours to the front and rear faces. However, I am unsure of how to achieve the same effect in Reality Composer Pro! 3D Model is already two-sided.
1
0
1.2k
Jan ’24
Muting Audio in Interactive Widgets with AudioPlaybackIntent When Device is in Silent Mode
I'm encountering an intriguing issue with interactive widgets and the AudioPlaybackIntent on my device. Specifically, my problem arises when the device is set to silent mode. Despite the silence setting, selecting the category .playback continues to play sounds, which is the expected behaviour. However, when I opt for alternative categories like .ambient or .soloAmbient, these widgets cease to produce sound, even when the device is in ringer mode. I would appreciate any insights, solutions, or discussion on this matter within the Apple forum community. // This code snippet allows audio to play in widgets with interactive buttons, even in silent mode. try? AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: []) try? AVAudioSession.sharedInstance().setActive(true) // Conversely, this code snippet prevents audio playback in widgets with interactive buttons, even in silent mode. try? AVAudioSession.sharedInstance().setCategory(.ambient, mode: .default, options: []) try? AVAudioSession.sharedInstance().setActive(true) Works as expected on the Simulator, but encounters issues when tested on a physical device using Xcode 15 Beta 8
0
0
849
Sep ’23
WidgetExtension Crashes on launch in Xcode 15 Beta 3
When applied .contentMarginsDisabled() modifier to WidgetConfiguration, Widget extension crashes on launch in Xcode 15 Beta 3. struct TestWidget: Widget { let kind: String = "TestWidget" var body: some WidgetConfiguration { return IntentConfiguration(kind: kind, intent: TestIntent.self, provider: TestProvider()) { entry in TestView(entry: entry) } .configurationDisplayName("TestWidget") .description("This is TestWidget.") .supportedFamilies([.systemMedium]) .contentMarginsDisabled() // << Here } } Though it works in Xcode 15 Beta 2. Anyone facing same issue ?
4
0
1.5k
Jul ’23
How to achieve NSSharingService menu options for NSTextAttachments inside UITextView in MacCatalyst?
When I hover the mouse over the NSTextAttachment image inside the UITextview, it should show this option to MarkUp. All native app including Notes, TextEditor, Mail have this behaviour: I think, by default, NSTextView will show the NSSharingServicePicker button when you hover over an image inside the text view. That’s true even for custom image-based NSTextAttachments in the attributed string. But it is not showing the button for UITextview in MacCatalyst. Also NSSharingService class is limited to MacOS only. Are there any alternative way to achieve this in MacCatalyst?
0
0
1.1k
Jul ’22
Is Focus Ring broken for InstGrouped Style TableView in MacCatalyst?
Hi, I've assigned contextual menu to my tableview rows which seems to focus cells background with blue ring in MacCatayst. If tableview style is Plain or Grouped, it focus ring appear as it should but in InsetGrouped type tableview, it seems to be broken. I've tried disabling the focus with : func tableView(_ tableView: UITableView, canFocusRowAt indexPath: IndexPath) -> Bool { return false } And tableView.selectionFollowsFocus = false But no luck disabling it. Anyone has any Idea about this behaviour ?
1
0
1.1k
Jun ’22
MacCatalyst - UITableview Separators not showing
Hi, I've made a simple list using UITableview for Mac Catalyst and have set the separator style to default. ( I'm not using Diffable datasource ) The problem is it is showing separators in iPhone and iPad, but not showing in Mac. Does any one has any idea about this behaviour? Is there any way to show for the Mac or do I have to make custom cells with separators ?
0
0
727
May ’22
Compose Mail Extension - User Privacy Permissions
I'm trying to build a simple Mail Extension using Compose session handler for the Mac Catalyst App. The idea is to open a ComposeViewController on App Icon click from Mail Toolbar ( when the user adds the app extensions for the app from Mail Preference ). I'm using core data in a shared group and I want to show the list of the email address that the user has added from the app to the ComposeViewController. But on the extension window in the Mail, it shows : Permissions for “MyDemoApp”: • Email Contents Can read sensitive information from emails including the message subject and recipients. This applies to all outgoing messages. Since my Compose-Mail-Extension does not read subject/recipients in the Compose window, My app should not ask this permission from users. Is there any way to omit permissions which my app is not using?
1
0
1.2k
May ’22
Copy/Paste from Textview to Mail App Composer not working - MacCatalyst
I'm trying with the MacCatalyst app which has editor screen with UITextView. Whenever I select some text [Attributed] & try to copy/paste ( using ctrl + c ) to another Mac app ( i.e Notes, Safari) it works well but if I try to paste it to Mail App's Composer, it doesn't work! When selecting some text and copying, it prints this log in debug window: Incorrect NSStringEncoding value 0x8000100 detected. Assuming NSASCIIStringEncoding. Will stop this compatibility mapping behavior in the near future. When converting Attributed string to Data, I'm applying the Encoding options as below: [NSAttributedString.DocumentAttributeKey: Any] = [ .documentType: NSAttributedString.DocumentType.rtfd, .characterEncoding: String.Encoding.utf8 ] Still it doesn't seem to work. Anyone has any idea about this ?
4
0
1.5k
May ’22