Skip to content

Extending from an external HybridObject does not compile in Swift #1158

@mrousavy

Description

@mrousavy

What happened?

Using external types (that's structs, enums, and HybridObjects defined in another Nitro Module than your own Nitro Module) works fine when they are used as struct properties, parameters or return values.

However when you create a HybridObject that extends from a HybridObject inside an external Nitro Module, the Swift build fails.

It works fine for C++ and Kotlin.

Nitrogen CLI logs (with --logLevel="debug")

🔧  Loading nitro.json config...
🚀  Nitrogen 0.33.1 runs at ~/Projects/react-native-vision-camera-v5/packages/react-native-vision-camera
    🔍  Nitrogen found 5 specs in ./src/specs
    🔍  Nitrogen found 0 specs in ./src/specs/common-types
    🔍  Nitrogen found 2 specs in ./src/specs/frame-processors
    🔍  Nitrogen found 2 specs in ./src/specs/inputs
    🔍  Nitrogen found 4 specs in ./src/specs/instances
    🔍  Nitrogen found 1 spec in ./src/specs/metering
    🔍  Nitrogen found 8 specs in ./src/specs/outputs
    🔍  Nitrogen found 2 specs in ./src/specs/views
... omitted (private)

Nitro Specs (.nitro.ts)

// In react-native-vision-camera-v5:
export interface CameraOutput extends HybridObject<{ ios: 'swift', android: 'kotlin' }> {
  // ...
}

// In react-native-vision-camera-v5-code-scanner:
import { CameraOutput } from 'react-native-vision-camera-v5'

export interface CodeScannerOutput extends CameraOutput {
  // ...
}

Nitro Modules Version

0.33.1

Nitrogen Version

0.33.1

Operating system

MacOS

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    nitrogenIssue is related to the code-generator "Nitrogen"swiftIssue regarding the Swift part of Nitro/Nitrogen

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions