mrousavy/nitro

Tuple (`[A, B, C]`) doesn't work in Swift

mrousavy opened this issue · 0 comments

When creating a tuple, the Swift code gets generated but it won't compile.

Tuple:

interface MyHybrid extends HybridObject<{ ios: 'swift' }> {
  someFunc(value: [number, number, number])
}

Generated Swift:

class MyHybrid implements MyHybridSpec {
  func someFunc(value: (Double, Double, Double)) {
    // do nothing
  }
}

Looks good, but unfortunately it will fail to compile because the Swift compiler inserted an additional < and > around the C++ type (std::tuple<<...>> instead of std::tuple<..>) in the generated -Swift.h header:

- SWIFT_INLINE_THUNK std::__1::tuple<<double, double, std::string>> MyHybridSpecCxx::getSomeTuple() {

I already reported this bug in the Swift compiler repo: swiftlang/swift#75865

Until that's fixed, tuples are currently not supported in Nitrogen.