react-native-builder-bob icon indicating copy to clipboard operation
react-native-builder-bob copied to clipboard

Support React Native Windows - C++/WinRT and C# templates with Example

Open BartoszKlonowski opened this issue 3 years ago • 10 comments

This pull request closes #69

It delivers the full support of React Native Windows project's templates for both C# and C++ languages. Example project is configured as C# application.


Following changes were implemented:

  • Additional questions and options in the index.ts file for Windows support
  • package.json extended with react-native-windows: v0.63.4
  • C++/WinRT project templates for both native module and native UI component
  • C# project templates for both native module and native UI component
  • README updated with the information about Windows support
  • Example application provided with the Windows solution (.sln)

The 4 new project templates created in the Bob project are created as a 0.63.x projects with React Native Windows dependency already added to the solution configuration. None of the scaffolded projects use the precompiled headers. All headers required for implementation are included where they are required.

NOTE: Each language has its project's GUID being the same across native module and native UI component.

All projects are provided with the most basic source code file, which should be a starting point for a further implementation. Though they are basic and do nothing, they still compile successfully for each project. Those files and classes they implement are named according to the type of project selected. These basic modules/component are already registered in the ReactPackageProvider.


Please see the short presentation of the full template creation looks like (C# is taken as an example, but the procedure is of course the same for C++/WinRT):

BobExample


For some more explanations please check the commit messages.

BartoszKlonowski avatar May 26 '21 13:05 BartoszKlonowski

Love seeing the support for Windows apps being added. Main piece of feedback is that the project files and the code that the template RNW CLI produce, change over time. That is to say, an app created for 0.63 RNW will have different project/code files as 0.64 RNW. We expect we will continue to iterate on the template code and project files as we continue to evolve the platform. Sometimes we also update the template files/projects to backport a severe bugfix.

So ideally react-native-builder-bob wouldn't carry these files itself and instead just call the RNW CLI (or somehow "suck up" the files that RNW CLI uses for each version).

asklar avatar May 26 '21 18:05 asklar

@jonthysell to review too

asklar avatar May 26 '21 19:05 asklar

@asklar You've got the point - creating the project through the CLI would prevent us from updating the template and track backports. On the other hand current solution allows to do some customizations to the scaffolded solution, also whole system (each language, platform) is done like this so there's no confusion for a future maintainer, I also believe that the amount of changes required to be done to implement CLI for Windows only would be bigger than the current solution. Of course, the other side of a coin is that the XML file can be more confusing than command line, but I'm aware of that and to be honest I'm willing to keep on maintaining that.

But I see no problem in keeping your opinion in mind, so perhaps whole system will be based on CLI, not just Windows.

BartoszKlonowski avatar May 26 '21 20:05 BartoszKlonowski

Yes I can see your point; I wouldn't want Windows to be the odd one out that's different : ) I just worry about how RNBB will be able to keep up/know about changes to the templates, but if you guys are comfortable signing up to keep this maintained then I am not concerned :)

asklar avatar May 26 '21 21:05 asklar

@asklar What just came to my mind is that there's one main concern about CLI-based approach: react-native-windows-init have the --projectType flag which determines whether exe or dll will be created, but if it's the native module or native UI component is determined only by the files and the implementation of the project. So there would be no possibility to create those two separately. I'm glad that we agree about the current approach, but CLI-based approach should be something to think about once it's possible for each platfrom and environment.

BartoszKlonowski avatar May 26 '21 22:05 BartoszKlonowski

@asklar @jonthysell Did you take a chance to take a look at .vcxproj and .csproj files? These are essential for the Builder Bob tool to work correctly and your expertise is most valuable here.

BartoszKlonowski avatar May 31 '21 19:05 BartoszKlonowski

What's the state of this? @BartoszKlonowski

jahead avatar Aug 04 '21 05:08 jahead

@jahead We are still waiting for the review and will only merge this with an approval of an owner: @satya164

BartoszKlonowski avatar Aug 04 '21 14:08 BartoszKlonowski

@satya164 do you have some time for you to review this?

jahead avatar Sep 03 '21 00:09 jahead

@BartoszKlonowski can you rebase this PR on top of main if you get some time this week? then I'll have time to review and merge this.

satya164 avatar Jun 21 '22 20:06 satya164

looking forward to this

rtorr avatar Jan 19 '23 22:01 rtorr

Closing due to inactivity. I'd like to figure out a different way to support other platforms without adding the code to this repo.

satya164 avatar Nov 24 '23 12:11 satya164