React-native-windows: Unable to build new native module library due to CodeGen problem

Created on 13 Nov 2020  路  5Comments  路  Source: microsoft/react-native-windows

Environment

Run the following in your terminal and copy the results here.

  1. npx react-native --version: 4.13.0
  2. npx react-native info:
    image
  • SDK version : 10.0.18363.1198

  • Target Platform Version(s):
    Desktop

  • Target Device(s):
    Visual Studio 2019

  • Visual Studio Version:
    Debug

  • Build Configuration:
    -->x64

Steps To Reproduce

  1. Follow the instructions on https://microsoft.github.io/react-native-windows/docs/native-modules-setup#creating-a-new-native-module-library-project, to create new native module library.

  2. Try to Build It

Expected Results

Building the project should succeed, instead this is the result:

CodeGenerror

link to a repository:

https://github.com/getuliovdmnaweb/MyLibrary

Author Feedback bug

Most helpful comment

@getuliovdmnaweb : I was able to get things to build with this change (which is present in the template, I'm curious if you may have undone this change locally or if we are creating the project wrongly on some older version...?)

namespace MyLibrary
{
-    public sealed class ReactPackageProvider : IReactPackageProvider
+    public sealed partial class ReactPackageProvider : IReactPackageProvider
    {
        public void CreatePackage(IReactPackageBuilder packageBuilder)
        {
            packageBuilder.AddAttributedModules();
        }

+        partial void CreatePackageImplementation(IReactPackageBuilder p);
    }
}

All 5 comments

@jonthysell @dannyvv does this look familiar?

@getuliovdmnaweb : I was able to get things to build with this change (which is present in the template, I'm curious if you may have undone this change locally or if we are creating the project wrongly on some older version...?)

namespace MyLibrary
{
-    public sealed class ReactPackageProvider : IReactPackageProvider
+    public sealed partial class ReactPackageProvider : IReactPackageProvider
    {
        public void CreatePackage(IReactPackageBuilder packageBuilder)
        {
            packageBuilder.AddAttributedModules();
        }

+        partial void CreatePackageImplementation(IReactPackageBuilder p);
    }
}

Environment

Run the following in your terminal and copy the results here.

  1. npx react-native --version: 4.13.0
  2. npx react-native info:
    image
  • SDK version : 10.0.18363.1198
  • Target Platform Version(s):
    Desktop
  • Target Device(s):
    Visual Studio 2019
  • Visual Studio Version:
    Debug
  • Build Configuration:
    -->x64

Steps To Reproduce

  1. Follow the instructions on https://microsoft.github.io/react-native-windows/docs/native-modules-setup#creating-a-new-native-module-library-project, to create new native module library.
  2. Try to Build It

Expected Results

Building the project should succeed, instead this is the result:

CodeGenerror

link to a repository:

https://github.com/getuliovdmnaweb/MyLibrary

I have the same in project from scratch (https://microsoft.github.io/react-native-windows/docs/getting-started) when build in console, see screenshot ManagedCodGen.jpg. When build via VisualStudio all ok, but when app starting I got crash, see screenshot crashWhenStarting.jpg.

VisualStudio version - 16.8.1
npm version - 6.14.8
node versio - v14.15.1
ManagedCodGen
crashWhenStarting

Dependecies:
"dependencies": {
"react": "16.13.1",
"react-native": "0.63.2",
"react-native-windows": "^0.63.0-0"
},
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/runtime": "^7.8.4",
"@react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^25.1.0",
"eslint": "^6.5.1",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.59.0",
"react-test-renderer": "16.13.1"
},

@getuliovdmnaweb : I was able to get things to build with this change (which is present in the template, I'm curious if you may have undone this change locally or if we are creating the project wrongly on some older version...?)

namespace MyLibrary
{
-    public sealed class ReactPackageProvider : IReactPackageProvider
+    public sealed partial class ReactPackageProvider : IReactPackageProvider
    {
        public void CreatePackage(IReactPackageBuilder packageBuilder)
        {
            packageBuilder.AddAttributedModules();
        }

+        partial void CreatePackageImplementation(IReactPackageBuilder p);
    }
}

I have this changes, but still can't build app via console and get crash when app starting in build via VS see my message above.
image

@tarasvakulka your issue seems unrelated to the issue being discussed here, please file a new issue.

Was this page helpful?
0 / 5 - 0 ratings