<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    
    <title>dejalatele's personal blog</title>
    <link>http://dejalatele.com/</link>
    <description>My little place on the web...</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.5 - http://www.s9y.org/</generator>
    
    <image>
        <url>http://dejalatele.com/templates/bulletproof_fork/img/s9y_banner_small.png</url>
        <title>RSS: dejalatele's personal blog - My little place on the web...</title>
        <link>http://dejalatele.com/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Reset the iPhone simulator from the command line</title>
    <link>http://dejalatele.com/archives/6-Reset-the-iPhone-simulator-from-the-command-line.html</link>
            <category>Automation</category>
            <category>iOS</category>
    
    <comments>http://dejalatele.com/archives/6-Reset-the-iPhone-simulator-from-the-command-line.html#comments</comments>
    <wfw:comment>http://dejalatele.com/wfwcomment.php?cid=6</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://dejalatele.com/rss.php?version=2.0&amp;type=comments&amp;cid=6</wfw:commentRss>
    

    <author>nospam@example.com (Antonio Diaz Ruiz)</author>
    <content:encoded>
    When we are running automatic tests in the iPhone simulator is desirable to reset the simulator settings between each test execution for avoid that the results or final settings of one test could interfere on the execution of the next test.  We can automate that process by running the following &lt;a href=&quot;https://developer.apple.com/library/mac/#documentation/AppleScript/Conceptual/AppleScriptX/AppleScriptX.html&quot;&gt;AppleScript&lt;/a&gt; code&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
osascript &amp;lt;&amp;lt;SCRIPT&lt;br /&gt;
application &quot;iPhone Simulator&quot; activate&lt;br /&gt;
&lt;br /&gt;
tell application &quot;System Events&quot;&lt;br /&gt;
    tell process &quot;iPhone Simulator&quot;&lt;br /&gt;
        tell menu bar 1&lt;br /&gt;
            tell menu bar item &quot;iOs Simulator&quot;&lt;br /&gt;
                tell menu &quot;iOs Simulator&quot;&lt;br /&gt;
                    click menu item &quot;Reset Content and Settings…&quot;&lt;br /&gt;
                end tell&lt;br /&gt;
            end tell&lt;br /&gt;
        end tell&lt;br /&gt;
        tell window 1&lt;br /&gt;
            click button &quot;Reset&quot;&lt;br /&gt;
        end tell&lt;br /&gt;
    end tell&lt;br /&gt;
end tell&lt;br /&gt;
SCRIPT&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
The code is not difficult to understand, first it sets the focus in the iPhone simulator, then it performs a navigation to the &quot;Reset content and Settings&quot; option from the Mac menu bar and clicks it, which displays a confirmation window.  Finally it clicks the &quot;Reset&quot; button in that window. 
    </content:encoded>

    <pubDate>Mon, 05 Mar 2012 19:54:00 +0100</pubDate>
    <guid isPermaLink="false">http://dejalatele.com/archives/6-guid.html</guid>
    
</item>
<item>
    <title>Testing a GPS fail on XCode 4.2</title>
    <link>http://dejalatele.com/archives/15-Testing-a-GPS-fail-on-XCode-4.2.html</link>
            <category>iOS</category>
            <category>Testing</category>
    
    <comments>http://dejalatele.com/archives/15-Testing-a-GPS-fail-on-XCode-4.2.html#comments</comments>
    <wfw:comment>http://dejalatele.com/wfwcomment.php?cid=15</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://dejalatele.com/rss.php?version=2.0&amp;type=comments&amp;cid=15</wfw:commentRss>
    

    <author>nospam@example.com (Antonio Diaz Ruiz)</author>
    <content:encoded>
    Since the version 4.2 XCode includes the option to test the GPS features of our iOS applications on the iPhone simulator by selecting among a few locations from a defaul list which includes cities as London, New York, Tokio, etc.  The procedure is quite simple you only have to pick up one citiy in your XCode project and when you launch your application on the iPhone simulator it will behave as if you were in that city.  This is really useful because by example a developer in London can test his application as if he were in Tokio and avoid bad user experience in this location.  But another interesting thing we can do is to test how our application will work if a GPS fail happened.  Let&#039;s see how.&lt;br /&gt;
&lt;br /&gt;
Those predetermined locations are saved on as GPX files.  GPX is an open light-weight XML data format for the interchange of GPS data between applications. XCode 4.2 offer us the possibility to &lt;a href=&quot;http://plainoldstan.blogspot.com/2011/08/on-gpx-files-for-xcode-42.html&quot;&gt;add our custom locations&lt;/a&gt; by creating new GPX files and including them on your XCode project.  The way we can force a GPS fail is just creating a GPX file what includes wrong geographical coordinates.  By example&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;gpx version=&quot;1.1&quot; creator=&quot;Xcode&quot;&amp;gt;&lt;br /&gt;
&amp;lt;wpt lat=&quot;77777777747,485317&quot; lon=&quot;19,073570&quot;&amp;gt;&lt;br /&gt;
&amp;lt;name&amp;gt;Force a GPS fail&amp;lt;/name&amp;gt;&lt;br /&gt;
&amp;lt;/wpt&amp;gt;&lt;br /&gt;
&amp;lt;/gpx&amp;gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
You can get more information about the schema an examples in the web site http://www.topografix.com/gpx.asp 
    </content:encoded>

    <pubDate>Thu, 01 Mar 2012 19:37:49 +0100</pubDate>
    <guid isPermaLink="false">http://dejalatele.com/archives/15-guid.html</guid>
    
</item>
<item>
    <title>Installing Curb in Ubuntu</title>
    <link>http://dejalatele.com/archives/11-Installing-Curb-in-Ubuntu.html</link>
            <category>Ruby</category>
    
    <comments>http://dejalatele.com/archives/11-Installing-Curb-in-Ubuntu.html#comments</comments>
    <wfw:comment>http://dejalatele.com/wfwcomment.php?cid=11</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://dejalatele.com/rss.php?version=2.0&amp;type=comments&amp;cid=11</wfw:commentRss>
    

    <author>nospam@example.com (Antonio Diaz Ruiz)</author>
    <content:encoded>
    For install curb in Ubuntu I&#039;ve follow steps quite similar to the required for&lt;a href=&quot;http://beginrescue.blogspot.com/2010/07/installing-curb-with-ruby-191-in.html&quot;&gt; install curb in Windows&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
1. Install Ruby dev kit&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;&lt;br /&gt;
sudo apt-get install ruby-dev&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
2. Install libcurl&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;&lt;br /&gt;
sudo apt-get install libcurl3 libcurl3-gnutls libcurl4-openssl-dev&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
3. Install curb&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;&lt;br /&gt;
sudo gem install curb&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
4. Test it with this simple script&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;&lt;br /&gt;
c = Curl::Easy.new&lt;br /&gt;
c.url = &quot;http://dejalatele.com&quot;&lt;br /&gt;
c.http_get&lt;br /&gt;
puts c.body_str.size &lt;br /&gt;
&lt;/div&gt; 
    </content:encoded>

    <pubDate>Tue, 28 Feb 2012 21:38:00 +0100</pubDate>
    <guid isPermaLink="false">http://dejalatele.com/archives/11-guid.html</guid>
    
</item>
<item>
    <title>A shell-like command line interpreter in Ruby</title>
    <link>http://dejalatele.com/archives/13-A-shell-like-command-line-interpreter-in-Ruby.html</link>
            <category>Ruby</category>
    
    <comments>http://dejalatele.com/archives/13-A-shell-like-command-line-interpreter-in-Ruby.html#comments</comments>
    <wfw:comment>http://dejalatele.com/wfwcomment.php?cid=13</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://dejalatele.com/rss.php?version=2.0&amp;type=comments&amp;cid=13</wfw:commentRss>
    

    <author>nospam@example.com (Antonio Diaz Ruiz)</author>
    <content:encoded>
    Going forward in my Ruby practices and as a continuation of &lt;a href=&quot;http://dejalatele.com/archives/12-Throw-catch-in-Ruby.html&quot;&gt;my previous post&lt;/a&gt;  here is the code of a shell-like command line interpreter which makes use of &lt;em&gt;catch/throw&lt;/em&gt; and exceptions for handle the user input.  The idea of this exercise came after read the &lt;a href=&quot;http://www.mkltesthead.com/2012/01/exercise-42-gothons-are-getting-classy.html&quot;&gt;ex 42&lt;/a&gt; of the series that Michael Larsen is doing following the &lt;a href=&quot;http://ruby.learncodethehardway.org/book/&quot;&gt;Learning Ruby the Hard Way&lt;/a&gt; book.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
class Shell&lt;br /&gt;
&lt;br /&gt;
    def initialize()&lt;br /&gt;
        @arguments = []&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    def run()&lt;br /&gt;
        nextOrder = prompt&lt;br /&gt;
&lt;br /&gt;
        while (nextOrder)&lt;br /&gt;
            catch (:callCommand) do&lt;br /&gt;
                throw :callCommand if nextOrder.length == 0&lt;br /&gt;
&lt;br /&gt;
                command = nextOrder.shift()&lt;br /&gt;
                @arguments = nextOrder&lt;br /&gt;
&lt;br /&gt;
                begin&lt;br /&gt;
                    currentCommand = method(command)&lt;br /&gt;
                rescue NameError&lt;br /&gt;
                    puts &quot;Command not found&quot;&lt;br /&gt;
                    throw :callCommand&lt;br /&gt;
                end&lt;br /&gt;
&lt;br /&gt;
                begin&lt;br /&gt;
                    currentCommand.call()&lt;br /&gt;
                rescue ArgumentError&lt;br /&gt;
                    puts &quot;Argument error&quot;&lt;br /&gt;
                rescue SystemExit&lt;br /&gt;
                    puts &quot;... bye!&quot;&lt;br /&gt;
                    Process.exit!(true)&lt;br /&gt;
                rescue Exception =&gt; unknownError&lt;br /&gt;
                    puts &quot;Unknown Error: #{unknownError.message}&quot;&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
            nextOrder = prompt&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    def prompt()&lt;br /&gt;
        print &quot;\n&gt;&quot;&lt;br /&gt;
        gets.chomp().split(&#039; &#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    def quit()&lt;br /&gt;
        raise SystemExit&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    def command1()&lt;br /&gt;
        puts &quot;Executing command1&quot;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    def command2()&lt;br /&gt;
        raise ArgumentError if @arguments.length == 0&lt;br /&gt;
        puts &quot;Executing command2&quot;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    def help()&lt;br /&gt;
        puts &amp;lt;&amp;lt;HELPTEXT&lt;br /&gt;
            command1 executes the command1&lt;br /&gt;
            command2 [ARGUMENT] executes the command2&lt;br /&gt;
            help  Shows this help.&lt;br /&gt;
            quit/exit  Exit the shell.&lt;br /&gt;
HELPTEXT&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
Shell.new.run&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
 &lt;br /&gt;
As you can see the shell-like program is implemented by a class whose methods are the available &quot;commands&quot; the user can execute over this shell.  Additionally the class includes methods for quit the shell, display help to the user, print out the shell prompt, and the &lt;em&gt;run&lt;/em&gt; method that is responsible for start up the shell.  The shell only allows the execution of &lt;em&gt;command1&lt;/em&gt; and &lt;em&gt;command2&lt;/em&gt; but it can be easily extended for allow the execution of more commands.   Just add those commands as methods of the Shell class.&lt;br /&gt;
When the user types a command the &lt;em&gt;prompt&lt;/em&gt; method returns an array which is handle by the &lt;em&gt;catch&lt;/em&gt; block labeled as  &lt;em&gt;callCommand&lt;/em&gt;.  Here, it extracts the first element off the array and assumes it is the command the user wants to execute and takes the remaining array as the arguments of the command.  &lt;br /&gt;
A few additional comments about the code.  The first &lt;em&gt;throw&lt;/em&gt; is called when the user types the &lt;em&gt;Return&lt;/em&gt; key without insert any command, then the program jumps out to the end of the &lt;em&gt;catch&lt;/em&gt; block and displays again the program prompt.  The first &lt;em&gt;exception&lt;/em&gt; block detects if the user types unknown command, in those cases it displays an error message and jumps out to the prompt method skipping the second &lt;em&gt;exception&lt;/em&gt; block, which is responsible of call the methods (commands) and handle their errors. I make use of the &lt;em&gt;rescue&lt;/em&gt; statement as a way for exit the program. I think more elegant than the the use of quit, die, or exit. Finally, for avoid the program stops its execution if an unexpected error happend, the last &lt;em&gt;rescue&lt;/em&gt; block invokes the base Exception class in Ruby. 
    </content:encoded>

    <pubDate>Wed, 22 Feb 2012 22:05:00 +0100</pubDate>
    <guid isPermaLink="false">http://dejalatele.com/archives/13-guid.html</guid>
    
</item>
<item>
    <title>Throw catch in Ruby</title>
    <link>http://dejalatele.com/archives/12-Throw-catch-in-Ruby.html</link>
            <category>Ruby</category>
    
    <comments>http://dejalatele.com/archives/12-Throw-catch-in-Ruby.html#comments</comments>
    <wfw:comment>http://dejalatele.com/wfwcomment.php?cid=12</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://dejalatele.com/rss.php?version=2.0&amp;type=comments&amp;cid=12</wfw:commentRss>
    

    <author>nospam@example.com (Antonio Diaz Ruiz)</author>
    <content:encoded>
    A few days ago I got stuck on the &lt;em&gt;throw/catch&lt;/em&gt; concept in Ruby.  The &lt;a href=&quot;http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_exceptions.html&quot;&gt;description on the Ruby documentation&lt;/a&gt; was not clear for me and I spend many hours trying to figure out how it works.  If you are on one of those days and get also stuck on these concepts I&#039;m going to try to show you how works through &lt;a href=&quot;http://www.ruby-doc.org/core-1.9.3/Kernel.html#method-i-catch&quot;&gt;this example included on the Ruby documentation&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;&lt;br /&gt;
def routine(n)&lt;br /&gt;
    puts n&lt;br /&gt;
    throw :done if n&lt;= 0&lt;br /&gt;
    routine(n-1)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
catch (:done) do&lt;br /&gt;
    routine(3)&lt;br /&gt;
end&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
The above code prints out a sequence of numbers in reverse order, stopping the sequence when it reaches the zero.  The way it stops the sequence is by the use of the throw statement.  Catch defines a block that is labeled (&quot;&lt;em&gt;done&lt;/em&gt;&quot; in the above example) and that is executed until a &lt;em&gt;throw&lt;/em&gt; is encountered. Usually this &lt;em&gt;throw&lt;/em&gt; statement is determined by a condition, in our example is &lt;em&gt;&quot;if n&lt;= 0&quot;&lt;/em&gt;.  Then, if the condition is not true it finishes the block where the thow is included, but if the condition is true it jumps out to the end of the of the active &lt;em&gt;catch&lt;/em&gt;.  In our example it finishes the script.&lt;br /&gt;
&lt;br /&gt;
We can&#039;t have a &lt;em&gt;throw&lt;/em&gt; statement with no catch &lt;em&gt;block&lt;/em&gt;.  Let&#039;s try the following variant&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;&lt;br /&gt;
def routine(n)&lt;br /&gt;
    puts n&lt;br /&gt;
    throw :done if n&lt;= 0&lt;br /&gt;
    routine(n-1)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
routine(3)&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
If you execute the code above you should see the following error&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;&lt;br /&gt;
`throw&#039;: uncaught throw :done (ArgumentError)&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
because there is no active catch block, the &lt;em&gt;throw&lt;/em&gt; was called but in the call stack there was not &lt;em&gt;catch&lt;/em&gt; block labeled with a tag which matches the throw&#039;s tag (&lt;em&gt;done&lt;/em&gt; in our example).&lt;br /&gt;
&lt;br /&gt;
We can include more than one &lt;em&gt;throw&lt;/em&gt; statement, here is an example&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;&lt;br /&gt;
def routine(n)&lt;br /&gt;
    puts n&lt;br /&gt;
    throw :done unless n&gt;2&lt;br /&gt;
    throw :done if n&gt;12&lt;br /&gt;
    routine(n+1)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
catch (:done) do&lt;br /&gt;
    routine(3)&lt;br /&gt;
end&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Finally, I recommend you to check this &lt;a href=&quot;http://www.rorexperts.com/rescue-raise-vs-catch-throw-in-ruby-t2162.html&quot;&gt;link&lt;/a&gt; and this &lt;a href=&quot;http://www.jacopretorius.net/2012/01/catch-and-throw-in-ruby.html&quot;&gt;link&lt;/a&gt; what were usefull for help me to understand this topic. 
    </content:encoded>

    <pubDate>Sun, 12 Feb 2012 11:37:16 +0100</pubDate>
    <guid isPermaLink="false">http://dejalatele.com/archives/12-guid.html</guid>
    
</item>
<item>
    <title>Launching the iPhone simulator using Apache Ant</title>
    <link>http://dejalatele.com/archives/7-Launching-the-iPhone-simulator-using-Apache-Ant.html</link>
            <category>iOS</category>
    
    <comments>http://dejalatele.com/archives/7-Launching-the-iPhone-simulator-using-Apache-Ant.html#comments</comments>
    <wfw:comment>http://dejalatele.com/wfwcomment.php?cid=7</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://dejalatele.com/rss.php?version=2.0&amp;type=comments&amp;cid=7</wfw:commentRss>
    

    <author>nospam@example.com (Antonio Diaz Ruiz)</author>
    <content:encoded>
    Here&#039;s the XML of an &lt;a href=&quot;http://ant.apache.org/&quot;&gt;Apache Ant&lt;/a&gt; buildfile that allows the execution of an iPhone application on the iPhone simulator.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;&lt;br /&gt;
&amp;lt;project name=&quot;my-iPhone-project&quot;&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;xcodebuild&quot; value=&quot;path_to_xcodebuilder_execuitable&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;sdk&quot; value=&quot;5.1&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;build_path&quot; value=&quot;/myhomepath/my_builds_folder&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;application_path&quot; value=&quot;${build_path}/Applications/my_iOS_application.app/my_application&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;simulator_path&quot; value=&quot;/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;target name=&quot;run&quot; depends=&quot;install, simulator&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;target name=&quot;build&quot; depends=&quot;clean, make&quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;target name=&quot;clean&quot;&amp;gt;&lt;br /&gt;
&amp;lt;delete dir=&quot;build&quot; failonerror=&quot;false&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;xcodebuild target=&quot;my_application_target&quot;&amp;gt;&lt;br /&gt;
&amp;lt;arg value=&quot;clean&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/xcodebuild&amp;gt;&lt;br /&gt;
&amp;lt;/target&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;target name=&quot;make&quot;&amp;gt;&lt;br /&gt;
&amp;lt;xcodebuild target=&quot;my_application_target&quot;&amp;gt;&lt;br /&gt;
&amp;lt;arg value=&quot;build&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/xcodebuild&amp;gt;&lt;br /&gt;
&amp;lt;/target&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;target name=&quot;install&quot; depends=&quot;build&quot;&amp;gt;&lt;br /&gt;
&amp;lt;xcodebuild target=&quot;my_application_target&quot;&amp;gt;&lt;br /&gt;
&amp;lt;arg value=&quot;install&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/xcodebuild&amp;gt;&lt;br /&gt;
&amp;lt;/target&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;target name=&quot;simulator&quot;&amp;gt;&lt;br /&gt;
&amp;lt;iphone_simulator/&amp;gt;&lt;br /&gt;
&amp;lt;/target&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;macrodef name=&quot;xcodebuild&quot;&amp;gt;&lt;br /&gt;
&amp;lt;attribute name=&quot;dir&quot; default=&quot;/myhomepath/my_application_source_code_folder&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;attribute name=&quot;builddir&quot; default=&quot;${build_path}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;attribute name=&quot;failonerror&quot; default=&quot;true&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;attribute name=&quot;target&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;attribute name=&quot;sdk&quot; default=&quot;${sdk}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;attribute name=&quot;configuration&quot; default=&quot;${configuration}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;element name=&quot;args&quot; optional=&quot;true&quot; implicit=&quot;true&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;sequential&amp;gt;&lt;br /&gt;
&amp;lt;exec executable=&quot;${xcodebuild}&quot; dir=&quot;@{dir}&quot; failonerror=&quot;@{failonerror}&quot;  failifexecutionfails=&quot;@{failonerror}&quot;&amp;gt;&lt;br /&gt;
&amp;lt;arg value=&quot;-target&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;arg value=&quot;@{target}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;arg value=&quot;-sdk&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;arg value=&quot;@{sdk}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;arg value=&quot;-configuration&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;arg value=&quot;@{configuration}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;arg value=&quot;SYMROOT=@{builddir}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;arg value=&quot;DSTROOT=@{builddir}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;args/&amp;gt;&lt;br /&gt;
&amp;lt;/exec&amp;gt;&lt;br /&gt;
&amp;lt;/sequential&amp;gt;&lt;br /&gt;
&amp;lt;/macrodef&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;macrodef name=&quot;iphone_simulator&quot;&amp;gt;&lt;br /&gt;
&amp;lt;attribute name=&quot;applicationpath&quot; default=&quot;${application_path}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;sequential&amp;gt;&lt;br /&gt;
&amp;lt;exec executable=&quot;${simulator_path}&quot; spawn=&quot;true&quot;&amp;gt;&lt;br /&gt;
&amp;lt;arg value=&quot;-SimulateApplication&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;arg value=&quot;@{applicationpath}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;arg value=&quot;&amp;amp;&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/exec&amp;gt;&lt;br /&gt;
&amp;lt;/sequential&amp;gt;&lt;br /&gt;
&amp;lt;/macrodef&amp;gt;&lt;br /&gt;
&amp;lt;/project&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
What you should see when you save this build file and run Ant is &lt;em&gt;xcodebuilder&lt;/em&gt; will start to clean, build and install our application, and when &lt;em&gt;xcodebuilder&lt;/em&gt; will finish the iPhone simulater will start automatically to run our application.&lt;br /&gt;
&lt;br /&gt;
Some key points here are the following:&lt;br /&gt;
- The xcodebuild property is the path to the xcodebuilder executable.&lt;br /&gt;
- The sdk property should be the iOS version you want to run your application.&lt;br /&gt;
- The build_path property is the path where &lt;em&gt;xcodebuilder&lt;/em&gt; will build and install the application.  It could be any path.  Notice that this property is passed into the macro responsible of the &lt;em&gt;xcodebuilder&lt;/em&gt; execution.&lt;br /&gt;
- The application_path property is the path of the application inside the build path.  It should be similar to the example above because &lt;em&gt;xcodebuilder&lt;/em&gt; installs the applications on folder called  &lt;em&gt;Applications&lt;/em&gt;.&lt;br /&gt;
- The simulator_path property is the path of the simulator executable.&lt;br /&gt;
- You should specify the target of the application by the attribute &lt;em&gt;target&lt;/em&gt; in all the &lt;em&gt;xcodebuilder&lt;/em&gt; calls.  &lt;strong&gt;Don&#039;t confuse&lt;/strong&gt; the application target with the Ant targets.&lt;br /&gt;
- The macro &lt;em&gt;xcodebuild&lt;/em&gt; contains the necessary code to call the &lt;em&gt;xcodebuilder&lt;/em&gt; executable.  Pay attention to the first attribute &lt;em&gt;dir&lt;/em&gt;, it is the path to the source code of your application.  Your can use the same attributes and arguments as in the example, but it is advisable to check man page of &lt;em&gt;xcodebuilder&lt;/em&gt; for a better understanding of the meaning of each available arguments.  Be careful with the order of the arguments inside the &lt;em&gt;sequential&lt;/em&gt; Ant container because it executes the nested tasks in sequence, so if you wrongly modify the order of the arguments, &lt;em&gt;xcodebuild&lt;/em&gt; will not run.&lt;br /&gt;
- Finally the &lt;em&gt;iphone_simulator&lt;/em&gt; macro will run the simulator starting your application.  The last argument (the ampersand) is passed with the only purpose of execute the simulator in background.&lt;br /&gt;
&lt;br /&gt;
This build file can be used in various ways but the most useful could be the launch of automated tests.  
    </content:encoded>

    <pubDate>Sun, 29 Jan 2012 21:01:00 +0100</pubDate>
    <guid isPermaLink="false">http://dejalatele.com/archives/7-guid.html</guid>
    
</item>
<item>
    <title>Avoiding crashes</title>
    <link>http://dejalatele.com/archives/3-Avoiding-crashes.html</link>
            <category>Automation</category>
            <category>iOS</category>
    
    <comments>http://dejalatele.com/archives/3-Avoiding-crashes.html#comments</comments>
    <wfw:comment>http://dejalatele.com/wfwcomment.php?cid=3</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://dejalatele.com/rss.php?version=2.0&amp;type=comments&amp;cid=3</wfw:commentRss>
    

    <author>nospam@example.com (Antonio Diaz Ruiz)</author>
    <content:encoded>
    When we doing test automation for iPhone or iPad using the &lt;a href=&quot;http://code.google.com/p/uispec/&quot;&gt;UISpec&lt;/a&gt; framework we have to pay attention to the existence or not of the UI elements we interact with.  If we try to touch a button, fill in a text field or perform any kind of interaction with an element and the element doesn&#039;t exist the Test application will crash and will stop the execution of the rest of specs.  So, we have to check the existence of the element before try to interact with them.  We can avoid the crash setting expectations before interact with the element.  &lt;br /&gt;
Let&#039;s imagine a screen with two buttons and we want to touch the second one, the UIquery code of the button is&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;&lt;br /&gt;
[[[app button] index:1] touch];&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
If this code is not correct or the button is no present on the screen the application which run the tests will crash, but if we set the expectation before the interaction &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;&lt;br /&gt;
[expectThat([app button] index:1]) should:be(YES)];&lt;br /&gt;
[[[app button] index:1] touch];&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
as the expectation will not be satisfied the execution of this spec will finish at this point but it won&#039;t finish the execution of the whole test application.  It will continue with the next spec.&lt;br /&gt;
&lt;br /&gt;
A more elaborated implementation could be&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;code&quot;&gt;&lt;br /&gt;
    BOOL existElement;&lt;br /&gt;
&lt;br /&gt;
    @try {&lt;br /&gt;
        existElement = [[[[app button] index:1] should] exist];&lt;br /&gt;
    }&lt;br /&gt;
    @catch (NSException *exception) {&lt;br /&gt;
        NSLog(@&quot;EXCEPTION CAUSED BY: %@&quot;, [NSThread callStackSymbols]);&lt;br /&gt;
    }&lt;br /&gt;
    @finally {&lt;br /&gt;
        [expectThat(existElement) should:be(YES)];&lt;br /&gt;
    }&lt;br /&gt;
&lt;/div&gt; 
    </content:encoded>

    <pubDate>Fri, 13 Jan 2012 19:41:29 +0100</pubDate>
    <guid isPermaLink="false">http://dejalatele.com/archives/3-guid.html</guid>
    
</item>

</channel>
</rss>
