README.md in snapshot-0.9.0 vs README.md in snapshot-0.9.1
- old
+ new
@@ -11,11 +11,14 @@
<a href="https://github.com/KrauseFx/frameit">frameit</a> •
<a href="https://github.com/KrauseFx/PEM">PEM</a> •
<a href="https://github.com/KrauseFx/sigh">sigh</a> •
<a href="https://github.com/KrauseFx/produce">produce</a> •
<a href="https://github.com/KrauseFx/cert">cert</a> •
- <a href="https://github.com/KrauseFx/codes">codes</a>
+ <a href="https://github.com/KrauseFx/codes">codes</a> •
+ <a href="https://github.com/fastlane/spaceship">spaceship</a> •
+ <a href="https://github.com/fastlane/pilot">pilot</a> •
+ <a href="https://github.com/fastlane/boarding">boarding</a>
</p>
-------
<p align="center">
<img src="assets/snapshot.png">
@@ -35,11 +38,11 @@
**New Screenshots**
You want them to look **perfect** and **gorgeous**. They should show the same screens on all devices in all languages.
-You have to manually create 20 (languages) x 4 (devices) x 5 (screenshots) = **400 screenshots**.
+You have to manually create 20 (languages) x 5 (devices) x 5 (screenshots) = **500 screenshots**.
It's hard to get everything right!
- New screenshots with every (design) update
- No loading indicators
@@ -49,11 +52,26 @@
This gem solves all those problems. It will run completely in the background - you can do something else, while your computer takes the screenshots for you.
Get in contact with the developer on Twitter: [@KrauseFx](https://twitter.com/KrauseFx)
+### Note: Support for UI Tests with Xcode 7
+Apple announced a new version of Xcode with support for UI Tests built in right into Xcode. This technology allows `snapshot` to be even better: Instead of dealing with UI Automation Javascript code, you will be able to write the screenshot code in Swift or Objective C allowing you to use debugging features like breakpoints.
+
+It's still work in progress and there are some technical difficulties I need to solve.
+
+As a result, `snapshot` will be completely rewritten from ground up without changing its public API :rocket:
+
+**Why change to UI Tests?**
+
+- UI Automation is deprecated
+- UI Tests will evolve and support even more features in the future
+- UI Tests are much easier to debug
+- UI Tests are written in Swift or Objective C
+- UI Tests can be executed in a much cleaner and better way
+
-------
<p align="center">
<a href="#features">Features</a> •
<a href="#installation">Installation</a> •
<a href="#ui-automation">UI Automation</a> •
@@ -71,13 +89,14 @@
# Features
- Create hundreds of screenshots in multiple languages on all simulators
- Configure it once, store the configuration in git
- Do something else, while the computer takes the screenshots for you
-- Integrated with [`fastlane`](https://fastlane.tools) and [`deliver`](https://github.com/KrauseFx/deliver)
+- Integrates with [`fastlane`](https://fastlane.tools) and [`deliver`](https://github.com/KrauseFx/deliver)
- Generates a beautiful web page, which shows all screenshots on all devices. This is perfect to send to Q&A or the marketing team
- ```snapshot``` automatically waits for network requests to be finished before taking a screenshot (we don't want loading images in the App Store screenshots)
+- Support for advanced configuration, like preprocess macros or [prefilling of data](#prefilling)
##### [Like this tool? Be the first to know about updates and new fastlane tools](https://tinyletter.com/krausefx)
After ```snapshot``` successfully created new screenshots, it will generate a beautiful html file to get a quick overview of all screens:
@@ -88,22 +107,22 @@
### Why should I automate this process?
- It takes **hours** to take screenshots
- It is an integration test: You can test for UI elements and other things inside your scripts
- Be so nice, and provide new screenshots with every App Store update. Your customers deserve it
-- You realise, there is a spelling mistake in one of the screens? Well, just correct it and re-run the script.
+- You realise, there is a spelling mistake in one of the screens? Well, just correct it and re-run the script
- You get a great overview of all your screens, running on all available simulators without the need to manually start it hundreds of times
- Easy verification that localizations fit into labels on all screen dimensions
- Easy verification for translators (without an iDevice) that translations do make sense in real App context
###Why use ```snapshot``` instead of....
I've been using many other solutions out there. Unfortunately none of them were perfect. The biggest issue was random timeouts of ```Instruments``` when starting the script. This problem is solved with ```snapshot```
- **UI Automation in Instruments**: Instruments can only run your app on one device in one language. You have to manually switch it.
- **[ui-screen-shooter](https://github.com/jonathanpenn/ui-screen-shooter)**: This is the best alternative out there right now. It's based on AppleScript, you can not update it properly and there are quite some hacks in there. ```snapshot``` uses a very similar technique - just in a clean and maintainable Ruby gem.
-- **[Subliminal](https://github.com/inkling/Subliminal)**: A good approach to write the interaction code in Objective C. Unfortunately it has a lot of open issues with the latest release of Xcode. Also, it requires modifications of your Xcode project and schemes, which might break some other things.
+- **[Subliminal](https://github.com/inkling/Subliminal)**: A good approach to write the interaction code in Objective C. Unfortunately the project seems to be dead and doesn't work with the latest version of Xcode yet. Also, it requires modifications of your Xcode project and schemes, which might break some other things.
# Installation
Install the gem
@@ -121,10 +140,11 @@
Here a few links to get started:
- [Apple's official documentation](https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/UsingtheAutomationInstrument/UsingtheAutomationInstrument.html)
- [UI Automation: An Introduction (cocoamanifest.net)](http://cocoamanifest.net/articles/2011/05/uiautomation-an-introduction.html)
- [Functional Testing UI Automation (mattmccomb.com)](http://www.mattmccomb.com/blog/2013/06/02/ios-functional-testing-with-uiautomation/)
+- [Cheat and use NSNotifications with HSUIAutomationCheat (github.com)](https://github.com/ConfusedVorlon/HSUIAutomationCheat)
# Quick Start
- Run ```snapshot init``` in your project folder
- Profile your app in Xcode (CMD + I), choose ```Automation``` and click the Record button on the bottom of the window.
@@ -308,11 +328,11 @@
To run a shell script, just use ```system('./script.sh')```.
```ruby
setup_for_device_change do |device, udid, language|
puts "Running #{language} on #{device}"
- system("./popuplateDatabase.sh")
+ system("./populateDatabase.sh")
end
teardown_device do |language, device|
puts "Finished with #{language} on #{device}"
system("./cleanup.sh")
@@ -320,17 +340,10 @@
```
### Skip alpha removal from screenshots
In case you want to skip this process, just add ```skip_alpha_removal``` to your ```Snapfile```.
-### Pass Bundle Identifier
-This is only required in case there is a problem automatically detecting it.
-
-```
-SNAPSHOT_APP_IDENTIFIER="com.krausefx.app" snapshot
-```
-
### Clear old screenshots
If you add this line in your `Snapfile`, the previously generated screenshots will be deleted before generating new ones:
```ruby
@@ -351,25 +364,103 @@
# Tips
## [`fastlane`](https://fastlane.tools) Toolchain
- [`fastlane`](https://fastlane.tools): Connect all deployment tools into one streamlined workflow
-- [`deliver`](https://github.com/KrauseFx/deliver): Upload screenshots, metadata and your app to the App Store using a single command
+- [`deliver`](https://github.com/KrauseFx/deliver): Upload screenshots, metadata and your app to the App Store
- [`frameit`](https://github.com/KrauseFx/frameit): Quickly put your screenshots into the right device frames
- [`PEM`](https://github.com/KrauseFx/pem): Automatically generate and renew your push notification profiles
- [`sigh`](https://github.com/KrauseFx/sigh): Because you would rather spend your time building stuff than fighting provisioning
- [`produce`](https://github.com/KrauseFx/produce): Create new iOS apps on iTunes Connect and Dev Portal using the command line
- [`cert`](https://github.com/KrauseFx/cert): Automatically create and maintain iOS code signing certificates
- [`codes`](https://github.com/KrauseFx/codes): Create promo codes for iOS Apps using the command line
+- [`spaceship`](https://github.com/fastlane/spaceship): Ruby library to access the Apple Dev Center and iTunes Connect
+- [`pilot`](https://github.com/fastlane/pilot): The best way to manage your TestFlight testers and builds from your terminal
+- [`boarding`](https://github.com/fastlane/boarding): The easiest way to invite your TestFlight beta testers
##### [Like this tool? Be the first to know about updates and new fastlane tools](https://tinyletter.com/krausefx)
## Frame the screenshots
If you want to add frames around the screenshots and even put a title on top, check out [frameit](https://github.com/fastlane/frameit).
-## Run in Continuous Integration
+## Prefilling
+
+Usually you want to mock your screenshot data to show the same content for all screenshots.
+
+There are 2 ways of doing this:
+
+#### Preprocessor macro
+Use the preprocessor macro `SNAPSHOT` to check if `snapshot` is currently running in your code. This enables you to add checks like this:
+
+```objective-c
+#ifdef SNAPSHOT
+// Your Code here
+#endif
+```
+
+Open your `Snapfile` and add `custom_build_args "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) SNAPSHOT=1'"` to it.
+
+#### By pre-filling data/documents in the bundle
+
+As used by [MindNode](https://github.com/fastlane/examples/blob/master/MindNode/Snapfile) you can fill your bundle after building with demo data using your `Snapfile` to use it on run-time.
+
+```ruby
+example_files = './ExampleDocuments'
+folder_name = "ExampleDocuments"
+
+setup_for_device_change do |device, udid, language|
+ # This will make sure, all example documents are installed on the simulator
+
+ puts "Copying example files to .app"
+
+ app_path = "/tmp/snapshot/build/MindNode.app/"
+
+ FileUtils.mkdir_p(File.join(app_path, folder_name))
+
+ Dir.glob(File.join(example_files, '*.mindnode')).each do |example_path|
+ puts "Copying '#{example_path}' to .app container"
+ FileUtils.cp_r(example_path, File.join(app_path, folder_name)) rescue nil # in case the file already exists
+ end
+end
+```
+
+This is simple Ruby that gets executed **after** the app was built and **before** it is installed on the simulator.
+
+In your `Objective-C` code you can now load the documents from your bundle and copy them over to your `Documents` folder (if necessary).
+
+```objective-c
+#ifdef SNAPSHOT
+/** This method will take care of copying over the example documents from the app's bundle into the `Documents` directory */
++ (void)load
+{
+ static NSString *exampleFolderName = @"ExampleDocuments";
+ if ([[NSBundle mainBundle] pathForResource:exampleFolderName ofType:@""]) {
+ NSArray *filesToCopy = @[@"File1",
+ @"File2"];
+ NSString *documents = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
+
+ for (NSString *currentFile in filesToCopy) {
+ NSString *from = [[NSBundle mainBundle] pathForResource:currentFile ofType:@"filetype" inDirectory:exampleFolderName];
+ if (from && documents) {
+ NSError *error = nil;
+ NSString *resultingFileName = [NSString stringWithFormat:@"%@.filetype", currentFile];
+ [[NSFileManager defaultManager] copyItemAtPath:from
+ toPath:[documents stringByAppendingPathComponent:resultingFileName]
+ error:&error];
+
+ if (error) {
+ NSLog(@"Error copying the example MindNode file: %@", error);
+ }
+ }
+ }
+ }
+}
+
+```
+
+## Run in Continuous Integration System
If you want to run `snapshot` on your `Jenkins` machine (or any other CI-system), you might run into an `authorization` popup coming up.
You can disable this dialog, running the following command:
```
security authorizationdb read system.privilege.taskport > /tmp/system.privilege.taskport.plist
@@ -384,11 +475,11 @@
Be aware: The file will be executed from the current directory, not the location of the ```Snapfile```. That means: ```./screenshots``` will export the screenshots to the current directory of your terminal session.
## Available language codes
```ruby
-["da-DK", "de-DE", "el-GR", "en-AU", "en-CA", "en-GB", "en-US", "es-ES", "es-MX", "fi-FI", "fr-CA", "fr-FR", "id-ID", "it-IT", "ja-JP", "ko-KR", "ms-MY", "nl-NL", "no-NO", "pt-BR", "pt-PT", "ru-RU", "sv-SE", "th-TH", "tr-TR", "vi-VI", "cmn-Hans", "zh_CN", "cmn-Hant"]
+["cs-CZ", "da-DK", "de-DE", "el-GR", "en-AU", "en-CA", "en-GB", "en-US", "es-ES", "es-MX", "fi-FI", "fr-CA", "fr-FR", "id-ID", "it-IT", "ja-JP", "ko-KR", "ms-MY", "nl-NL", "no-NO", "pt-BR", "pt-PT", "ru-RU", "sv-SE", "th-TH", "tr-TR", "vi-VI", "cmn-Hans", "cmn-Hant"]
```
## Use a clean status bar
You can use [SimulatorStatusMagic](https://github.com/shinydevelopment/SimulatorStatusMagic) to clean up the status bar.
@@ -432,10 +523,14 @@
When the app dies directly after the application is launched there might be 2 problems
- The simulator is somehow in a broken state and you need to re-create it. You can use `snapshot reset_simulators` to reset all simulators (this will remove all installed apps)
- You haven't enabled the correct architectures. Make sure you have the same architectures as in the example project of this repository.
+### Snapshot throws an `Instruments Usage Error: Timed out waiting for device to boot: ...` error
+
+This can happen when you launch `fastlane` or `snapshot` inside of a tool like `tmux`. Thankfully, Chris Johnsen wrote a fix to help us out, which you can find [here](https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard). Just follow the instructions at his repository, and launching the Simulator from `tmux` will work!
+
## Determine language in UI Automation script
To detect the currently used localization in your Javascript file, use the following code:
```javascript
@@ -447,9 +542,11 @@
- If there is a technical problem with ```snapshot```, submit an issue.
- I'm available for contract work - drop me an email: snapshot@krausefx.com
# License
This project is licensed under the terms of the MIT license. See the LICENSE file.
+
+> This project and all fastlane tools are in no way affiliated with Apple Inc. This project is open source under the MIT license, which means you have full access to the source code and can modify it to fit your own needs. All fastlane tools run on your own computer or server, so your credentials or other sensitive information will never leave your own computer. You are responsible for how you use fastlane tools.
# Contributing
1. Create an issue to discuss about your idea
2. Fork it (https://github.com/KrauseFx/snapshot/fork)