OLD | NEW |
---|---|
1 iOS | 1 iOS |
2 === | 2 === |
3 | 3 |
4 Quickstart | |
5 ---------- | |
6 | |
7 1. Install [XCode](http://developer.apple.com/xcode/). | |
stephana
2015/10/15 15:28:08
I think it would be helpful if you added a note wi
jvanverth1
2015/10/15 16:36:44
Done.
| |
8 | |
9 2. Install depot tools. | |
10 | |
11 <!--?prettify lang=sh?--> | |
12 | |
13 git clone 'https://chromium.googlesource.com/chromium/tools/depot_tools. git' | |
14 export PATH="${PWD}/depot_tools:${PATH}" | |
15 | |
16 3. Get Skia. | |
17 | |
18 <!--?prettify lang=sh?--> | |
19 | |
20 git clone 'https://skia.googlesource.com/skia' | |
21 cd skia | |
22 | |
23 4. Create the project files. | |
24 | |
25 <!--?prettify lang=sh?--> | |
26 | |
27 GYP_DEFINES="skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0" ./gy p_skia | |
28 | |
29 5. Build and run SampleApp. | |
30 | |
31 <!--?prettify lang=sh?--> | |
32 | |
33 xed out/gyp/SampleApp.xcodeproj # opens the SampleApp project in Xcode | |
34 | |
4 Prerequisites | 35 Prerequisites |
5 ------------- | 36 ------------- |
6 | 37 |
7 _These steps should closely follow building on Mac OS X. Those steps seem slight ly out of date._ | 38 Make sure the following have been installed: |
39 | |
40 * XCode (Apple's development environment): required | |
41 * publicly available at http://developer.apple.com/xcode/ | |
42 * add the optional Unix Tools to the install so you get the make command lin e tool. | |
43 * Chromium depot_tools: required to download the source and dependencies | |
44 * http://www.chromium.org/developers/how-tos/depottools | |
45 * You will need an Apple developer account if you wish to run on an iOS device . | |
46 * A tool such as [ios-deploy](https://github.com/phonegap/ios-deploy) is also useful for pulling output from an iOS device. | |
47 | |
48 Check out the source code | |
49 ------------------------- | |
50 | |
51 See the instructions [here](../download). | |
52 | |
53 Generate XCode projects | |
54 ----------------------- | |
55 | |
56 We use the open-source gyp tool to generate XCode projects (and analogous | |
57 build scripts on other platforms) from our multiplatform "gyp" files. | |
58 | |
59 Before building, make sure that gyp knows to create an XCode project or ninja | |
60 build files. If you leave GYP_GENERATORS undefined it will assume the | |
61 following default: | |
62 | |
63 GYP_GENERATORS="ninja,xcode" | |
64 | |
65 Or you can set it to `xcode` alone, if you like. | |
66 | |
67 You can then generate the Xcode projects by running: | |
68 | |
69 GYP_DEFINES="skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0" ./gyp_sk ia | |
70 | |
71 Alternatively, you can do: | |
72 | |
73 export GYP_DEFINES="skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0" | |
74 ./gyp_skia | |
75 | |
76 Build and run tests | |
77 ------------------- | |
78 | |
79 The 'dm' test program is wrapped in an app called iOSShell. The project for iOSS hell is at out/gyp/iOSShell.xcodeproj. | |
80 Running this app with the flag '--dm' will run unit tests and golden master imag es. Other arguments to the standard 'dm' | |
81 test program can also be passed in. | |
82 | |
83 To 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): | |
84 | |
85 xcodebuild -project out/gyp/iOSShell.xcodeproj -configuration Debug | |
86 ios-deploy --bundle xcodebuild/Debug-iphoneos/iOSShell.app -I -d --args "--d m <dm_args>" | |
87 | |
88 The usual mode you want for testing is Debug mode (SK_DEBUG is defined, and | |
89 debug symbols are included in the binary). If you would like to build the | |
90 Release version instead: | |
91 | |
92 xcodebuild -project out/gyp/iOSShell.xcodeproj -configuration Release | |
93 ios-deploy --bundle xcodebuild/Release-iphoneos/iOSShell.app -I -d --args "- -dm <dm_args>" | |
94 | |
95 Build and run nanobench (performance tests) | |
96 ------------------------------------------- | |
97 | |
98 The 'nanobench' test program is also wrapped in iOSShell.app. Passing in the fla g '--nanobench' will run these tests. | |
99 | |
100 Here's an example of running nanobench from the command line. We will build with the "Release" configuration, since we are running performance tests. | |
101 | |
102 xcodebuild --project out/gyp/iOSShell.xcodeproj -configuration Release | |
103 ios-deploy --bundle xcodebuild/Release-iphoneos/iOSShell.app -I -d --args "- -nanobench <nanobench_args>" | |
8 | 104 |
9 Build and run SampleApp in the XCode IDE | 105 Build and run SampleApp in the XCode IDE |
10 ---------------------------------------- | 106 ---------------------------------------- |
11 | 107 |
12 ### XCode 4.5 | 108 * Run gyp_skia as described above. |
109 * In the Finder, navigate to $SKIA_INSTALLDIR/trunk/out/gyp | |
110 * Double-click SampleApp.xcodeproj ; this will launch XCode and open the Sampl eApp project | |
111 * Make sure the SampleApp target is selected, and choose an iOS device to run on | |
112 * Click the “Build and Run” button in the top toolbar | |
113 * Once the build is complete, launching the app will display a window with lot s of shaded text examples. On the upper left there is a drop down | |
114 menu that allows you to cycle through different test pages. On the upper right t here is a dialog with a set of options, including different | |
115 rendering methods for each test page. | |
13 | 116 |
117 Provisioning | |
118 ------------ | |
14 | 119 |
15 To build SampleApp on XCode 4.5 using the IDE these steps should work: | 120 To run the Skia apps on an iOS device rather than using the simulator, you will need a developer account and a provisioning profile. See |
121 [Launching Your App on Devices](https://developer.apple.com/library/ios/document ation/IDEs/Conceptual/AppDistributionGuide/LaunchingYourApponDevices/LaunchingYo urApponDevices.html) for more information. | |
16 | 122 |
17 GYP_DEFINES="skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0" ./gyp_sk ia | 123 Managing App Data |
18 xed out/gyp/SampleApp.xcodeproj # opens the SampleApp project in the IDE | 124 ----------------- |
125 By 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 | |
126 so that the app can read them you can use a tool such as [ios-deploy](https://gi thub.com/phonegap/ios-deploy). For example: | |
19 | 127 |
20 Note that if you run make at the command line the gyp\_skia script will rerun | 128 ios-deploy --bundle_id 'com.google.SkiaSampleApp' --upload resources/baby_tu x.png --to Documents/resources/baby_tux.png |
21 and you'll lose the effect of the GYP\_DEFINES. To avoid this do: | |
22 | 129 |
23 export GYP_DEFINES="skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0" | 130 You can use the same tool to download log files and golden master (GM) images: |
24 | 131 |
25 ### XCode 3 | 132 ios-deploy --bundle_id 'com.google.iOSShell' --download=/Documents --to ./my _download_location |
26 | 133 |
27 Use GYP\_DEFINES to tell gyp\_skia how to build for iOS. Here's a bash shell | 134 Alternatively, you can put resources and other files in the bundle of the applic ation. In this case, you'll need to run the app with the option '--resourcePath .' |
28 snippet that sets the world up to build SampleApp with XCode 3: | |
29 | |
30 function buildSampleApp() | |
31 { | |
32 sdkVersion="4.3" | |
33 if [[ "$1" == "sim" ]] ; then | |
34 export GYP_DEFINES="skia_os='ios' skia_arch_type='x86' \ | |
35 ios_sdk_dir='/Developer/Platforms/iPhoneSimulator.platform/Developer/S DKs/iPhoneSimulator' \ | |
36 ios_sdk_version='$sdkVersion'" | |
37 elif [[ "$1" == "iphone" ]] ; then | |
38 export GYP_DEFINES="skia_os='ios' skia_arch_type='arm' armv7='1' arm_neo n='0' \ | |
39 ios_sdk_dir='/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPh oneOS' \ | |
40 ios_sdk_version='$sdkVersion'" | |
41 elif [[ "$1" == "mac" ]] ; then | |
42 export GYP_DEFINES="" | |
43 else | |
44 echo "buildSampleApp expects 'sim', 'iphone', or 'mac'" | |
45 fi | |
46 if [[ "$1" == "sim" ]] || [[ "$1" == "iphone" ]] || [[ "$1" == "mac" ]] ; then | |
47 save=`pwd` | |
48 cd /chrome/nih/skia/trunk | |
49 echo "$GYP_DEFINES ./gyp_skia gyp/SampleApp.gyp" | |
50 ./gyp_skia gyp/SampleApp.gyp | |
51 cd $save | |
52 fi | |
53 if [[ "$1" == "sim" ]] ; then | |
54 setiossdk iphonesimulator$sdkVersion | |
55 elif [[ "$1" == "iphone" ]] ; then | |
56 setiossdk iphoneos$sdkVersion | |
57 fi | |
58 } | |
59 | |
60 The script function setiossdk called by buildSampleApp is a | |
61 not-completely-working hackery. When gyp builds an iOS-targeted project, it is | |
62 hard-coded for the iOS simulator. To point the project at either the iOS | |
63 simulator, or an iOS device, the project file must be opened to create a | |
64 custom pbxuser file. | |
65 | |
66 This is accomplished by: | |
67 | |
68 function setiossdk() | |
69 { | |
70 osascript -e 'tell app "Xcode" to quit' | |
71 osascript -e 'repeat until appIsRunning("Xcode") is false' -e \ | |
72 'do shell script "sleep 1"' -e 'end repeat' | |
73 save=`pwd` | |
74 skia | |
75 cd out/gyp | |
76 for project in *.xcodeproj; do | |
77 open $project | |
78 done | |
79 osascript -e 'tell app "Xcode" to quit' | |
80 osascript -e 'repeat until appIsRunning("Xcode") is false' -e \ | |
81 'do shell script "sleep 1"' -e 'end repeat' | |
82 for project in *.xcodeproj; do | |
83 lsave=`pwd` | |
84 cd $project | |
85 filename=`eval whoami`.pbxuser | |
86 while [[ ! -s $filename ]] ; do | |
87 sleep 1 | |
88 echo -n "." | |
89 done | |
90 sed -e '/activeSDKPreference/ d' <$filename | sed -e '/activeTarget/ i\ | |
91 \ activeSDKPreference = '$1';' >x$filename | |
92 if [[ -s x$filename ]] ; then | |
93 mv x$filename $filename | |
94 else | |
95 echo "mv x$filename $project/$filename failed" | |
96 fi | |
97 cd $lsave | |
98 done | |
99 open SampleApp.xcodeproj | |
100 cd $save | |
101 } | |
102 | |
103 In particular, the calls to osascript to wait for Xcode to quit use faulty synta x. | |
104 | |
OLD | NEW |