Skip to content

A cookiecutter template to easily start mobile, cross-platform C++ library projects (e.g., Android, iOS, ...)

License

Notifications You must be signed in to change notification settings

diegum/cookiecutter-cpp-mobile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cookiecutter C++ Mobile

A cookiecutter template to easily start mobile, cross-platform C++ library projects (e.g., Android, iOS, ...)

What's about

Imagine that you are working on a mobile app, game, etc., and you want to reuse the core logic from a cross-platform C++ library that can be later consumed from both Android and iOS. You just enter the following terminal command:

$ cookiecutter https://github.com/diegum/cookiecutter-cpp-mobile.git

Repo [my-cpp-lib]: amazing-app-core
Brief_description [What's this C++ library for?]: This repo contains the core logic of my amazing app
Library_name [mylib]: core
Year [2019]:
Copyright_holder [<YOUR NAME OR COMPANY HERE>]: John Doe

What you'll get is a pre-baked hello-world-like project with the following structure:

amazing-app-core
├── src           // Here goes your common library
│   ├── core.h
│   └── core.cc
├── samples
│   ├── android   // An Android app that uses it via JNI
│   ├── ios       // An iOS app that uses it via ObjC++
│   └── terminal  // A command line sample
├── tests         // A Catch2 canary test
|   ├── catch.hpp
|   └── core_tests.cc
└── docs          // A Javadoc-like directory tree
    ├── doxygen.cfg
    └── html
        ├── index.html
        └── ...

Thus, you got a simple, fully working reference sample to start from. You can build it from your favorite IDE or just from the command line.

Typical Usage

You'll get the Android sample built and running with

$ buck install --run android_sample

Likewise, the iOS sample port runs with

$ buck install --run ios_sample

You'll run Catch2 C++ unit tests with

$ buck run test

You'll generate the library documentation with

$ buck run doc

You'll check C++ coding styles with

$ buck run lint

Prerequisites

  1. To create new projects from this template, you'll need Cookiecutter.
    1. Create new projects from the command line with cookiecutter https://github.com/diegum/cookiecutter-cpp-mobile.git.
  2. To build, install and run on Android and on iOS, you'll need Buck.
  3. For Android, in particular, you'll need both the Android SDK for Java & Kotlin code, and the Android NDK for C++.
  4. For iOS, you'll need the Xcode command line tools package (which comes included with Xcode or could be installed separately). This implicitly means that a macOS is also a requirement to build for iOS. For iOS, Buck especially requires fbsimctl installed.
  5. This template already comes with Catch2 for unit testing; so you're good to write and run C++ unit tests.
  6. To generate the library documentation, you'll need Doxygen.
  7. To validate C++ coding standards, you'll need Cppcheck.

FAQ

  • Why Buck and not CMake? I used CMake for years and it's a very mature build system. In many ways ahead of Facebook's Buck. Notwithstanding, Buck features Android and iOS integration out-of-box. It's a goal to offer either build system at some point.

  • Why Catch2 and not Google Test? Catch2 is a lightweight, easy-to-use Test-Driven Development (TDD) or Behavior-Driven Development (BDD) framework that got a lot of momentum these recent years. Curiously, the Buck command buck test only takes gtest or boost as xUnit test frameworks. Not yet Catch2. However, Catch2 consists on a single .hpp file that comes included in the template. In comparison, GTest would have implied yet another requirement. You may still apply your own GTest cases if you want. Like with CMake, this project template will offer a GTest canary sample as an alternative to Catch2.

  • Are more samples expected? I'm working on an optional Unreal Engine sample that applies the cross-platform library as a UE4 project third-party module. Unreal Engine is already a cross-platform C++ game framework (so there wouldn't be a need to integrate C++ logic as a static library), but the main goal of this project template is to enable the creation of fully cross-platform libraries that aren't bound or siloed to any end-app code base in any way.

  • What about continuous integration? The idea is to incorporate integration to Jenkins, Travis CI and other continuous integration servers. Even Git hooks that would prevent a merge to the master branch if, namely, tests don't pass.

  • Can anybody contribute? A big yes! Fork this repo and get familiar with its organization. Work on your features and, when ready, submit a PR to merge it back. Don't forget to update this README :-)

About

A cookiecutter template to easily start mobile, cross-platform C++ library projects (e.g., Android, iOS, ...)

Resources

License

Stars

Watchers

Forks

Packages

No packages published