Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace collision with RxSwift #119

Open
3 tasks done
damien-rivet opened this issue Jan 15, 2025 · 0 comments · May be fixed by #120
Open
3 tasks done

Namespace collision with RxSwift #119

damien-rivet opened this issue Jan 15, 2025 · 0 comments · May be fixed by #120
Labels
bug Something isn't working due to a bug in the library.

Comments

@damien-rivet
Copy link

damien-rivet commented Jan 15, 2025

Description

When both swift-perception & RxSwift are added as dependencies to a project, both packages are imported in a file and one class is decorated with @Perceptible it produces a compilation error.

namespace collision swift-perception rxswift

Checklist

  • I have determined that this bug is not reproducible using Swift's observation tools. If the bug is reproducible using the @Observable macro or another tool from the Observation framework, please file it directly with Apple.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

Expected behavior

The generated code should look like the following:

extension DummyObject: Perception.Perceptible, Observation.Observable {
}

A very small change but it would negates all potential namespace collision for people that relies on both packages.

Actual behavior

The macro will generate the following code:

extension DummyObject: Perception.Perceptible, Observable {
}

Where Observable is not coming from Observation but from RxSwift (link) which causes a compilation issue as this class is generic but not the base object.

Steps to reproduce

  1. Create a new App with Xcode
  2. Add both swift-perception & RxSwift packages as SPM dependencies on the project (include them in the App dependencies)
  3. Create a new empty file
  4. Import both packages in the file
  5. Add an empty class that is decorated with the @Perceptible macro
  6. Build the App

The empty class:

import Perception
import RxSwift

@Perceptible
final class DummyObject { }

Fortunately, the workaround is to implement the perception macro manually.

extension DummyObject: Perception.Perceptible, Observation.Observable {
}

Here is a sample project: NamespaceCollisionWithRxSwift.zip

Perception version information

1.4.1

Destination operating system

iOS 18.2

Xcode version information

16.2

Swift Compiler version information

swift-driver version: 1.115.1
Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0
@damien-rivet damien-rivet added the bug Something isn't working due to a bug in the library. label Jan 15, 2025
@damien-rivet damien-rivet linked a pull request Jan 15, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working due to a bug in the library.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant