I’m attempting to display a PDF file in a visionOS application using the PDFView in PDFKit.
When running on device with visionOS 26, a horizontal solid line appears on some pages, while on other pages, both a horizontal and vertical solid line appear.
These lines do not appear
in Xcode preview canvas (macOS, visionOS)
on device running visionOS 2.5
on Mac running macOS 15.6
I thought that this could possibly be the page breaks, but setting displaysPageBreaks = false did not appear to be effective.
Are there any other settings that could be causing the lines to display?
Code Example
struct ContentView: View {
@State var pdf: PDFDocument? = nil
var body: some View {
PDFViewWrapper(pdf: pdf)
.padding()
}
}
#Preview(windowStyle: .automatic) {
ContentView(pdf: PDFDocument(url: Bundle.main.url(forResource: "SampleApple", withExtension: "pdf")!))
.environment(AppModel())
}
struct PDFViewWrapper: UIViewRepresentable {
let pdf: PDFDocument?
func makeUIView(context: Context) -> PDFView {
let view = PDFView()
view.document = pdf
view.displaysPageBreaks = false
return view
}
func updateUIView(_ uiView: PDFView, context: Context) {
uiView.document = pdf
}
}
Tested with
Xcode Version 16.4 (16F6)
Xcode Version 26.0 beta 5 (17A5295f)
visionOS 2.5
visionOS 26 Beta 5
I
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I'm running into an issue with collisions between two entities with a character controller component. In the collision handler for moveCharacter the collision has both hitEntity and characterEntity set to the same object. This object is the entity that was moved with moveCharacter()
The below example configures 3 objects.
stationary sphere with character controller
falling sphere with character controller
a stationary cube with a collision component
if the falling sphere hits the stationary sphere then the collision handler reports both hitEntity and characterEntity to be the falling sphere. I would expect that the hitEntity would be the stationary sphere and the character entity would be the falling sphere.
if the falling sphere hits the cube with a collision component the the hit entity is the cube and the characterEntity is the falling sphere as expected.
Is this the expected behavior? The entities act as expected visually however if I want the spheres to react differently depending on what character they collided with then I am not getting the expected results. IE: If a player controlled character collides with a NPC then exchange resource with NPC. if player collides with enemy then take damage.
import SwiftUI
import RealityKit
struct ContentView: View {
@State var root: Entity = Entity()
@State var stationary: Entity = createCharacter(named: "stationary", radius: 0.05, color: .blue)
@State var falling: Entity = createCharacter(named: "falling", radius: 0.05, color: .red)
@State var collisionCube: Entity = createCollisionCube(named: "cube", size: 0.1, color: .green)
//relative to root
@State var fallFrom: SIMD3<Float> = [0,0.5,0]
var body: some View {
RealityView { content in
content.add(root)
root.position = [0,-0.5,0.0]
root.addChild(stationary)
stationary.position = [0,0.05,0]
root.addChild(falling)
falling.position = fallFrom
root.addChild(collisionCube)
collisionCube.position = [0.2,0,0]
collisionCube.components.set(InputTargetComponent())
}
.gesture(SpatialTapGesture().targetedToAnyEntity().onEnded { tap in
let tapPosition = tap.entity.position(relativeTo: root)
falling.components.remove(FallComponent.self)
falling.teleportCharacter(to: tapPosition + fallFrom, relativeTo: root)
})
.toolbar {
ToolbarItemGroup(placement: .bottomOrnament) {
HStack {
Button("Drop") {
falling.components.set(FallComponent(speed: 0.4))
}
Button("Reset") {
falling.components.remove(FallComponent.self)
falling.teleportCharacter(to: fallFrom, relativeTo: root)
}
}
}
}
}
}
@MainActor
func createCharacter(named name: String, radius: Float, color: UIColor) -> Entity {
let character = ModelEntity(mesh: .generateSphere(radius: radius), materials: [SimpleMaterial(color: color, isMetallic: false)])
character.name = name
character.components.set(CharacterControllerComponent(radius: radius, height: radius))
return character
}
@MainActor
func createCollisionCube(named name: String, size: Float, color: UIColor) -> Entity {
let cube = ModelEntity(mesh: .generateBox(size: size), materials: [SimpleMaterial(color: color, isMetallic: false)])
cube.name = name
cube.generateCollisionShapes(recursive: true)
return cube
}
struct FallComponent: Component {
let speed: Float
}
struct FallSystem: System{
static let predicate: QueryPredicate<Entity> = .has(FallComponent.self) && .has(CharacterControllerComponent.self)
static let query: EntityQuery = .init(where: predicate)
let down: SIMD3<Float> = [0,-1,0]
init(scene: RealityKit.Scene) {
}
func update(context: SceneUpdateContext) {
let deltaTime = Float(context.deltaTime)
for entity in context.entities(matching: Self.query, updatingSystemWhen: .rendering) {
let speed = entity.components[FallComponent.self]?.speed ?? 0.5
entity.moveCharacter(by: down * speed * deltaTime, deltaTime: deltaTime, relativeTo: nil) { collision in
if collision.hitEntity == collision.characterEntity {
print("hit entity has collided with itself")
}
print("\(collision.characterEntity.name) collided with \(collision.hitEntity.name) ")
}
}
}
}
#Preview(windowStyle: .volumetric) {
ContentView()
}
I'm running into an issue where my application will hang when switching tabs. The issue only seems to occur when I include a Swift Chart in a navigation label. The application does not hang If I replace the chart with a text field.
This appears to only hang when running on macOS 26. When running on iOS (simulator) or visionOS (simulator, on-device) I do not observe a hang. The same code does not hang on macOS 15.
Has any one seen this behavior?
The use case is that my root view is a TabView where the first tab is a summary of events that have occurred. This summary is embedded in a NavigationStack and has a graph of events over the last week. I want the user to be able to click that graph to get additional information regarding the events (ie: a detail page or break down of events).
Initially, the summary view loads fine and displays appropriately. However, when I switch to a different tab, the application will hang when I switch back to the summary view tab.
In Xcode I see the following messages
=== AttributeGraph: cycle detected through attribute 162104 ===
=== AttributeGraph: cycle detected through attribute 162104 ===
=== AttributeGraph: cycle detected through attribute 162104 ===
=== AttributeGraph: cycle detected through attribute 162104 ===
=== AttributeGraph: cycle detected through attribute 162104 ===
A simple repro is the following
import SwiftUI
import Charts
@main
struct chart_cycle_reproApp: App {
var body: some Scene {
WindowGroup {
TabView {
Tab("Chart", systemImage: "chart.bar") {
NavigationStack {
NavigationLink {
Text("this is an example of clicking the chart")
}
label: {
Chart {
BarMark(
x: .value("date", "09/03"),
y: .value("birds", 3)
)
// additional marks trimmed
}
.frame(minHeight: 200, maxHeight: .infinity)
}
}
}
Tab("List", systemImage: "list.bullet") {
Text("This is an example")
}
}
}
}
}