Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add macOS desktop app using React Native #38

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"presets": ["react-native"],
"plugins": [
[
"module-resolver",
{
"alias": {
"react-native": "react-native-macos"
}
}
]
]
}
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

This project shows how the source code can be architectured to run on multiple devices. As of now, it is able to run as:

- iOS & Android Apps (based on [react-native](https://facebook.github.io/react-native))
- a Desktop App based on [NW](http://nwjs.io) or based on [Electron](http://electron.atom.io)
- iOS & Android Apps (based on [react-native](https://facebook.github.io/react-native))
- a Desktop App based on [NW](http://nwjs.io) or based on [Electron](http://electron.atom.io) or based on React Native
- a Website App in any browser (based on [react](https://facebook.github.io/react))

A demo for the Website App is available [here](http://benoitvallon.github.io/react-native-nw-react-calculator).
Expand All @@ -20,16 +20,22 @@ A demo for the Website App is available [here](http://benoitvallon.github.io/rea

![Desktop App](images/desktop-apps.png "Desktop App")

### Desktop App (React Native macOS)

![Desktop React Native App](images/desktop-rn-app.png "Desktop React Native macOS App")

### Website App

![Website App](images/website-app.png "Website App")

## Libraries/tools

This project uses libraries and tools like:

- es6 syntax and [babel](https://babeljs.io)
- [react](https://facebook.github.io/react) for the Website App and Desktop App,
- [react-native](https://facebook.github.io/react-native) for the iOS & Android Apps
- [react-native-macos](https://github.com/ptmt/react-native-macos) for the macOS App
- [NW](http://nwjs.io) to package the Desktop App
- [Electron](http://electron.atom.io) to package the Desktop App
- [flux](https://facebook.github.io/flux) to organize the data flow management
Expand All @@ -40,6 +46,7 @@ This project uses libraries and tools like:
## Basic philosophy

All the code is contained in the `src` directory, especially the 3 main entry files that are used for the builds:

- `index.ios.js` & `index.android.js` are the ones used to build the iOS & Android Apps
- `index.js` is the one used to build the Website App and Desktop App as the code is strictly the same.

Expand Down Expand Up @@ -68,7 +75,7 @@ Screen.js

And here is the main `Class` file which composes the files.

```js
```javascript
'use strict';

import Base from './ScreenBase';
Expand Down Expand Up @@ -123,7 +130,7 @@ Some builds from npm included bugs while `npm install`. So if you are using a np

#### Android

- Follow the official documentation guide here: http://facebook.github.io/react-native/docs/getting-started.html#android-setup (includes experimental Windows & Linux support)
- Follow the official documentation guide here: <http://facebook.github.io/react-native/docs/getting-started.html#android-setup> (includes experimental Windows & Linux support)

### Running the Mobile Apps

Expand All @@ -136,7 +143,7 @@ Some builds from npm included bugs while `npm install`. So if you are using a np

- Open an emulator. (Genymotion or run `android avd`)
- Run the `react-native run-android` in the root of this project.
- If trying to run on a device, read the following guide: http://facebook.github.io/react-native/docs/running-on-device-android.html#content
- If trying to run on a device, read the following guide: <http://facebook.github.io/react-native/docs/running-on-device-android.html#content>

Congratulations! You've just successfully run the project as an iOS or Android App.

Expand All @@ -149,7 +156,7 @@ There isn't any additional requirements since you already installed the deps wit
### Quick start

- `npm run build` to build the project (at least the first time)
- `npm run serve-web` to preview in the browser at http://localhost:8000/index.web.html or http://localhost:8000/webpack-dev-server/index.web.html with webpack-dev-server and hot reload enabled
- `npm run serve-web` to preview in the browser at <http://localhost:8000/index.web.html> or <http://localhost:8000/webpack-dev-server/index.web.html> with webpack-dev-server and hot reload enabled

Congratulations! You've just successfully run the project as a Website App.

Expand All @@ -163,7 +170,7 @@ To run the project, you are supposed to run something like:

`/path/to/nw .`

On OSX, the executable binary is in a hidden directory within the .app file. The easier solution to install it is to download the app on http://nwjs.io/ then copying it to your application folder. You will now be able to run:
On OSX, the executable binary is in a hidden directory within the .app file. The easier solution to install it is to download the app on <http://nwjs.io/> then copying it to your application folder. You will now be able to run:

`/Applications/nwjs.app/Contents/MacOS/nwjs .`

Expand Down
Binary file added images/desktop-rn-app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions macos/ReactNativeNWReactCalculator-tvOS/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSAppTransportSecurity</key>
<!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ -->
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>
24 changes: 24 additions & 0 deletions macos/ReactNativeNWReactCalculator-tvOSTests/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Loading