Play2 is a template for creating iOS and Android apps sharing a common non-UI core.
Base your new iOS and Android apps off Play2 infrastructure to maximize code reuse and save development time.
You get the maximum benefit if you develop app on both platforms at the same time. About 50% of app's functionality (conceptually) can be reused, but your milage may vary.
The project is based on several open source technologies that work together to create a tremendous value.
Play2 is a rouge fork of mx3 by Steven Kabbes. The folder and makefile structure is mostly unchanged, but dependencies and code of the actual starter apps have diverged significantly.
The bundled starter iOS and Android apps are type of "pull to refresh" that display results in UITableView and ListView. The functionality where code is shared across platforms:
- Making HTTPS request and downloading JSON response
- Unpacking JSON response and saving it into sqlite3 database
- Pulling data from local sqlite3 database in form of a local API
- Some business logic, mostly around data
Since the focus of this project is sharing of non-UI code across platforms the opportunities for useful unit tests are abound. The project includes some fairly useful starter unit tests as well as Xcode and Jenkins friendly options to invoke them.
git clone https://github.com/yevgenyk/Play2.git
sh subs.shto set up and pull submodules
sudo gem install xcprettyto beautify the output of
===> If you get compile errors this may be because the version of Djinni is not stable. You can pin to an older commit. Only do this if you canot compile.
cd deps/djinni git checkout 137c2ea8fd12635ca29e98af6bffd3018e822451 cd ../..
This builds and runs a series of gtest unit tests that are ran inside mac shell. The last test downloads some JSON data from a remote site, updates a local database and pulls back the results. This means every time you run it the final
Updated countvalue will be different.
If you have gotten this far you should proceed to the actual starter apps!
make iosto generate objective-c proxies used by the actual app.
- The actual app is located in
- The iOS app in app-ios should run, pick the target called 'app' It should just load and run. Pull to refresh to see numbers change! Updated numbers will show up in blue!
- Make sure you have Android NDK installed on your mac. Make sure its folder is in PATH.
Something like this:
export PATH=$PATH:/Users/yevgeny/android-ndk-r10d export ANDROID_NDK=/Users/yevgeny/android-ndk-r10d
ndk-buildand you should see this error
Android NDK: Could not find application project directory !. This is what you want. Run
make androidto build the example android application
make androidNdkto build JNI libraries. This will produce the shared shared libraries needed by the Android app.
make androidJavato build Android app using gradle. The app is located in
app-androidfolder. You can open this project in Android Studio by choosing
app-android/appfolder and importing it as gradle project.
make clean- cleans all generated files
make tests- runs the unit tests
make ios- builds a static library for ios
make mac- builds a static library for mac
make androidNdk- builds JNI shared library for the Android app
make androidJava- builds the Android app using the
Where things are
- Play2.gyp - gyp definition file which spcifies targets and dependencies
- Application.mk - the android make file, you should modify this file to specify things like APP_ABI which is curently set only to x86 to speed up compilation
- Makefile - helper for interacting with gyp, and using command line builds (no xcode!!)
- deps/ - third party dependencies
- objc/ - objective-c code for iOS/OSX implementation, and also generated objective-c files
- src/ - shared implementation code
- test/ - gtest tests