react-native-community / discussions-and-proposals

Discussions and proposals related to the main React Native project
https://reactnative.dev
1.68k stars 126 forks source link

Publish specification of what non-default Xcode Project settings are required for React Native #662

Open ScottRobbins opened 1 year ago

ScottRobbins commented 1 year ago

Introduction

Xcode Project files are difficult to use, especially on larger teams. They're incredibly difficult to read from source, cause all sorts of merge conflicts that aren't easy to resolve and make certain kinds of code generation tasks (for special use cases) difficult to achieve.

A lot of native iOS developers in the wider community use tools like XcodeGen or Tuist to generate their project files, avoiding these issues and gaining flexibility.

However, react native projects seem to always start from some base project file, and it's a bit unclear what project settings are changed to make it work from the default (run scripts, build settings, etc). Because of this, it is very tricky to use these tools and get the project to work, and also difficult to upgrade.

I think it would be helpful for the wider community if this information was available for every React Native version, so that these tools could be utilized, without requiring React Native, itself, to support them directly.

Details

Documentation for each new react native version (minor and if there is ever a major), that lists the changes made from a default Xcode project in terms of Build Settings & Run scripts would be incredibly helpful.

This information would make custom tooling much easier to develop, without requiring the core project supports every use case.

cortinico commented 1 year ago

cc @cipolleschi @dmytrorykun as they have relevant context here.

cipolleschi commented 1 year ago

Hi @ScottRobbins, thank you for posting this. I completely agree with you that maintaining an xcodeproj is not ideal.

We have plans to start using Tuist for the template as it will make conflict resolution easier and also easier to track the changes. This kind of work will require some changes also to the React Native CLI, so it is not a simple change to the template, but it require a little bit more of work.

So far, I don't have a timeline for when this is going to happen, but I hope to be able to have it soon.

Meanwhile, I'd like to understand if there is something specific you need right now to unblock you or it is more like a proposal to improve the framework as a whole.

In any case, thank you again for this, we really need these kind of posts to understand where are the community's pain points.

ScottRobbins commented 1 year ago

Thanks @cipolleschi , this is great to hear!

We have plans to start using Tuist for the template as it will make conflict resolution easier and also easier to track the changes. This kind of work will require some changes also to the React Native CLI, so it is not a simple change to the template, but it require a little bit more of work.

That would be great. If the work for Tuist ends up not being a direction the team would like to go in, or will take longer than expected, even a document listing the changes would be helpful.

For my use case, we build a lot of white labeled apps. Right now, we have a massive project file with many targets. Being able to generate the projects would allow much more flexibility to generate the targets dynamically and make it easier to include/exclude code from specific ones. Likely, I'd end up making my own Tuist template, using the one the react native cli uses as a reference.

Meanwhile, I'd like to understand if there is something specific you need right now to unblock you or it is more like a proposal to improve the framework as a whole.

It was more of a proposal to improve the framework as a whole.

A couple weeks ago I was trying to convert one of our larger projects to use XcodeGen and ran out of time before I could get it fully working, a little unsure of what I was missing.

This isn't something I'll have time to revisit for a while anyway, but I thought I'd make this suggestion.

cipolleschi commented 1 year ago

@ScottRobbins BTW, I recently published this RFC Hopefully, we would be able to land it before 0.73. I'd love to hear your thoughts on the matter! 😄

ScottRobbins commented 1 year ago

I will take a look. Thank you!

ScottRobbins commented 7 months ago

@cipolleschi Given that this RFC hasn't progressed much, perhaps a start still would be for the React Native team to publish a specification of what non-default build settings are needed?

cipolleschi commented 6 months ago

Hi @ScottRobbins, sorry for the late reply but I was away for a long PTO. In the past months, we tried to push all the known build settings to Cocoapods, so that those are applied automatically and people shouldn't have to worry too much about the xcodeproj file. I hope that this effort was visible thanks to the fewer lines changed in the xcodeproj files in the update helper tool after every release.

If we are moving these build settings to the build system and we are automating them, is it still worth to have the list of build settings documented somewhere? What is your use case? The problem of having a separated list of build settings with the documentation is maintenance: I can see how we would add/remove some build setting from the build system and we forget to update the documentation, which becomes stale and basically useless...

ScottRobbins commented 6 months ago

No worries @cipolleschi, I appreciate you responding.

Ultimately, my goal is to use something like Tuist or Xcodegen to generate the project file. Eventually, perhaps Tuist will be supported by React Native directly like in that RFC linked above, but for now I was hoping to set this up myself.

When the settings overrides are made directly on the project file, it's a bit difficult to find them and pick them out, and in the past I have been left with build errors when attempting to generate a project file that I did not quite understand how to resolve.

However, it has been quite a while since I tried this last, so I'll take a look at the later changes and give it another go 😃

I know my use case isn't supported by this project, and I do agree that it would be difficult to keep the documentation up to date. I'll also put some thought into how to ease that burden, if possible.