Codegen: app codegenConfig with no spec files emits "${PODS_ROOT}/.." as Generate Specs input and causes an Xcode dependency cycle

オープン 初心者向け
#58,621 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
92/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, react-native

調査の方向性

scripts/codegen/generate-artifacts-executor/generateReactCodegenPodspec.js から始め、特に getInputFiles() を確認し、空の jsSrcsDir を持つ app-level の codegenConfig のケースを再現してください。生成された ReactCodegen.podspec を調べ、Generate Specs の input_files リストが ios ディレクトリを含まず空であることを確認してください。その後、Xcode の依存関係サイクルが発生しなくなったことを検証してください。

索引モデルが issue の本文から書いたものです。

説明

Needs: Author Feedback Needs: Repro
Description

scripts/codegen/generate-artifacts-executor/generateReactCodegenPodspec.jsgetInputFiles() builds the Generate Specs script phase input_files from a find over the app's codegenConfig.jsSrcsDir. When that directory contains no Native*.{js,ts} / *NativeComponent.{js,ts} files, execSync(find …) returns an empty string, ''.trim().split('\n') is [''], and the single empty path is mapped to:

'input_files' => ["${PODS_ROOT}/.."]

i.e. the whole ios/ directory. Xcode then sees that the Generate Specs phase of ReactCodegen depends on files produced by other targets' script phases in that directory (in an Expo project: the app target's [Expo] Configure project phase, which writes Pods/Target Support Files/…/ExpoModulesProvider.swift) and fails:

error: Cycle in dependencies between targets 'Callingx' and 'TurnoHosts'; building could produce unreliable results.
Cycle path: Callingx → ReactCodegen → TurnoHosts → Callingx
→ Target 'Callingx' has an explicit dependency on Target 'ReactCodegen'
○ That command depends on command in Target 'ReactCodegen': script phase “[CP-User] Generate Specs”
→ That command depends on command in Target 'TurnoHosts': script phase “[Expo] Configure project”

An app-level codegenConfig with no spec files is a legitimate setup: it is the documented way to declare ios.modulesConformingToProtocol (e.g. an RCTImageURLLoader) from the app when a dependency cannot.

Steps to reproduce
  1. In an app's package.json add
    "codegenConfig": { "name": "AppSpecs", "type": "modules", "jsSrcsDir": "src/config", "ios": { "modulesConformingToProtocol": { "RCTImageURLLoader": ["SomeLoader"] } } }
    
    where src/config exists but has no spec files.
  2. pod install
  3. Inspect ios/build/generated/ios/ReactCodegen/ReactCodegen.podspec'input_files' => ["${PODS_ROOT}/.."].
  4. Build in Xcode → dependency cycle error above (seen with Expo SDK 57 projects; any other script phase writing under ios/ triggers it too).
Fix

Filter the empty entry:

   const list = String(execSync(findCommand))
     .trim()
     .split('\n')
+    .filter(Boolean)
     .sort()

With that, input_files is [] (same as projects without an app codegenConfig) and the build succeeds.

React Native Version

0.86.3

Affected Platforms

Build - MacOS, Runtime - iOS

主要言語
C++
スター
127k
フォーク
25.3k
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

react/react-native のほかの issue

react/react-native の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。