Package observation seems to collide with SwiftUI @Observable.

Open
#31 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
swift
Domain
mobile-dev

Research direction

Start with the minimal reproduction using SwiftUI, ModelsDSTU2, and ModelsR4, and confirm the ambiguous Observation error when declaring an @Observable class. Trace the conflicting package declarations and verify that the reproduction compiles without the workaround of moving associated code into a separate extension file.

Written by the indexing model from the issue text.

Description

bug

I think I'm going crazy here but after importing

import ModelsDSTU2
import ModelsR4

in a project it stops compiling with some obscure errors. From what I can make out, it seems the classes defined in the package clash with the SwiftUI @Observable macro:

/var/folders/rt/5jrx9dk91r17__4r2tm3m01w0000gn/T/swift-generated-sources/@__swiftmacro_6cardya13HKDataManager10ObservablefMe_.swift:1:26 'Observation' is ambiguous for type lookup in this context

A minimal reproduction of this error:

import SwiftUI
import ModelsDSTU2
import ModelsR4

@Observable class TestClass {}

The quickest work around has been to move all associated code to a separate file in an extension.

Dominant language
Swift
Stars
209
Forks
36
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apple/FHIRModels

All issues in apple/FHIRModels

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.