Skip to content

Build fails on Expo iOS - Error: Union types are unsupported in structs #68

@SamYu

Description

@SamYu

Describe the bug
iOS build fails during React Native codegen with the error Union types are unsupported in structs. The failure occurs when installing pods or building the iOS app after adding the dependency that triggers codegen.

To Reproduce
Steps to reproduce the behavior:

  1. Create or open a React Native app managed by Expo
  2. Install the package @google/react-native-make-payment
  3. Run npx expo prebuild -p ios
  4. Run cd ios && pod install
  5. Build the app with npx expo run:ios or xcodebuild
  6. See the build fail during codegen with the error shown below

Expected behavior
The iOS app should build successfully. Codegen should complete without errors and the module should be compiled and linked.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: macOS
  • Browser: N/A
  • Version: N/A

Smartphone (please complete the following information):

  • Device: iPhone simulator and physical device
  • OS: iOS
  • Browser: N/A
  • Version: N/A

Additional context

  • React Native: 0.76.9

  • Expo SDK: 52.0.0

  • Platform: iOS only, Android builds succeed

  • Pods step reference from ios/Podfile:

    # from /Users/samyu/Moreta/moreta-mobile/ios/Podfile:41
    use_react_native!(
      # :path => config[:reactNativePath],
    )
    
  • Full error log:

    Error: Union types are unsupported in structs
        at StructCollector.process (/Users/samyu/Moreta/moreta-mobile/node_modules/@react-native/codegen/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js:194:15)
        at /Users/samyu/Moreta/moreta-mobile/node_modules/@react-native/codegen/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js:223:32
        at Array.map (<anonymous>)
        at StructCollector._insertStruct (/Users/samyu/Moreta/moreta-mobile/node_modules/@react-native/codegen/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js:217:56)
        at StructCollector._insertAlias (/Users/samyu/Moreta/moreta-mobile/node_modules/@react-native/codegen/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js:203:12)
        at StructCollector.process (/Users/samyu/Moreta/moreta-mobile/node_modules/@react-native/codegen/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js:186:14)
        at /Users/samyu/Moreta/moreta-mobile/node_modules/@react-native/codegen/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js:223:32
        at Array.map (<anonymous>)
        at StructCollector._insertStruct (/Users/samyu/Moreta/moreta-mobile/node_modules/@react-native/codegen/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js:217:56)
        at StructCollector._insertAlias (/Users/samyu/Moreta/moreta-mobile/node_modules/@react-native/codegen/lib/generators/modules/GenerateModuleObjCpp/StructCollector.js:203:12)
    
  • This appears related to React Native codegen handling of union types inside a struct in a TurboModule spec or types used by the affected package. A similar report is here: Union types are unsupported in structs mkuczera/react-native-haptic-feedback#127

Minimal repro notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions