<commit_before>#### Getting Started

This document is written for OS X 10.8.4 or better. iOS testing requires OS X. Android testing works on OS X, Windows, and Linux.

Install `Xcode` 4.6.3 or better from the Mac app store and the command line build tools (Xcode -> Preferences -> Downloads).

Make sure to create this symlink after installing the Xcode developer tools. Otherwise, FFI will not install properly.
Reinstall Ruby if you didn't set this symlink and have FFI issues.

`sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2`

- Install Java 7 if there's no Java on the system.
  - [JDK 7](http://www.oracle.com/technetwork/java/javase/downloads/index.html)

- Install the latest stable patch release of Ruby 2.0.

`$ \curl -L https://get.rvm.io | bash -s stable --ruby=2.0.0`

- Make sure RVM is using the correct Ruby by default

```
$ rvm list
$ rvm --default use 2.0.0
```

- If you have an old ruby, you can installing Ruby 2.0 instead

```
$ rvm get stable
$ rvm install 2.0.0
```

- Check that it's installed properly by printing the ruby version.

`$ ruby --version`

- Update RubyGems and Bundler.

```ruby
gem update --system ;\
gem install --no-rdoc --no-ri bundler ;\
gem update ;\
gem cleanup
```

- Install appium_console gem.

```ruby
gem uninstall -aIx appium_lib ;\
gem uninstall -aIx appium_console ;\
gem install --no-rdoc --no-ri appium_console
```

- Install [brew](http://mxcl.github.io/homebrew/)

`ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"`

- Install [nodejs](http://nodejs.org/) using brew.

```
brew update ;\
brew upgrade node ;\
brew install node
```

- Node should be `v0.10.5` or better.
Don't use the big green install button on nodejs.org or all npm commands will require sudo.

`$ node --version`

`$ npm --version`

- Install grunt.

`npm install -g grunt grunt-cli`

```bash
$ grunt --version
grunt-cli v0.1.6
grunt v0.4.1
```

- Install [ant](http://ant.apache.org/) if it's not already installed.
- Install [maven](http://maven.apache.org/download.cgi) if it's not already installed.

```
$ ant -version
Apache Ant(TM) version 1.8.2 compiled on June 20 2012
$ mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 12:31:09-0500)
```

- Clone appium

`$ git clone git://github.com/appium/appium.git`

- Run reset.sh

`cd appium; ./reset.sh`

If you see config errors, try cleaning git. `git clean -dfx; git reset --hard`

You can also reset by platform. `./reset.sh --android`


- Authorize for iOS testing. Must run reset.sh as mentioned above before running the grunt task.

> sudo \`which grunt\` authorize

- Start appium.

`node server.js`


#### Bash Profile
- Add the Android SDK tools folder to your path so you can run `android`.
- Define the `ANDROID_HOME` env var pointing to SDK root. On OSX place it in `~/.bash_profile`
- You may have to add grunt as well `/usr/local/share/npm/bin/grunt`

```
# ~/.bash_profile
export ANDROID_HOME=$HOME/Downloads/android-sdk-macosx
export ANDROID_SDK=$ANDROID_HOME
PATH=$PATH:/Applications/apache-ant-1.8.4/bin
PATH=$PATH:/usr/local/share/npm/bin/
PATH=$PATH:$ANDROID_HOME/build-tools
PATH=$PATH:$ANDROID_HOME/platform-tools
PATH=$PATH:$ANDROID_HOME/tools
export JAVA_HOME="`/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home`"
export APP_PATH="/path/to/MyiOS.app"
export APK_PATH="/path/to/my.apk"
export APP_PACKAGE="com.example.Package"
export APP_ACTIVITY="StartActivity"
export APP_WAIT_ACTIVITY="SplashActivity"

export PATH
```

- Run `android` to open the SDK manager. 
- Install `Intel x86 Emulator Accelerator (HAXM)` under Extras
- Install API 18 `SDK Platform`, `Intel x86 Atom System Image`, `Google APIs`
If there are any problems viewing or downloading the packages, go to `Packages -> Reload` and try again.

- Create a new Android virtual device that uses the Intel image. Ensure `Use Host GPU` is checked. Set `VM Heap` to `64`. `32` is too small.

![](img/avd_settings.png)

`android avd`

- Check that `hax is working` If it's not, install hax [directly from Intel](http://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager)

```bash
$ emulator @t18
HAX is working and emulator runs in fast virt mode
```

- Launch the emulator with `emulator @t18`

- After launching the emulator, check that it's listed in adb devices. Run the following commands a few times until it's listed.

`adb kill-server; adb devices`

If you see `error: protocol fault (no status)` just keep running the command until the emulator is detected.

- With both the Android emulator running and the Appium server started, it's time to launch the appium console. Make sure the ENV vars are exported.

- Echo the values to make sure they're set correctly

`$ echo $APP_PATH $APP_PACKAGE $APP_ACTIVITY $APP_WAIT_ACTIVITY`

- Start appium console

`arc`

- See [running on OS X](https://github.com/appium/appium/blob/master/docs/running-on-osx.md)

#### Troubleshooting

- If install fails, keep trying to install a few times.

When using `Appium.app` make sure to set Appium -> Preferences... -> Check "Use External Appium Package" and set it to the path of Appium cloned from GitHub.

Fix permission errors. npm shouldn't require sudo.

```bash
brew uninstall node
brew install node
rm -rf ./node_modules # run from the appium folder
rm -rf /Users/`whoami`/.npm
rm -rf /usr/local/lib/node_modules/ 
./reset.sh --ios
./reset.sh --android
```

- [Helper bash methods](https://gist.github.com/bootstraponline/5580587)
<commit_msg>Use quotes<commit_after>#### Getting Started

This document is written for OS X 10.8.4 or better. iOS testing requires OS X. Android testing works on OS X, Windows, and Linux.

Install `Xcode` 4.6.3 or better from the Mac app store and the command line build tools (Xcode -> Preferences -> Downloads).

Make sure to create this symlink after installing the Xcode developer tools. Otherwise, FFI will not install properly.
Reinstall Ruby if you didn't set this symlink and have FFI issues.

`sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2`

- Install Java 7 if there's no Java on the system.
  - [JDK 7](http://www.oracle.com/technetwork/java/javase/downloads/index.html)

- Install the latest stable patch release of Ruby 2.0.

`$ \curl -L https://get.rvm.io | bash -s stable --ruby=2.0.0`

- Make sure RVM is using the correct Ruby by default

```
$ rvm list
$ rvm --default use 2.0.0
```

- If you have an old ruby, you can installing Ruby 2.0 instead

```
$ rvm get stable
$ rvm install 2.0.0
```

- Check that it's installed properly by printing the ruby version.

`$ ruby --version`

- Update RubyGems and Bundler.

```ruby
gem update --system ;\
gem install --no-rdoc --no-ri bundler ;\
gem update ;\
gem cleanup
```

- Install appium_console gem.

```ruby
gem uninstall -aIx appium_lib ;\
gem uninstall -aIx appium_console ;\
gem install --no-rdoc --no-ri appium_console
```

- Install [brew](http://mxcl.github.io/homebrew/)

`ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"`

- Install [nodejs](http://nodejs.org/) using brew.

```
brew update ;\
brew upgrade node ;\
brew install node
```

- Node should be `v0.10.5` or better.
Don't use the big green install button on nodejs.org or all npm commands will require sudo.

`$ node --version`

`$ npm --version`

- Install grunt.

`npm install -g grunt grunt-cli`

```bash
$ grunt --version
grunt-cli v0.1.6
grunt v0.4.1
```

- Install [ant](http://ant.apache.org/) if it's not already installed.
- Install [maven](http://maven.apache.org/download.cgi) if it's not already installed.

```
$ ant -version
Apache Ant(TM) version 1.8.2 compiled on June 20 2012
$ mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 12:31:09-0500)
```

- Clone appium

`$ git clone git://github.com/appium/appium.git`

- Run reset.sh

`cd appium; ./reset.sh`

If you see config errors, try cleaning git. `git clean -dfx; git reset --hard`

You can also reset by platform. `./reset.sh --android`


- Authorize for iOS testing. Must run reset.sh as mentioned above before running the grunt task.

> sudo \`which grunt\` authorize

- Start appium.

`node server.js`


#### Bash Profile
- Add the Android SDK tools folder to your path so you can run `android`.
- Define the `ANDROID_HOME` env var pointing to SDK root. On OSX place it in `~/.bash_profile`
- You may have to add grunt as well `/usr/local/share/npm/bin/grunt`

```
# ~/.bash_profile
export ANDROID_HOME=$HOME/Downloads/android-sdk-macosx
export ANDROID_SDK=$ANDROID_HOME
PATH=$PATH:/Applications/apache-ant-1.8.4/bin
PATH=$PATH:/usr/local/share/npm/bin/
PATH=$PATH:$ANDROID_HOME/build-tools
PATH=$PATH:$ANDROID_HOME/platform-tools
PATH=$PATH:$ANDROID_HOME/tools
export JAVA_HOME="`/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home`"
export APP_PATH="/path/to/MyiOS.app"
export APK_PATH="/path/to/my.apk"
export APP_PACKAGE="com.example.Package"
export APP_ACTIVITY="StartActivity"
export APP_WAIT_ACTIVITY="SplashActivity"

export PATH
```

- Run `android` to open the SDK manager. 
- Install `Intel x86 Emulator Accelerator (HAXM)` under Extras
- Install API 18 `SDK Platform`, `Intel x86 Atom System Image`, `Google APIs`
If there are any problems viewing or downloading the packages, go to `Packages -> Reload` and try again.

- Create a new Android virtual device that uses the Intel image. Ensure `Use Host GPU` is checked. Set `VM Heap` to `64`. `32` is too small.

![](img/avd_settings.png)

`android avd`

- Check that `hax is working` If it's not, install hax [directly from Intel](http://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager)

```bash
$ emulator @t18
HAX is working and emulator runs in fast virt mode
```

- Launch the emulator with `emulator @t18`

- After launching the emulator, check that it's listed in adb devices. Run the following commands a few times until it's listed.

`adb kill-server; adb devices`

If you see `error: protocol fault (no status)` just keep running the command until the emulator is detected.

- With both the Android emulator running and the Appium server started, it's time to launch the appium console. Make sure the ENV vars are exported.

- Echo the values to make sure they're set correctly

`$ echo $APP_PATH $APP_PACKAGE $APP_ACTIVITY $APP_WAIT_ACTIVITY`

- Start appium console

`arc`

- See [running on OS X](https://github.com/appium/appium/blob/master/docs/running-on-osx.md)

#### Troubleshooting

- If install fails, keep trying to install a few times.

When using `Appium.app` make sure to set Appium -> Preferences... -> Check "Use External Appium Package" and set it to the path of Appium cloned from GitHub.

Fix permission errors. npm shouldn't require sudo.

```bash
brew uninstall node
brew install node
rm -rf ./node_modules # run from the appium folder
rm -rf "/Users/`whoami`/.npm"
rm -rf /usr/local/lib/node_modules/ 
./reset.sh --ios
./reset.sh --android
```

- [Helper bash methods](https://gist.github.com/bootstraponline/5580587)

{'fraction_non_alphanumeric': 0.12117893968427776, 'fraction_numerical': 0.017337348298202392, 'mean_word_length': 3.748700173310225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1898096', 'n_tokens_mistral': 3921, 'n_tokens_neox': 3608, 'n_words': 1335}