Skip to content

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

Closed
BartoszKlonowski wants to merge 14 commits intomainfrom
feature-windows-support
Closed

Support React Native Windows - C++/WinRT and C# templates with Example#172
BartoszKlonowski wants to merge 14 commits intomainfrom
feature-windows-support

Conversation

@BartoszKlonowski
Copy link
Member

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.

This commit adds the C++ UI Component template with empty class IDL
implementation which should act as a starting point for a developer.
Full implementation of UI Component for RNW library can be found in the
Microsoft's docs.
The template for C++ Native UI component has been refactored:
 * ReactPackageProvider added so the RNW can automatically link the
   created FrameworkElement
 * View and ViewManager scaffolded for better starting point
 * Solution file fixed - more convenient approach to project
   architecture and structure
 * View IDL template does now derive from FrameworkElement
   This is done mostly for the compilation purposes, but this can also
   give a better understanding for the developers
The native module template has been refactored:
 * PCH removed
 * Native Module header file formatting unified
 * Project architecture improved
The Windows configuration is based on the C# language - it's easy and
simple to understand and has better support when it comes to the UWP
documentation.
The example is generated for the version 0.63.4 specified in the
package.json
@asklar
Copy link

asklar commented May 26, 2021

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
Copy link

asklar commented May 26, 2021

@jonthysell to review too

@BartoszKlonowski
Copy link
Member Author

@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.

@asklar
Copy link

asklar commented May 26, 2021

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 :)

@BartoszKlonowski
Copy link
Member Author

@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
Copy link
Member Author

@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.

Copy link

@asklar asklar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend adding CI validation that the apps/libs/modules can be generated properly as well as that they build :)

This commit fixes and covers all review findings of @asklar from
Microsoft:
 - windows-uwp instead of windows for all the template packages name
 - author.name used for Package.appxmanifes
 - ViewManager extended with ReactContext and NativeProperties
 - unnecessary readme.txt files removed
@jahead
Copy link

jahead commented Aug 4, 2021

What's the state of this?
@BartoszKlonowski

@BartoszKlonowski
Copy link
Member Author

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

@jahead
Copy link

jahead commented Sep 3, 2021

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

@satya164
Copy link
Member

@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 satya164 force-pushed the main branch 2 times, most recently from b94e81b to cf3f675 Compare October 18, 2022 21:31
@rtorr
Copy link

rtorr commented Jan 19, 2023

looking forward to this

@satya164 satya164 force-pushed the main branch 6 times, most recently from 99cfbff to 0775dc9 Compare March 10, 2023 15:30
@satya164 satya164 force-pushed the main branch 3 times, most recently from 7b11914 to 6facf3b Compare July 4, 2023 17:35
@satya164
Copy link
Member

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 satya164 closed this Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add template for React Native Windows plugins

5 participants