microsoft / react-native-code-push

React Native module for CodePush
http://appcenter.ms
Other
9k stars 1.48k forks source link

code push package not building with react native windows. #2235

Open arunvenkat1911 opened 2 years ago

arunvenkat1911 commented 2 years ago

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 2) cd projectName 3) npx react-native-windows-init --overwrite --language cs 5) npm install react-native-code-push 6) npx react-native autolink-windows 7) 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

chrisglein commented 2 years ago

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

arunvenkat1911 commented 2 years ago

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

chrisglein commented 2 years ago

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)

arunvenkat1911 commented 2 years ago

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]_

chrisglein commented 2 years ago

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.

Rushiraj-karm commented 2 years ago

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

rahman2835 commented 2 years ago

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

Boiko33 commented 2 years ago

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?

tmjordan commented 2 years ago

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

Boiko33 commented 2 years ago

@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

rahman2835 commented 2 years ago

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

rahman2835 commented 2 years ago

@vmoroz any update on this issue?

DrewHigginsMSFT commented 1 year ago

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?

rahman2835 commented 1 year ago

any update on this issue?

asklar commented 1 year ago

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

joshuayoes commented 1 year ago

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.

asklar commented 1 year ago

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

vmoroz commented 1 year ago

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 commented 1 year ago

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.

joshuayoes commented 1 year ago

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

mununki commented 9 months ago

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?

codinglesstech commented 5 months ago

C++ code is fixed in this commit in my fork: vmoroz@06ffaba#diff-817e63f5b664a6f031d60feba3a721bbdab4fc21c058b8548faa485b5cfc523a I need to fix the example bundle creation before I can submit a PR.

thankyou i'll try that with your change