Code push and debugging
Just implemented code push and it all works well. How to debug locally - hot reload etc, after setting up code push? Can get it working by commenting out export default codepush(myapp) in js, and running react-native start and running debug from vs2015, but this seems to be a bit long winded. Has anyone got suggestions to do this better? Thanks
You shouldn't need to comment anything out. Running from Visual Studio should be okay assuming you use the right build configuration. Can you paste your MainPage.cs file here?
Thanks, see as follows =================== MainPage.cs ===================
using ReactNative;
using ReactNative.Modules.Core;
using ReactNative.Shell;
using System.Collections.Generic;
using CodePush.ReactNative;
namespace MobilePos
{
class MainPage : ReactPage
{
private CodePushReactPackage codePushReactPackage;
public override string MainComponentName
{
get
{
return "MobilePos";
}
}
#if BUNDLE
public override string JavaScriptBundleFile
{
get
{
codePushReactPackage = new CodePushReactPackage("my-code-push-key", this);
return codePushReactPackage.GetJavaScriptBundleFile();
}
}
#endif
public override List<IReactPackage> Packages
{
get
{
return new List<IReactPackage>
{
new MainReactPackage(),
// codePushReactPackage // needed to comment this to run locally
};
}
}
public override bool UseDeveloperSupport
{
get
{
#if !BUNDLE || DEBUG
return true;
#else
return false;
#endif
}
}
}
}
================== index.windows.js ==================
/**
* POS
* https://apparel21.com
*/
import {
AppRegistry,
} from 'react-native';
import Root from './js/Root';
AppRegistry.registerComponent('MobilePos', () => Root);
=================== /js/Root.js ===================
import React, { Component } from 'react'
import codePush from 'react-native-code-push'
import { Provider } from 'react-redux'
import NavigationRoot from './components/NavigationRoot'
import configureStore from './store/configureStore'
const store = configureStore({})
class Root extends Component {
render() {
return (
<Provider store={store}>
<NavigationRoot />
</Provider>
);
}
}
//export default codePush(Root) // commenting to debug locally
export default Root
========== package.json ===================
{
"name": "MobilePos",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"dependencies": {
"react": "15.3.2",
"react-native": "^0.35.0",
"react-native-code-push": "^1.15.0-beta",
"react-native-side-menu": "^0.20.1",
"react-native-vector-icons": "git+https://[email protected]/jmcginty/react-native-vector-icons.git",
"react-native-windows": "^0.35.0",
"react-redux": "^4.4.5",
"redux": "^3.6.0",
"redux-logger": "^2.6.1",
"redux-thunk": "^2.1.0"
},
"devDependencies": {
"babel-eslint": "^6.1.2",
"eslint": "^3.5.0",
"eslint-config-airbnb": "^11.1.0",
"eslint-plugin-import": "^1.15.0",
"eslint-plugin-jsx-a11y": "^2.2.2",
"eslint-plugin-react": "^6.3.0",
"rnpm-plugin-windows": "^0.2.0"
}
}
@KalKhera Presuming you are not using DebugBundle or ReleaseBundle configurations, you should never be using the CodePush logic. If you deploy the app using react-native run-windows or run from Visual Studio with the Debug Configuration (not DebugBundle), it should connect to the packager server.
Hi, resolved with following changes In mainpage.cs
public override List<IReactPackage> Packages
{
get
{
#if BUNDLE
return new List
In js componentDidMount() { if (codePush) { codePush.sync() } }
Update to my resolution codePush.sync() does not seem to work in windows
I had to use export default codePush(MyApp) to get it working, ie
let exp = null if (codePush) { exp = codePush(Root) } else { exp = Root } export default exp
@KalKhera what version of code push are you using?
"react-native-code-push": "^1.15.0-beta", Hi, I am getting confusing results. It seemed to work fine on my machine, but on colleagues machines, code push just doesn't seem to fire. IOS has worked flawlessly using either method. I am still diagnosing,,
Okay, lmk what you find out.
It works very intermittently, has anyone else tried using code push with windows?
Could be a problem with codepush
So scenario this morning works for 3 codepush updates then,, Download manager logs the following error Update is invalid - A JS bundle file named "index.windows.bundle" could not be found within the downloaded contents. Please check that you are releasing your CodePush updates using the exact same JS bundle file name that was shipped with your app's binary.
The files in the download folder look as follows assets folder main.jsbundle main.jsbundle.meta
The download will keep failing from now on and we are 'stuck'
Problem fixed - Collaborator was code pushing , their updates were getting ignored. The reason is they had a wrong binary version number in the following file - Package.appxmanifest The Version in Identity element was different from the binary version deployed from my machine. We need to hurry and setup our build machine !! All good now, codepush is awesome.