Skip to content

[Xcode 26.4] GenerateStateCpp emits symbol-less objects for stateless component libraries #57525

Description

@Malakof

Description

React Native Codegen 0.86.0 always emits a States.cpp translation unit, but GenerateStateCpp.js currently renders no state definitions (StateTemplate returns an empty string). For component libraries whose generated state source has no other definitions, Xcode 26.4.1 libtool reports the compiled object as symbol-less.

Environment

  • @react-native/codegen: 0.86.0
  • React Native: 0.86.0
  • Xcode: 26.4.1
  • SDK: iOS simulator
  • configuration: Release, new architecture

Reproduction

Generate component code for libraries such as rnscreens or safeareacontext, then build the generated ReactCodegen target in Release. The generated source contains only the header include and empty namespace.

libtool: warning: States-89020dfa9f92f64072c3fa149a6beab6.o has no symbols
libtool: warning: States-07dedd22012e4ff4426f2b40f6fb19ed.o has no symbols

Verified source-level fix

Have GenerateStateCpp emit a unique external-linkage function based on the sanitized library name, for example:

extern "C" void RnscreensStatesLinkerAnchor() {}

A regenerated Release object then exposes _RnscreensStatesLinkerAnchor in nm -g, and libtool no longer reports an empty object. This fixes the source without warning flags, suppression, or log filtering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Author FeedbackNeeds: ReproThis issue could be improved with a clear list of steps to reproduce the issue.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions