1iOS 2=== 3 4The following has been tested on MacOS Yosemite with Xcode version 6.3. 5 6Quickstart 7---------- 8 9First, install [XCode](https://developer.apple.com/xcode/). 10 11<!--?prettify lang=sh?--> 12 13 # Install depot tools. 14 git clone 'https://chromium.googlesource.com/chromium/tools/depot_tools.git' 15 export PATH="${PWD}/depot_tools:${PATH}" 16 17 # Get Skia. 18 git clone 'https://skia.googlesource.com/skia' 19 cd skia 20 21 # Create the project files. 22 GYP_DEFINES="skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0" python bin/sync-and-gyp 23 # Build and run SampleApp. 24 xed out/gyp/SampleApp.xcodeproj # opens the SampleApp project in Xcode 25 26Prerequisites 27------------- 28 29Make sure the following have been installed: 30 31 * XCode (Apple's development environment): required 32 * publicly available at http://developer.apple.com/xcode/ 33 * add the optional Unix Tools to the install so you get the make command line tool. 34 * Chromium depot_tools: required to download the source and dependencies 35 * http://www.chromium.org/developers/how-tos/depottools 36 * You will need an Apple developer account if you wish to run on an iOS device. 37 * A tool such as [ios-deploy](https://github.com/phonegap/ios-deploy) is also useful for pulling output from an iOS device. 38 39Check out the source code 40------------------------- 41 42See the instructions [here](../download). 43 44Generate XCode projects 45----------------------- 46 47We use the open-source gyp tool to generate XCode projects (and analogous 48build scripts on other platforms) from our multiplatform "gyp" files. 49 50Before building, make sure that gyp knows to create an XCode project or ninja 51build files. If you leave GYP_GENERATORS undefined it will assume the 52following default: 53 54 GYP_GENERATORS="ninja,xcode" 55 56Or you can set it to `xcode` alone, if you like. 57 58You can then generate the Xcode projects by running: 59 60 GYP_DEFINES="skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0" python bin/sync-and-gyp 61 62Alternatively, you can do: 63 64 export GYP_DEFINES="skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0" 65 python bin/sync-and-gyp 66 67Build and run tests 68------------------- 69 70The 'dm' test program is wrapped in an app called iOSShell. The project for iOSShell is at out/gyp/iOSShell.xcodeproj. 71Running this app with the flag '--dm' will run unit tests and golden master images. Other arguments to the standard 'dm' 72test program can also be passed in. 73 74To launch the iOS app on a device from the command line you can use a tool such as [ios-deploy](https://github.com/phonegap/ios-deploy): 75 76 xcodebuild -project out/gyp/iOSShell.xcodeproj -configuration Debug 77 ios-deploy --bundle xcodebuild/Debug-iphoneos/iOSShell.app -I -d --args "--dm <dm_args>" 78 79The usual mode you want for testing is Debug mode (SK_DEBUG is defined, and 80debug symbols are included in the binary). If you would like to build the 81Release version instead: 82 83 xcodebuild -project out/gyp/iOSShell.xcodeproj -configuration Release 84 ios-deploy --bundle xcodebuild/Release-iphoneos/iOSShell.app -I -d --args "--dm <dm_args>" 85 86Build and run nanobench (performance tests) 87------------------------------------------- 88 89The 'nanobench' test program is also wrapped in iOSShell.app. Passing in the flag '--nanobench' will run these tests. 90 91Here's an example of running nanobench from the command line. We will build with the "Release" configuration, since we are running performance tests. 92 93 xcodebuild --project out/gyp/iOSShell.xcodeproj -configuration Release 94 ios-deploy --bundle xcodebuild/Release-iphoneos/iOSShell.app -I -d --args "--nanobench <nanobench_args>" 95 96Build and run SampleApp in the XCode IDE 97---------------------------------------- 98 99 * Run `sync-and-gyp` as described above. 100 * In the Finder, navigate to $SKIA_INSTALLDIR/trunk/out/gyp 101 * Double-click SampleApp.xcodeproj ; this will launch XCode and open the SampleApp project 102 * Make sure the SampleApp target is selected, and choose an iOS device to run on 103 * Click the “Build and Run” button in the top toolbar 104 * Once the build is complete, launching the app will display a window with lots of shaded text examples. On the upper left there is a drop down 105menu that allows you to cycle through different test pages. On the upper right there is a dialog with a set of options, including different 106rendering methods for each test page. 107 108Provisioning 109------------ 110 111To run the Skia apps on an iOS device rather than using the simulator, you will need a developer account and a provisioning profile. See 112[Launching Your App on Devices](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/LaunchingYourApponDevices/LaunchingYourApponDevices.html) for more information. 113 114Managing App Data 115----------------- 116By default, the iOS apps will look for resource files in the Documents/resources folder of the app and write any output files to Documents/. To upload resources 117so that the app can read them you can use a tool such as [ios-deploy](https://github.com/phonegap/ios-deploy). For example: 118 119 ios-deploy --bundle_id 'com.google.SkiaSampleApp' --upload resources/baby_tux.png --to Documents/resources/baby_tux.png 120 121You can use the same tool to download log files and golden master (GM) images: 122 123 ios-deploy --bundle_id 'com.google.iOSShell' --download=/Documents --to ./my_download_location 124 125Alternatively, you can put resources and other files in the bundle of the application. In this case, you'll need to run the app with the option '--resourcePath .' 126