diff --git a/README.md b/README.md index ee805f6a..f277e2b1 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Realm is a mobile database that runs directly inside phones, tablets or wearables. This repository holds the source code for Realm's JavaScript bindings for integrating with mobile apps built using ReactNative and Apache Cordova (PhoneGap). ## Setup -This repository uses submodules so you need to run `git submodule update --init --recursive` in the realm-js root directory before running any examples or including the project in your app. +This repository uses submodules so you need to run `git submodule update --init --recursive` in the realm-js root directory before running any examples. ## ReactNative Example Make sure your environment is set up to run react native applications. Follow the instructions here https://facebook.github.io/react-native/docs/getting-started.html. @@ -10,11 +10,13 @@ Make sure your environment is set up to run react native applications. Follow th The ReactNative example project is in the `examples/ReactExample` directory. You need to run `npm install` in this directory before running the example for the first time. ## ReactNative Project Setup -- Create a new ReactNative project `react-native init ` and open the generated XCode project. -- Drag `RealmJS.xcodeproj` into the `Libraries` folder in your project. -- Drag `RealmReact.framework` from the `Products` directory under `RealmJS.xcodeproj` into the `Embedded Binaries` section in the `General` tab for your app's target settings. Make sure the checkbox under `Code Sign On Copy` is **not checked** because having it checked will cause issues when trying to run your app on a device. -- In the `Build Phases` tab for your app's target settings, add `RealmReact.framework` to the `Link Binary with Library` build phases. -- In your app's `package.json` file, add the `realm` dependency with a path to the `realm-js/lib` folder like this: `"realm": "file:path/to/realm-js/lib"` (symlinks are not yet supported by the React Native packager, see [issue #637](https://github.com/facebook/react-native/issues/637)). +- Create a new ReactNative project: `react-native init ` +- Change directories into the new project (`cd `) and add the `realm` dependency: `npm install --save git+ssh://git@github.com/realm/realm-js.git#beta` (please note it's **essential** to leave the `#beta` at the end) +- Open the generated Xcode project (`ios/.xcodeproj`) +- Making sure the top-level project is selected in the sidebar, change the `iOS Deployment Target` to at least `8.0` in the project settings. +- Right-click the `Libraries` group in the sidebar and click `Add Files to “”`. Select `node_modules/realm/RealmJS.xcodeproj` from the dialog. +- Drag `RealmReact.framework` from the `Products` directory under `RealmJS.xcodeproj` into the `Embedded Binaries` section in the `General` tab for your app's target settings. +- In the `Build Phases` tab for your app's target settings, make sure `RealmReact.framework` is added to the `Link Binary with Library` build phase. - You can now `require('realm')` in your app's JS to use Realm! ## Getting Started diff --git a/RealmJS.xcodeproj/project.pbxproj b/RealmJS.xcodeproj/project.pbxproj index ab4e7a36..aee9ff71 100644 --- a/RealmJS.xcodeproj/project.pbxproj +++ b/RealmJS.xcodeproj/project.pbxproj @@ -880,11 +880,6 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)", - "$(BUILT_PRODUCTS_DIR)", - ); GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -894,6 +889,7 @@ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, "$(SRCROOT)/vendor", "$(SRCROOT)/vendor/GCDWebServer", + "$(SRCROOT)/../react-native/React/Base", "$(SRCROOT)/tests/react-test-app/node_modules/react-native/React/Base", "$(SRCROOT)/examples/ReactExample/node_modules/react-native/React/Base", ); @@ -918,16 +914,12 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)", - "$(BUILT_PRODUCTS_DIR)", - ); HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, "$(SRCROOT)/vendor", "$(SRCROOT)/vendor/GCDWebServer", + "$(SRCROOT)/../react-native/React/Base", "$(SRCROOT)/tests/react-test-app/node_modules/react-native/React/Base", "$(SRCROOT)/examples/ReactExample/node_modules/react-native/React/Base", ); @@ -951,16 +943,12 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)", - "$(BUILT_PRODUCTS_DIR)", - ); HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, "$(SRCROOT)/vendor", "$(SRCROOT)/vendor/GCDWebServer", + "$(SRCROOT)/../react-native/React/Base", "$(SRCROOT)/tests/react-test-app/node_modules/react-native/React/Base", "$(SRCROOT)/examples/ReactExample/node_modules/react-native/React/Base", ); diff --git a/examples/ReactExample/package.json b/examples/ReactExample/package.json index 3f1ec8be..311f4d11 100644 --- a/examples/ReactExample/package.json +++ b/examples/ReactExample/package.json @@ -7,6 +7,6 @@ }, "dependencies": { "react-native": "0.16.0", - "realm": "file:../../lib" + "realm": "file:../.." } } diff --git a/lib/package.json b/lib/package.json deleted file mode 100644 index ea644f03..00000000 --- a/lib/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "realm", - "version": "0.0.1", - "private": true -} diff --git a/package.json b/package.json new file mode 100644 index 00000000..0cbb581f --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "realm", + "version": "0.0.1", + "private": true, + "main": "lib/index.js", + "files": [ + "lib", + "react-native", + "scripts", + "src", + "vendor", + "RealmJS.xcodeproj" + ] +} diff --git a/scripts/publish-beta.sh b/scripts/publish-beta.sh new file mode 100755 index 00000000..8503b7c1 --- /dev/null +++ b/scripts/publish-beta.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -e +set -o pipefail + +cd "$(dirname "$0")/.." + +# Check if the worktree (or submodules) are dirty. +if ! git diff --ignore-submodules=none --no-ext-diff --quiet --exit-code HEAD; then + echo 'Publishing requires a clean work tree!' >&2 + exit 1 +fi + +GIT_AUTHOR_NAME=$(git config --get user.name) +GIT_AUTHOR_EMAIL=$(git config --get user.email) +GIT_ORIGIN_URL=$(git ls-remote --get-url origin) + +# Reset these variables just in case they were inherited from the environment. +TEMP_DIR= +PACKAGE= + +# Cleanup before this script exits. +trap 'rm -rf "$TEMP_DIR" "$PACKAGE"' EXIT + +TEMP_DIR=$(mktemp -d -t realm-js) +PACKAGE=$(npm pack | tail -n 1) + +tar -xf "$PACKAGE" -C "$TEMP_DIR" + +( + cd "$TEMP_DIR/package" + + export GIT_AUTHOR_NAME + export GIT_AUTHOR_EMAIL + export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME" + export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL" + + git init + git add . + git commit -m 'Beta build' + git remote add origin "$GIT_ORIGIN_URL" + git push -f origin master:beta +) diff --git a/tests/react-test-app/package.json b/tests/react-test-app/package.json index 1170ce85..c5545a0f 100644 --- a/tests/react-test-app/package.json +++ b/tests/react-test-app/package.json @@ -7,7 +7,7 @@ }, "dependencies": { "react-native": "0.16.0", - "realm": "file:../../lib", + "realm": "file:../..", "realm-tests": "file:../lib" } } diff --git a/vendor/.npmignore b/vendor/.npmignore new file mode 100644 index 00000000..77af1ff3 --- /dev/null +++ b/vendor/.npmignore @@ -0,0 +1,16 @@ +.travis.yml + +GCDWebServer/*.podspec +GCDWebServer/*.xcodeproj +GCDWebServer/*.sh +GCDWebServer/Frameworks +GCDWebServer/GCDWebDAVServer +GCDWebServer/GCDWebUploader +GCDWebServer/iOS +GCDWebServer/Mac +GCDWebServer/Tests +GCDWebServer/tvOS + +PEGTL/Makefile +PEGTL/examples +PEGTL/unit_tests