tag:blogger.com,1999:blog-35270608268490814892011-10-23T02:30:52.087+13:00Gravitini iOS DevelopmentGravitinihttp://www.blogger.com/profile/06797850924645926080noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-3527060826849081489.post-19436541731354023702010-08-16T23:00:00.032+12:002010-08-16T23:42:47.752+12:00NSZombies to the rescue... finding your EXC BAD ACCESS memory issueAnyone who has developed a native application for iOS will have encountered the dreaded EXC BAD ACCESS error with zero information about what caused the crash.<br /><br />NSZombies catches attempts to access deallocated objects (which are the primary causes of that error) by replacing the deallocated object with a zombie.<br /><br />When a zombie is accessed a helpful message is logged to the console: <span style="font-family: "Courier New",Courier,monospace; font-size: x-small;">message sent to deallocated instance</span><br /><br />Take a read of <a href="http://developer.apple.com/iphone/library/documentation/xcode/conceptual/iphone_development/130-Debugging_Applications/debugging_applications.html">Finding Memory Leaks</a> for instructions on how to activate NSZombieEnabled on your Debug executable.<br /><br />Make sure you only activate NSZombies on your Debug executable as you don't want to release an application that never frees memory.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3527060826849081489-1943654173135402370?l=ios-dev.gravitini.com' alt='' /></div>Gravitinihttp://www.blogger.com/profile/06797850924645926080noreply@blogger.com0tag:blogger.com,1999:blog-3527060826849081489.post-44621974120745780642009-03-18T12:30:00.010+13:002009-03-19T11:16:07.087+13:00iPhone OS 3.0 Beta<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.gravitini.com/images/iphoneos3.png"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 163px; height: 120px;" src="http://www.gravitini.com/images/iphoneos3.png" border="0" alt="" /></a><span class="Apple-style-span" style="font-family:'lucida grande';"><br /></span><span class="Apple-style-span" style=" ;font-family:Times;"><div style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; width: auto; font: normal normal normal 100%/normal Georgia, serif; text-align: left; "><span><span><span><span><span class="Apple-style-span" style="font-family:'lucida grande';">Well, I've taken the plunge and installed the iPhone OS 3.0 beta on my iPhone 3G.</span></span></span></span></span></div><div style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; width: auto; font: normal normal normal 100%/normal Georgia, serif; text-align: left; "><span><span><span><span><span class="Apple-style-span" style="font-family:'lucida grande';"><br />... it's a one way trip just in case you didn't read bullet point 3 of the iPhone OS 3.0 beta pre-installation advisory notes.</span></span></span></span></span></div><div style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; width: auto; font: normal normal normal 100%/normal Georgia, serif; text-align: left; "><span class="Apple-style-span" style="font-family:'lucida grande';"><br /></span></div><div style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; width: auto; font: normal normal normal 100%/normal Georgia, serif; text-align: left; "><span><span><span><span><span class="Apple-style-span" style="font-family:'lucida grande';"><br />I'm guessing this was a popular download as Apple's iPhone Dev Center site initially failed under the load.<br /><br /></span></span></span></span></span></div><div style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; width: auto; font: normal normal normal 100%/normal Georgia, serif; text-align: left; "><span><span><span><span><span class="Apple-style-span" style="font-family:'lucida grande';">Here's the cool stuff so far:</span></span></span></span></span></div><div style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; width: auto; font: normal normal normal 100%/normal Georgia, serif; text-align: left; "><ul><li><span class="Apple-style-span"><span class="Apple-style-span" style="font-family:'lucida grande';">Cut Copy Paste </span></span><span class="Apple-style-span" style="color:#C0C0C0;"><span class="Apple-style-span" style="font-family:'lucida grande';">(it works well)</span></span></li><li><span class="Apple-style-span"><span class="Apple-style-span" style="font-family:'lucida grande';">Forwarding of text messages </span></span><span class="Apple-style-span" style="color:#C0C0C0;"><span class="Apple-style-span" style="font-family:'lucida grande';">(which we had that around xmas)</span></span></li><li><span class="Apple-style-span"><span class="Apple-style-span" style="font-family:'lucida grande';">Landscape for mail, notes and the new messages app </span></span><span class="Apple-style-span" style="color:#C0C0C0;"><span class="Apple-style-span" style="font-family:'lucida grande';">(SMS++)</span></span></li><li><span class="Apple-style-span" style="font-family:'lucida grande';">Global search </span><span class="Apple-style-span" style="color:#C0C0C0;"><span class="Apple-style-span" style="font-family:'lucida grande';">(wish it had some filter icons eg apps only)</span></span></li><li><span class="Apple-style-span"><span class="Apple-style-span" style="font-family:'lucida grande';">Synchronisation of notes </span></span><span class="Apple-style-span" style="color:#C0C0C0;"><span class="Apple-style-span" style="font-family:'lucida grande';">(but only to Apple Mail and Mobile Me)</span></span></li></ul><div><span class="Apple-style-span" style="font-family:'lucida grande';">Most painful experience was having to reorganise my 150+ icons :-(</span></div><div><span class="Apple-style-span" style="font-family:'lucida grande';"><br /></span></div><div><div><span class="Apple-style-span" style="font-family:'lucida grande';"><br /></span></div></div></div></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3527060826849081489-4462197412074578064?l=ios-dev.gravitini.com' alt='' /></div>Gravitinihttp://www.blogger.com/profile/06797850924645926080noreply@blogger.com0tag:blogger.com,1999:blog-3527060826849081489.post-84047224068833934372009-02-12T14:00:00.002+13:002010-08-16T23:45:11.294+12:00Using Xcode Targets for Adhoc iTunes Artwork<span class="Apple-style-span" style="font-family: 'lucida grande';">By creating multiple Xcode targets you can adjust what files are included in each target.</span><br /><div><span class="Apple-style-span" style="font-family: 'lucida grande';"><br /></span></div><div><span class="Apple-style-span" style="font-family: 'lucida grande';">eg iTunesArtwork for adhoc users or testers</span></div><div><span class="Apple-style-span" style="font-family: 'lucida grande';"><br /></span></div><div><span class="Apple-style-span" style="font-family: 'lucida grande';">As the iTunesArtwork file only works for adhoc builds you want to exclude it from debug and release builds.</span></div><div><div><div><span class="Apple-style-span" style="font-family: 'lucida grande';"><br /></span></div><div><span class="Apple-style-span" style="font-family: 'lucida grande';">To create an Adhoc target which includes your iTunesArtwork file you need to:</span></div><div><ul><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Create a new Adhoc target<br /></span></li><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Add your iTunesArtwork file to your project<br /></span></li><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Change the target memberships for your iTunesArtwork</span></li></ul></div><div><span class="Apple-style-span" style="font-family: 'lucida grande';">Step by Step:</span></div><div><ol><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Duplicate the primary target (right click -> Duplicate)</span><br /></li><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Rename the new target to Adhoc<br /></span></li><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Add your iTunesArtwork file to your project as described </span><a href="http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/145-Publishing_Applications_for_Testing/chapter_9_section_3.html#//apple_ref/doc/uid/TP40007959-CH10-SW7" target="_blank"><span class="Apple-style-span" style="font-family: 'lucida grande';">here</span></a><br /></li><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Change the target memberships for your iTunesArtwork file to Adhoc only using:<br />Select Target -> right click -> Get Info -> Targets<br />(make sure only Adhoc is selected)</span></li></ol></div><div><span class="Apple-style-span" style="font-family: 'lucida grande';">Once you've made these changes you can explore the Target build phases. The iTunesArtwork file should only appear in Copy Bundle Resources for the Adhoc target.</span></div><div><br /></div><div><span class="Apple-style-span" style="font-family: 'lucida grande';">It may be useful to have matching targets and configurations for each type of build eg</span></div><div><ul><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Debug</span></li><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Adhoc</span></li><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Release </span><br /></li></ul><div><span class="Apple-style-span" style="font-family: 'lucida grande';">When changing the build type set both the active configuration and active target.</span></div><div><span class="Apple-style-span" style="font-family: 'lucida grande';"><br /></span></div></div><div><span class="Apple-style-span" style="font-family: 'lucida grande';">Other uses for multiple targets include:</span></div><div><ul><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Different icons for Debug / Adhoc / Release builds</span></li><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Incrementing build numbers only for Adhoc / Release builds</span></li></ul></div></div></div><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3527060826849081489-8404722406883393437?l=ios-dev.gravitini.com' alt='' /></div>Gravitinihttp://www.blogger.com/profile/06797850924645926080noreply@blogger.com0tag:blogger.com,1999:blog-3527060826849081489.post-51102487050927800462009-02-12T11:30:00.008+13:002010-08-16T23:45:43.684+12:00Identifying the Current Xcode Configuration<span class="Apple-style-span" style="font-family: 'lucida grande';">The easiest way to identify the current configuration in code is by creating a preprocessor macro under your Xcode project build settings.</span><br /><div><span class="Apple-style-span" style="font-family: 'lucida grande';"><br /></span></div><div><span class="Apple-style-span" style="font-family: 'lucida grande';">Step by step:</span></div><div><ol><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Project menu -> Edit Project Settings -> Build tab</span></li><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Select All Configurations</span></li><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Scroll down to GCC 4.0 - Preprocessing</span></li><li><span class="Apple-style-span" style="font-family: 'lucida grande';">Add the following to Preprocessor Macros Not Used in Precompiled Headers:<br /><br />CONFIGURATION_$(CONFIGURATION)</span></li></ol><div><span class="Apple-style-span" style="font-family: 'lucida grande';">Assuming you have Debug, Adhoc and Release configurations, this will generate preprocessor macros for each configuration. ie</span></div><div><ul><li><span class="Apple-style-span" style="font-family: 'courier new';">CONFIGURATION_Debug</span></li><li><span class="Apple-style-span" style="font-family: 'courier new';">CONFIGURATION_Adhoc</span></li><li><span class="Apple-style-span" style="font-family: 'courier new';">CONFIGURATION_Release</span></li></ul></div><div><span class="Apple-style-span" style="font-family: 'lucida grande';">In your code you can now use something like:</span><span class="Apple-style-span" style="font-family: 'courier new';"></span></div><div><span class="Apple-style-span" style="font-family: 'courier new';"><br /></span></div><div><span class="Apple-style-span" style="font-family: 'courier new';">#ifdef CONFIGURATION_Debug</span></div><div><span class="Apple-tab-span" style="white-space: pre;"><span class="Apple-tab-span" style="white-space: pre;"><span class="Apple-style-span" style="font-family: 'courier new';"> </span></span><span class="Apple-style-span" style="font-family: 'courier new';">NSLog(@"Debug message");</span></span><span class="Apple-style-span" style="font-family: 'courier new';"><br /></span></div><div><span class="Apple-style-span" style="white-space: pre;"><span class="Apple-style-span" style="font-family: 'courier new';">#endif</span></span></div><div><span class="Apple-style-span" style="white-space: pre;"><span class="Apple-style-span" style="font-family: 'courier new';"><br /></span></span></div><div><span class="Apple-style-span" style="white-space: pre;"><span class="Apple-style-span" style="font-family: 'courier new';">#if defined (CONFIGURATION_Debug) || defined (CONFIGURATION_Adhoc)</span></span></div><div><span class="Apple-style-span" style="white-space: pre;"><span class="Apple-tab-span" style="white-space: pre;"><span class="Apple-style-span" style="font-family: 'courier new';"> </span></span><span class="Apple-style-span" style="font-family: 'courier new';">NSLog( @"Warning message");<br /></span></span></div><div><span class="Apple-style-span" style="white-space: pre;"><span class="Apple-style-span" style="font-family: 'courier new';">#endif</span></span></div><div><br /></div></div><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3527060826849081489-5110248705092780046?l=ios-dev.gravitini.com' alt='' /></div>Gravitinihttp://www.blogger.com/profile/06797850924645926080noreply@blogger.com1tag:blogger.com,1999:blog-3527060826849081489.post-65252604683590649802008-12-07T23:00:00.009+13:002009-02-12T12:20:45.921+13:00Updating Leopard's Pre-Installed Subversion<span style="font-family:lucida grande;">Here's the how to update Leopard's pre-installed copy of subversion.</span><br /><br /><span style="font-family:lucida grande;">Download and install the latest universal binary from CollabNet:</span><br /><span style="font-family:lucida grande;">http://www.collab.net/downloads/community/includes/communitydownloads-getit-mac.html</span><br /><br /><span style="font-family:lucida grande;">The installer puts everything into /opt/subversion and creates symbolic links in /usr/local/bin but this doesn't disable the pre-installed copy in /usr/bin.</span><br /><br /><span style="font-family:lucida grande;">You need to get adventurous:<br /></span><ol><li><span style="font-family:lucida grande;">Create symbolic links in /usr/bin/ and /usr/lib/ to the new subversion files in /opt/subversion/bin/ and /op/subversion/lib/<br /></span></li><li><span style="font-family:lucida grande;">Update your apache subversion configuration to use the new /opt/subversion/lib/svn-apache/mod_dav_svn.so</span></li></ol><span class="Apple-style-span" style=" ;font-family:'lucida grande';">Note: do not update libapr to 1.0.2.12 as it will cause a problem with Apache.</span><br /><span style="font-family:lucida grande;"><br />Step by step using Terminal:</span><br /><ol><li><span style="font-family:lucida grande;">Commit all your files and close all subversion clients eg Xcode</span></li><li><span style="font-family:lucida grande;">If not logged in as an admin account switch user to an admin account:<br /><span style="font-family:courier new;">su admin</span><br /></span></li><li><span style="font-family:lucida grande;">Create links to the new subversion files:<br /><span style="font-family:courier new;">sudo ln -sf /opt/subversion/bin/svn* /usr/bin/<br />sudo ln -sf /opt/subversion/lib/libsvn* /usr/lib/<br /></span></span></li><li><span style="font-family:lucida grande;">Edit your apache2 subversion configuration file:</span><span style="font-family:lucida grande;"> (your location may be different)</span><br /><span style="font-family:lucida grande;"><span style="font-family:courier new;">sudo pico /etc/apache2/other/svn.conf<br /></span></span></li><li><span style="font-family:lucida grande;">Update LoadModule to:<br /><span style="font-family:courier new;">LoadModule dav_svn_module /opt/subversion/lib/svn-apache/mod_dav_svn.so</span><br /><br /></span></li></ol><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3527060826849081489-6525260468359064980?l=ios-dev.gravitini.com' alt='' /></div>Gravitinihttp://www.blogger.com/profile/06797850924645926080noreply@blogger.com0tag:blogger.com,1999:blog-3527060826849081489.post-54270202471417339282008-12-06T15:00:00.006+13:002010-08-18T03:06:16.382+12:00Incrementing Your Build Number in XcodeHere's a little shell script to increment a build number automatically with each build.<br /><br /><span style="font-size: 85%;"><span style="font-family: courier new;"></span></span>It assumes the following about your versions in info.plist:<br /><ul><li>Your product version is CFBundleShortVersionString in info.plist<br />eg 1.0.0<br /></li><li>Your build number is appended to your product version in CFBundleVersion<br />eg 1.0.0.133<br /></li></ul>Step by step:<br /><br /><ol><li>Enter some default values in info.plist<br /><span style="font-family: courier new;">Bundle versions string, short: 0.1.0 (CFBundleShortVersionString)</span><br /><span style="font-family: courier new;"> Bundle version: 0.1.0.1 (CFBundleVersion) </span></li><li>Select your Target in Xcode</li><li>Add a new run script build phase:<br /><span style="font-family: courier new;">Project -> New Build Phase -> New Run Script Build Phase</span></li><li>Paste the script below into the script box</li><li>Build your project</li></ol><span style="font-size: 85%;"><span style="font-family: courier new;">version=$(sed -n '</span><br /><span style="font-family: courier new;">/^[[:blank:]]*<key>CFBundleShortVersionString<\/key>$/ {</key></span><br /><span style="font-family: courier new;">N</span><br /><span style="font-family: courier new;">s/^[[:blank:]]*<key>CFBundleShortVersionString<\/key>\n[[:blank:]]*<string>\(.*\)<\/string>/\1/</string></key></span><br /><span style="font-family: courier new;">p</span><br /><span style="font-family: courier new;">}' info.plist)</span><span style="font-family: courier new;"><br /><br />build=$(sed -n '</span><br /><span style="font-family: courier new;">/^[[:blank:]]*<key>CFBundleVersion<\/key>$/ {</key></span><br /><span style="font-family: courier new;">N</span><br /><span style="font-family: courier new;">s/^[[:blank:]]*<key>CFBundleVersion<\/key>\n[[:blank:]]*<string>.*\.\(.*\)<\/string>/\1/</string></key></span><br /><span style="font-family: courier new;">p</span><br /><span style="font-family: courier new;">}' info.plist)</span><span style="font-family: courier new;"><br /><br />build=$(($build +1))</span><br /><span style="font-family: courier new;"><br />cp Info.plist 'Backup of Info.plist'</span><span style="font-family: courier new;"><br /><br />sed '</span><span style="font-family: courier new;"><br />/^[[:blank:]]*<key>CFBundleVersion<\/key>$/ {</key></span><br /><span style="font-family: courier new;">N</span><br /><span style="font-family: courier new;">s/\(<string>\).*\(<\/string>\)/\1'"$version\.$build"'\2/</string></span><br /><span style="font-family: courier new;">P</span><br /><span style="font-family: courier new;">D</span><br /><span style="font-family: courier new;">}' 'Backup of info.plist' > Info.plist<br /></span></span><br /><span style="font-size: 85%;"><span style="font-family: courier new;"></span></span>Each time you build using that target the build number will be incremented. A backup of your info.plist is made (just in case).<br /><br />You could easily extend this script to commit files to your subversion repository.<br /><br />The script uses multi-line sed and I'm no sed magician. If you're looking for a sed tutorial try <a href="http://www.grymoire.com/Unix/Sed.html">here</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3527060826849081489-5427020247141733928?l=ios-dev.gravitini.com' alt='' /></div>Gravitinihttp://www.blogger.com/profile/06797850924645926080noreply@blogger.com0