Skip to content

Commit

Permalink
Merge pull request #28 from tangrams/ios-build
Browse files Browse the repository at this point in the history
iOS build
  • Loading branch information
matteblair committed Dec 4, 2014
2 parents 4f0d62b + f487850 commit a6dfc84
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ ifndef ANDROID_API_LEVEL
ANDROID_API_LEVEL = android-19
endif

ifndef IOS_PLATFORM
IOS_PLATFORM = SIMULATOR
endif

UNIT_TESTS_CMAKE_PARAMS = \
-DUNIT_TESTS=1

Expand All @@ -46,7 +50,7 @@ ANDROID_CMAKE_PARAMS = \

IOS_CMAKE_PARAMS = \
-DPLATFORM_TARGET=ios \
-DIOS_PLATFORM=SIMULATOR \
-DIOS_PLATFORM=${IOS_PLATFORM} \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_DIR}/iOS.toolchain.cmake \
-G Xcode

Expand Down
37 changes: 33 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,43 @@ Then build using GNU Make:
make osx
```

### iOS ###
For iOS, an XCode project would be generated and target would be built by running the following:
### iOS Simulator ###
For running on the iOS simulator, generate and compile an XCode project:

```bash
make ios && open build/ios/tangram.xcodeproject
make ios
```

Then just use Xcode as usual. Note that any Xcode configuration change you make to the project won't be preserved when Cmake runs again. Build configuration is defined only in the CMakeLists file(s).
Then just open the Xcode project and run/debug from there:

```bash
open build/ios/tangram.xcodeproject
```

Note that any Xcode configuration change you make to the project won't be preserved when Cmake runs again. Build configuration is defined only in the CMakeLists file(s).

### iOS Devices ###
For running on iOS devices you will need an iOS developer account, a valid code signing certificate, and a valid provisioning profile. Help on these topics can be found at [Apple's developer website](http://developer.apple.com).

First generate an XCode project without compiling:

```bash
make cmake-ios IOS_PLATFORM=OS
```

Then open the Xcode project:

```bash
open build/ios/tangram.xcodeproject
```

In the project settings for the target named 'tangram', set 'Team' to your developer account. Now you can build and run the demo on a connected device.

When you run on a device for the first time you may encounter an error with a message similar to:

`The file ... couldn’t be opened because you don’t have permission to view it.`

To fix this, go to the Issues navigator tab in Xcode and click 'Validate Project Settings' under 'tangram.xcodeproj', then allow Xcode to perform any needed changes.

### Android ###
To build for Android, ensure you have your `$ANDROID_NDK` environment variable set and pointing to your [NDK](https://developer.android.com/tools/sdk/ndk/index.html) toolset.
Expand Down
9 changes: 5 additions & 4 deletions build/toolchains/iOS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}
if(${IOS_PLATFORM} STREQUAL "SIMULATOR")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mios-simulator-version-min=6.0")
set(ARCH "i386")

# include headers for ios
include_directories(${PROJECT_SOURCE_DIR}/ios/include/)
else()
# todo : actual build on devices
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(ARCH "armv6 armv7")
endif()

# include headers for ios
include_directories(${PROJECT_SOURCE_DIR}/ios/include/)

set(FRAMEWORKS CoreGraphics CoreFoundation QuartzCore UIKit OpenGLES Security CFNetwork GLKit)
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.mapzen.\${PRODUCT_NAME:Tangram}")
set(APP_TYPE MACOSX_BUNDLE)
Expand Down

0 comments on commit a6dfc84

Please sign in to comment.