Showing posts with label ios. Show all posts
Showing posts with label ios. Show all posts

Tuesday, February 4, 2014

Configuring OSX Mavericks and Jenkins to Support Interactive Jobs

While developing iOS applications we leverage Jenkins on OSX Mavericks for our Xcode / iOS and Android builds. We perform application level automated testing (i.e. in the Simulator or Emulator) and as such need a Windowed environment can't simply run in a Daemon mode. In addition, OSX Server on Mavericks integrates a "GUI" Apache Server that we want to integrate.

An initial installation of Jenkins on a Mac using the Jenkins supplied installer is ok, but it only supports a headless execution. There are many times that our jobs need a head or window manager to execute (Xcode Automation Tests). To support this on Mac we need to reorganize this. Basically, we want to change the jenkins process from running as a LaunchDaemon and to run as LaunchAgent defined the jenkins user itself. Here is a cookbook for doing this with a fresh Mac install.
  1. If you don't have Java installed, install it by attempting to run the following and follow the instructions. java -version (I’d recommend to install the Java 7 version directly from Oracle).
  2. Download & Install the Jenkins Mac Installer.
  3. This will create a user named jenkins. In the user manager it will have an empty name, go ahead and name it Jenkins User in System Preferences -> User & Groups. You will also want to set a password at this time. It's not necessary, nor recommend to make this user an Administrator
  4. Now, we need to disable the Jenkins LaunchDaemon. You can unload and force it not to load again by executing "sudo launchctl unload -w /Library/LaunchDaemons/org.jenkins-ci.plist"
  5. We now need to create a LaunchAgents script, and this can be done by copying "cp /Library/LaunchDaemons/org.jenkins-ci.plist to ~/Library/LaunchAgents/org.jenkins-ci.plist"
  6. For Jenkins to start on a fresh system boot, you would configure System Preferences -> User & Groups -> Login Options to automatically login to the Jenkins User account.
  7. We should now be good to go and can start jenkins by logging in to the jenkins account (and out if already logged in).
One thing to keep in mind, is by default Jenkins can not update itself. To fix this you can do the following.
  1. Change the owner on the jenkins.war and directory. "sudo chown /Applications/Jenkins jenkins; sudo chown /Applications/Jenkins/jenkins.war jenkins"
Next we would also like Jenkins to play nicely with OSX Server (You might need to install it if it's not already installed from the App Store). Ideally, we want http://{SERVER_NAME}/jenkins to forward proxy to http://localhost:8080/jenkins.
  1. If Websites aren’t enabled, go ahead and turn that on in OSX Server. Make sure to “Allow overrides using .htaccess files” is enabled in the Advanced settings of the "Server Website" and "Server Website (SSL)” sites
  2. We need to configure Jenkins to respond to /jenkins as well, and this can be done by adding a prefix to the preferences. "sudo defaults write /Library/Preferences/org.jenkins-ci.plist prefix /jenkins"
  3. We need to configure OSX Server to redirect any non-SSL traffic to https for /jenkins. We did this in the OSX Server App by click on Websites -> Server Website -> Redirects -> Edit and adding a Permanent redirect for anything /jenkins to go to https://{SERVER_NAME}/jenkins.
  4. We need to configure OSX Server to forward proxy any /jenkins requests to the local jenkins server. Do this by adding an .htaccess file to /Library/Server/Web/Data/Sites/Default/jenkins/.htaccess with the following content.
RewriteEngine on
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ http://localhost:8080%{REQUEST_URI} [P]

After that we should now be able to access jenkins from http://{SERVER_NAME}/jenkins and it should redirect the user to https://{SERVER_NAME}/jenkins and allow you to login and continue the Jenkins configuration and create jobs that start windows (i.e. iOS Simulator and the Android Emulator).

Monday, September 2, 2013

Slicy Photoshop Export Better Than Cake

For iOS and Android projects we're constantly having to export Photoshop designs to the individual assets. It gets very tedious to use the Slice Tool in Photoshop to manually draw boxes around all the assets you want exported and to hide/show groups to get the right transparency and backgrounds.
Well, if you're still doing it this way I have a recommendation! Slicy which is just plain awesome. It's the best $29 I've ever spent.

Take a look at the "How it works" video on that page, but in a nutshell you name your Groups or Assets in a Photoshop file as Foo@2x.png and Slicy will perfectly slice these from the layers and export both the 2x and 1x image sizes. You still have to make sure that the designs use even pixels, but otherwise it works great. That's it. Done. It can even export automatically every time a change is made to the Photoshop file.

We even use it on Android even though it's originally built for iOS. We will use Foo.png instead of the iOS naming of @2x.png (with the designs made for xxhdpi with a resolution of 1080x1920). We then take the directory we had Slicy to export to and use a our android shell script (droidsize.py) to export these to all the other dpi's.

Tuesday, February 21, 2012

iOS Custom UISwitch

On an iOS project we had the need to provide a custom UISwitch similar to the following.



With iOSS 5 there is quite a bit of support for interface customization. It's great for customizing almost every control in iOS, except... UISwitch. The only thing customizable with UISwitch is the tint color, which is pretty limited. So, iOS 5 is out for supporting this customization.

Next, we looked at several existing open source projects. There are several out there that support a customized look and feel, but none of these had the "feel" of the built in UISwitch control from Apple. Some would allow dragging, and some just clicking, but none allowed both a click and drag interaction.

There was a strong desire for the switch to behave just like the standard UISwitch that supports both a click and drag interaction. That led us to create our own. We were able to support the look and feel and mimic the behavior of UISwitch by implementing a custom drawRect as well as a custom touch handling. Check the Open Source implementation.

LolayUISwitch.h
LolayUISwitch.m

Next, we hope to extend this to support setting the "on" value with animation, and additionally adding in support for all the autoscale settings of iOS on a UIControl. Also, thoughts of supporting a UIView rather than just a UIImage.

Thursday, July 21, 2011

OSX Lion and Xcode 4.1

We've upgraded to OSX Lion and Xcode 4.1 and it has been an interesting process. Here's the steps we took.
  1. The first was to make sure we were upgraded to 10.6.8 before we started anything.
  2. Purchase and download OSX Lion from the App Store (Note, you before starting the installation you may want to create a bootable drive)
  3. Install OSX Lion
  4. Java is not installed by default, so after Lion is installed you can install Java by going to a Terminal and typing "java -version" and it'll start a download to install Java.
  5. Before installing Xcode 4.1 it's good to remove any previous versions of Xcode
    1. Uninstall any previous Xcode by issuing a "sudo /Developer/Library/uninstall-devtools"
    2. In ~/Library issue a "find . -name *Xcode*" and remove each file/directory
    3. In ~/Library issue a "find . -name *Simulator*" and remove each file/directory
    4. Reboot
  6. Next find Xcode 4.1 on the App Store and download and install it. This just installs the installer. You then have to install it. The installer can be removed when you're finished.
  7. If Xcode launches with errors or has no menu times you'll need to reinstall iTunes. The download has the 64-bit universal builds now.
The only issue we've seen is that Core Location isn't working in the simulator and generates an error. See our post on the developer forums.

Saturday, April 9, 2011

How to Upgrade Test in the iOS Simulator

For the purpose of upgrade testing in automation it's useful to have a build of the previous version of the application. Of course, for actual device installs this is easy with the use of adhoc builds and .ipa files, but for the Simulator this is a little more involved. It is feasible if you follow the following steps.
  1. Launch the Simulator (/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app) and set the hardware and version to the appropriate settings.
  2. Delete any existing apps in the simulator.
  3. Put a breakpoint in the main function (i.e. first line of the main function main.m). This is to ensure that no code writes any files to the build directory (i.e. CoreData, Analytics, Preloading URL's, etc.).
  4. Run the project in debug and stop the program once it reaches the breakpoint in the main function.
  5. At this point if you followed step (2) and only have one application it should be easy to locate in ~/Library/Application Support/iPhone Simulator/[version]/Applications and can easily be tar'ed up and archived and moved around.
Now in an automated testing script you can remove any applications from the simulator, untar the appropriate archive, exercise preloading (i.e. logging in) to get the simulator in a state to test an upgrade. Now, simply build the project and have it install over this version and test any upgrade scenarios.

This has even worked from Xcode 3.2.6 builds being applied to Xcode 4.0.1.

Tuesday, April 5, 2011

iPhone Open Source Automation

Testing iPhone apps is always thought of last and is typically performed manually. At Lolay we believe in a strong automation investment to allow testing as we develop so that we can have confidence in the stability of our builds as we develop.

Checkout a demonstration of how to automate the iOS platform / iPhone using all open source. This is all compatible with ANT and Maven in any continuous environment. In this demo you will be shown on open source can perform a basic test in Where U At? and run through both positive and negative testing. At the end you can see the JUnit results including screen shots of the failure.

Vimeo: How to automate the iPhone using open source