react-native-code-push icon indicating copy to clipboard operation
react-native-code-push copied to clipboard

code push package not building with react native windows.

Open arunvenkat1911 opened this issue 2 years ago • 22 comments

Problem Description

Hi Team,

I am working on code push for native windows app. I have done the initial set up for the project and got the app working fine in my local. But when I included the code push package, the app is not building.

Steps To Reproduce

  1. npx react-native init <projectName>
  2. cd projectName
  3. npx react-native-windows-init --overwrite --language cs
  4. npm install react-native-code-push
  5. npx react-native autolink-windows
  6. npx react-native run-windows

Expected Results

The build should be success and the app should be launched fine.

CLI version

6.3.1

Environment

info Fetching system and libraries information...
System:
    OS: Windows 10 10.0.22000
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 5.37 GB / 31.75 GB
  Binaries:
    Node: 16.7.0 - C:\Program Files\nodejs\node.EXE
    Yarn: Not Found
    npm: 7.20.3 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
    Windows SDK:
      AllowDevelopmentWithoutDevLicense: Enabled
      AllowAllTrustedApps: Enabled
      Versions: 10.0.16299.0, 10.0.17134.0, 10.0.17763.0, 10.0.18362.0, 10.0.19041.0, 10.0.20348.0, 10.0.22000.0
  IDEs:
    Android Studio: Not Found
    Visual Studio: 17.0.32014.148 (Visual Studio Professional 2022), 16.11.32002.261 (Visual Studio Professional 2019)
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2
    react-native: 0.66.0 => 0.66.0
    react-native-windows: 0.66.6 => 0.66.6
  npmGlobalPackages:
    *react-native*: Not Found

Target Platform Version

No response

Target Device(s)

Desktop

Visual Studio Version

Visual Studio 2022

Build Configuration

Debug

Snack, code example, screenshot, or link to a repository

No response

arunvenkat1911 avatar Mar 07 '22 05:03 arunvenkat1911

@arunvenkat1911 Can you share the build log that contains the failure?

chrisglein avatar Mar 07 '22 17:03 chrisglein

Attaching the Build log. BuildLog.txt

Also please have a look at the errors that we get while running the app from visual studio. CodePushVSError

arunvenkat1911 avatar Mar 08 '22 09:03 arunvenkat1911

From that build log:

× Build failed with message Building Solution - error code 1. Check your build configuration. × It is possible your installation is missing required software dependencies. Dependencies can be automatically installed by running E:\Samples\CodePush\windowscodepushsample\node_modules\react-native-windows\scripts\rnw-dependencies.ps1 from an elevated PowerShell prompt. For more information, go to http://aka.ms/rnw-deps Re-run the command with --logging for more information

Can you check to see if your dependencies are set up correctly with that script? (and enable logging and report back if it's reporting an issue)

chrisglein avatar Mar 10 '22 19:03 chrisglein

Please have a look at the attached file.

The issue is coming from code push package added. BuildLogWithFullLogging.txt

E:\Samples\CodePush\windowscodepushsample\node_modules\react-native-code-push\windows\CodePush\CodePushConfig.cpp(18,36): error C2259: 'winrt::Microsoft::CodePush::ReactNative::implementation::CodePushConfig': cannot instant iate abstract class [E:\Samples\CodePush\windowscodepushsample\node_modules\react-native-code-push\windows\CodeP ush\CodePush.vcxproj]

arunvenkat1911 avatar Mar 16 '22 09:03 arunvenkat1911

Something in RNW's codepush support is interacting with cppwinrt wrong. Let's follow up with an issue on that repo to make sure it's tracked.

chrisglein avatar Mar 17 '22 18:03 chrisglein

I am facing same issue, did anyone find solution for same ?

Rushiraj-karm avatar Sep 19 '22 09:09 Rushiraj-karm

@Rushiraj-karm nope. We did not hear any thing from Microsoft team.

rahman2835 avatar Sep 19 '22 09:09 rahman2835

Facing same issue with: react-native: 0.70.3 react-native-windows: 0.70.3 react-native-code-push: 7.0.5 Did smb find any solutions?

Boiko33 avatar Oct 17 '22 08:10 Boiko33

I have the exact same issue. Please any solution or workaround? Thanks

tmjordan avatar Nov 07 '22 16:11 tmjordan

@tmjordan Unfortunately I didn't find any working solution. In the case that currently I am not using code-push for especially windows app, only for iOS/Android, I just removed this package from windows platform in react-native.config.js. And waiting for some new updates or whatever

Boiko33 avatar Nov 09 '22 07:11 Boiko33

There is no working solution as of now. we are also waiting for the same.

rahman2835 avatar Nov 09 '22 07:11 rahman2835

@vmoroz any update on this issue?

rahman2835 avatar Nov 09 '22 07:11 rahman2835

Any updates on this issue? Was investigating using Code Push on my team's RNW app but ran into this issue that seems like it's been ongoing for over a year?

DrewHigginsMSFT avatar Mar 17 '23 22:03 DrewHigginsMSFT

any update on this issue?

rahman2835 avatar Apr 19 '23 10:04 rahman2835

the CodePushConfig type does not have a constructor so an instance of it cannot be constructed. It looks like you are supposed to call the static methods on that type only, not construct an instance of it. See example in https://github.com/microsoft/react-native-code-push/blob/master/Examples/CodePushDemoAppCpp/windows/CodePushDemoAppCpp/App.cpp#L79

asklar avatar Sep 25 '23 16:09 asklar

I spent an hour or two with an engineer to take a closer look at this:

The header file tries to define a private static instance of this class: https://github.com/microsoft/react-native-code-push/blob/75785cbabcfa9b2934bdb2c6626cfe95ba5d4977/windows/CodePush/CodePushConfig.h#L50

Earlier in the file, there is a CodePushConfigT template class that seems to be including some logic to allow for CodePushConfig to be turned into a class to be instantiated. https://github.com/microsoft/react-native-code-push/blob/75785cbabcfa9b2934bdb2c6626cfe95ba5d4977/windows/CodePush/CodePushConfig.h#L16

However, that template class is auto-generated and not included in the git repository, so I can't include here.

joshuayoes avatar Sep 25 '23 19:09 joshuayoes

that's just the implementation (see the ::implementation part of the namespace in line 14), so you're not supposed to use that; instead you should use the same type but without the ::implementation namespace. See the example in https://github.com/microsoft/react-native-code-push/blob/master/Examples/CodePushDemoAppCpp/windows/CodePushDemoAppCpp/App.cpp#L79

asklar avatar Sep 25 '23 20:09 asklar

I spent an hour or two with an engineer to take a closer look at this:

The header file tries to define a private static instance of this class:

https://github.com/microsoft/react-native-code-push/blob/75785cbabcfa9b2934bdb2c6626cfe95ba5d4977/windows/CodePush/CodePushConfig.h#L50

Earlier in the file, there is a CodePushConfigT template class that seems to be including some logic to allow for CodePushConfig to be turned into a class to be instantiated.

https://github.com/microsoft/react-native-code-push/blob/75785cbabcfa9b2934bdb2c6626cfe95ba5d4977/windows/CodePush/CodePushConfig.h#L16

However, that template class is auto-generated and not included in the git repository, so I can't include here.

@joshuayoes , it seems that the issue is related to the changes in our project templates that use C++/WinRT. We now prohibit instantiation of WinRT classes directly. They must be created with winrt::make. I will see how to fix it here.

vmoroz avatar Sep 25 '23 21:09 vmoroz

C++ code is fixed in this commit in my fork: https://github.com/vmoroz/react-native-code-push/commit/06ffaba9311557dfb68dcf5f65e637a504497d7f#diff-817e63f5b664a6f031d60feba3a721bbdab4fc21c058b8548faa485b5cfc523a I need to fix the example bundle creation before I can submit a PR.

vmoroz avatar Sep 26 '23 00:09 vmoroz

Thank you so much for taking a look at this @vmoroz!

joshuayoes avatar Sep 26 '23 00:09 joshuayoes

I bump to the same issue.

"react-native": "0.72.7", "react-native-code-push": "^8.1.1",

@vmoroz Was your PR sumitted and merged? When can I expect this issue to be resolved?

mununki avatar Feb 21 '24 13:02 mununki