react-native-community / react-native-community/cli

Support existing CLI apple project use cases without relying on podfile existing on the disk (projects using SPM)

Open
#2,856 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request
Dominant language
TypeScript
Stars
2.9k
Forks
949
PR merge metrics
No merged PRs in 30d

Description

Describe the Feature

Since RN 0.87 there's an experimental SPM support introduced

Right now when project is migrated from Cocoapods to SPM, all the commands that rely on the getProjectConfig from @react-native-community/cli-config-apple (e.g. react-native spm) will fail once the Podfile is removed from its default location. Having dead Podfile just to keep the config command work doesn't make any sense

Possible Implementations

looking at where findPodfilePath or findPodfilePaths are used, there're 2 internal use cases

  • https://github.com/react-native-community/cli/blob/9013a480c66aece0e23cc8082ee23f92274e3cf4/packages/cli-config-apple/src/config/index.ts#L36 (getProjectConfig)
  • https://github.com/react-native-community/cli/blob/9013a480c66aece0e23cc8082ee23f92274e3cf4/packages/cli-doctor/src/tools/healthchecks/xcodeEnv.ts#L33 (relies on the project config)

One idea would be to at least prioritize user config (project.ios.sourceDir from react-native.config.js) and use it instead of always returning null config when there's no Podfile. That way the amount of changes in CLI will be minimal and SPM users will be able to just set the value to e.g. ios and to drop the Podfile.

Another idea would be to look for .spm-injected.json within the candidate directory (it's a file injected via react-native spm command) - if it's found, it means that its parent directory is in fact the one that consists .pbxproj file and the directory with swift/objc source code.

Last one I can think of is to look for .xcode.env file, which is afaik should exist in each RN project next to Podfile

The resolving order should be like this: (user-config) -> (.spm-injected.json OR .xcode.env) -> (Podfile) - if none of those exist only then return null for the project config value

Related Issues

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing findPodfilePath and findPodfilePaths in packages/cli-config-apple/src/config/index.ts and the xcodeEnv healthcheck in packages/cli-doctor/src/tools/healthchecks/xcodeEnv.ts. Compare how getProjectConfig handles project.ios.sourceDir, .spm-injected.json, .xcode.env, and Podfile. Done means SPM projects without a Podfile still resolve their project config while projects with none of these indicators return null.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.