SlideShare a Scribd company logo
1 of 31
solving little problems
My First iPhone App
On contract…

  for non-developer…

  who wants to use his own
  developer account.

Presents some challenges.

Only my second Objective-C
program…

  what can I learn?
Huh?

On app store now (yay!).

Simple idea—audio translation of
silly phrases.

Moderate dataset (4 languages, 202
phrases, 808 audio files).

  May expand later with StoreKit.
Four Things

Core Data

Slow Startup and Progress

Debug Archiving

Build Numbering with git
1. Core Data
               Used for language/phrase
               reference information for easy
               update.

               Slightly confusing since I
               know SQL well.

               Lots of work to set up queries.

               Matt Gallagher (Cocoa with
               Love) showed code that helps.
Core Data: one line fetch

I adopted and extended this
code as a category now on
GitHub:

  github.com/halostatue/
  coredata-easyfetch
Apple’s Example
NSManagedObjectContext *moc = [self managedObjectContext];
NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Employee"
                                    inManagedObjectContext:moc];
NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
[request setEntity:entityDescription];

// Set example predicate and sort orderings...
NSNumber *minimumSalary = ...;
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(lastName LIKE[c] 'Worsley') AND (salary > %@)",
                                     minimumSalary];
[request setPredicate:predicate];

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"firstName" ascending:YES];
[request setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
[sortDescriptor release];

NSError *error = nil;
NSArray *array = [moc executeFetchRequest:request error:&error];
if (array == nil)
{
    // Deal with error...
}
Apple’s Example
NSManagedObjectContext *moc = [self managedObjectContext];
NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Employee"
                                    inManagedObjectContext:moc];




            12+
NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
[request setEntity:entityDescription];

// Set example predicate and sort orderings...
NSNumber *minimumSalary = ...;
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(lastName LIKE[c] 'Worsley') AND (salary > %@)",
                                     minimumSalary];
[request setPredicate:predicate];

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"firstName" ascending:YES];




        Statements!
[request setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
[sortDescriptor release];

NSError *error = nil;
NSArray *array = [moc executeFetchRequest:request error:&error];
if (array == nil)
{
    // Deal with error...
}
Matt’s Example

  [[self managedObjectContext]
     fetchObjectsForEntityName:@"Employee"
            withPredicate:@"(lastName LIKE[c] 'Worsley') AND (salary > %@)",
                     minimumSalary];




 1 Statement!
coredata-easyfetch
   #import “NSManagedObjectContext-EasyFetch.h”

   …

   [[self managedObjectContext]
      fetchObjectsForEntityName:@"Employee"
           predicateWithFormat:@"(lastName LIKE[c] 'Worsley') AND (salary > %@)",
                       minimumSalary];


Made a category so it’s easy                       All objects, unsorted (1)
to reuse.
                                                   All objects, sorted (2)
Refactored easy filtering.
                                                   Some objects, unsorted (2)
Added easy sorting.
                                                   Some objects, sorted (4)
How I Use It

 + (NSMutableArray*)fetchAllFromManagedObjectContext:(NSManagedObjectContext*)moc
 {
   return [[[moc fetchObjectsForEntityName:@"DataVersion"] mutableCopy] autorelease];
 }

 + (NSMutableArray*)fetchAllFromManagedObjectContext:(NSManagedObjectContext*)moc
 {
   NSArray* fetched = [moc fetchObjectsForEntityName:@"Language"];
   NSMutableArray* result = [fetched mutableCopy];
   [result release];

     return result;
 }

 + (NSMutableArray*)fetchAllFromManagedObjectContext:(NSManagedObjectContext*)moc
 {
   NSArray* fetched = [moc fetchObjectsForEntityName:@"Phrase" sortByKey:@"phraseId" ascending:YES];
   NSMutableArray* result = [fetched mutableCopy];
   [result release];
   return result;
 }
2. Progress
              Original plan:

                Copy all media files from
                bundle to document area.

              Problem:

                Slow (~20–30 seconds)

              Solution:

                Show a progress monitor.
MBProgressHUD
MBProgressHUD
Created in April 2009

  Matej Bukovinski

  http://github.com/matej/
  MBProgressHUD/

Other options exist, such as
DSActivityView

  http://www.dejal.com/
  developer/dsactivityview
Beautiful, but…
…the progress HUD blocked
the application logo

…immediately on launch.

Request:

  Move the HUD to a
  different spot, and

  don’t show it unless the
  work takes 2 seconds or
  more.
Easy enough…
Added x- and y-offsets

Added a delay-before-showing

   Later changed by Matej to
   be a “grace time”

Pushed back to master and
MBProgressHUD is reasonably
active for a little project.

My version is at github.com/
halostatue/MBProgressHUD
3. Save the dSYM

             Had crashes on the client’s
             iPhone that I couldn’t
             reproduce.

             Hadn’t been saving my
             dSYM bundles…so I
             couldn’t symbolicate the
             logs.
Symboliwhat?
Again, with feeling…

Craig Hockenberry:

  http://furbo.org/2008/08/08/
  symbolicatifination/

  Crash logs have address
  offsets; if you have the
  dSYM bundles, you can
  “symbolicate” to restore
  method names.
Simple script…
# http://furbo.org/stuff/dSYM_Archive.txt
ARCHIVE_ROOT="$PROJECT_DIR/dSYM_Archive"

if [ $SDK_NAME = "iphoneos2.0" ]; then
    echo "Archiving $CONFIGURATION in $ARCHIVE_ROOT at `date`" >> /tmp/dSYM_Archive.out
    if [ $CONFIGURATION = "Distribution-Free" -o $CONFIGURATION = "Distribution-Paid" -o $CONFIGURATION =
"Distribution-Beta-Free" ]; then
        ARCHIVE_CONFIG_FOLDER="$ARCHIVE_ROOT/$CONFIGURATION"
        mkdir -p -v "$ARCHIVE_CONFIG_FOLDER" >> /tmp/dSYM_Archive.out
        ARCHIVE_FOLDER="$ARCHIVE_CONFIG_FOLDER/`date "+%Y-%m-%d-%H%M%S"`"
        echo "Copying $DWARF_DSYM_FOLDER_PATH to $ARCHIVE_FOLDER" >> /tmp/dSYM_Archive.out
        cp -R $DWARF_DSYM_FOLDER_PATH $ARCHIVE_FOLDER >> /tmp/dSYM_Archive.out
    fi
fi
My script…
      #!/bin/bash

      function prepare_adhoc_package()
      {
        if [ ${#} -eq 1 ]; then
          BASE_NAME="${1}"
        else
          BASE_NAME="${PROJECT}"
        fi

          PAYLOAD_FOLDER="${ARCHIVE_FOLDER}/Payload"
          mkdir -p "${PAYLOAD_FOLDER}"

          if [ -d "${ARCHIVE_FOLDER}/${BASE_NAME}.app" ]; then
            cp -rp "${ARCHIVE_FOLDER}/${BASE_NAME}.app" "${PAYLOAD_FOLDER}"
            cp "${ARCHIVE_FOLDER}/${BASE_NAME}.app/iTunesArtwork" "${ARCHIVE_FOLDER}"
            (cd "${ARCHIVE_FOLDER}"; zip -qr "${BASE_NAME}.ipa" iTunesArtwork Payload)
          else
            for app in "${ARCHIVE_FOLDER}/*.app"; do
              cp -rp "${app}" "${PAYLOAD_FOLDER}"
              cp -rp "${app}/iTunesArtwork" "${ARCHIVE_FOLDER}"
            done

           (cd "${ARCHIVE_FOLDER}"; zip -qr "${BASE_NAME}.ipa" iTunesArtwork Payload)
          fi

          rm -rf "${ARCHIVE_FOLDER}/iTunesArtwork" "${PAYLOAD_FOLDER}"

          open "${ARCHIVE_FOLDER}"
      }

      function archive_dsym_iphoneos()
      {
        case ${CONFIGURATION} in
         *Distribution*) : ;;
         *)         return ;;
        esac

          ARCHIVE_ROOT="${HOME}/projects/dSYMArchive/${PROJECT_NAME}"
          ARCHIVE_DATE=`date +"%Y%m%d-%H%M%S"`

          echo "Archiving ${CONFIGURATION} in ${ARCHIVE_ROOT} at ${ARCHIVE_DATE}" >> /tmp/archive_dsym.out

          ARCHIVE_CONFIG_FOLDER="${ARCHIVE_ROOT}/${CONFIGURATION}"
          mkdir -p -v "${ARCHIVE_CONFIG_FOLDER}" >> /tmp/archive_dsym.out
          ARCHIVE_FOLDER="${ARCHIVE_CONFIG_FOLDER}/${ARCHIVE_DATE}"
          echo "Copying ${DWARF_DSYM_FOLDER_PATH} to ${ARCHIVE_FOLDER}" >> /tmp/archive_dsym.out
          cp -Rp ${DWARF_DSYM_FOLDER_PATH} ${ARCHIVE_FOLDER} >> /tmp/archive_dsym.out

          case ${CONFIGURATION} in
           *[Bb]eta*) prepare_adhoc_package "${1}" ;;
           *)      return ;;
          esac
      }

      case @${SDK_NAME} in
       @iphoneos*) archive_dsym_iphoneos "${1}" ;;
       @*)      : ;;
       @)       echo "Not running under Xcode." ;;
      esac
My script…
        #!/bin/bash

        function prepare_adhoc_package()
        {
          if [ ${#} -eq 1 ]; then
            BASE_NAME="${1}"
          else
            BASE_NAME="${PROJECT}"
          fi

            PAYLOAD_FOLDER="${ARCHIVE_FOLDER}/Payload"
            mkdir -p "${PAYLOAD_FOLDER}"

            if [ -d "${ARCHIVE_FOLDER}/${BASE_NAME}.app" ]; then
              cp -rp "${ARCHIVE_FOLDER}/${BASE_NAME}.app" "${PAYLOAD_FOLDER}"
              cp "${ARCHIVE_FOLDER}/${BASE_NAME}.app/iTunesArtwork" "${ARCHIVE_FOLDER}"
              (cd "${ARCHIVE_FOLDER}"; zip -qr "${BASE_NAME}.ipa" iTunesArtwork Payload)
            else
              for app in "${ARCHIVE_FOLDER}/*.app"; do
                cp -rp "${app}" "${PAYLOAD_FOLDER}"




 You can read that, can’t you?
                cp -rp "${app}/iTunesArtwork" "${ARCHIVE_FOLDER}"
              done

             (cd "${ARCHIVE_FOLDER}"; zip -qr "${BASE_NAME}.ipa" iTunesArtwork Payload)
            fi

            rm -rf "${ARCHIVE_FOLDER}/iTunesArtwork" "${PAYLOAD_FOLDER}"

            open "${ARCHIVE_FOLDER}"
        }

        function archive_dsym_iphoneos()
        {
          case ${CONFIGURATION} in
           *Distribution*) : ;;
           *)         return ;;
          esac

            ARCHIVE_ROOT="${HOME}/projects/dSYMArchive/${PROJECT_NAME}"
            ARCHIVE_DATE=`date +"%Y%m%d-%H%M%S"`

            echo "Archiving ${CONFIGURATION} in ${ARCHIVE_ROOT} at ${ARCHIVE_DATE}" >> /tmp/archive_dsym.out

            ARCHIVE_CONFIG_FOLDER="${ARCHIVE_ROOT}/${CONFIGURATION}"
            mkdir -p -v "${ARCHIVE_CONFIG_FOLDER}" >> /tmp/archive_dsym.out
            ARCHIVE_FOLDER="${ARCHIVE_CONFIG_FOLDER}/${ARCHIVE_DATE}"
            echo "Copying ${DWARF_DSYM_FOLDER_PATH} to ${ARCHIVE_FOLDER}" >> /tmp/archive_dsym.out
            cp -Rp ${DWARF_DSYM_FOLDER_PATH} ${ARCHIVE_FOLDER} >> /tmp/archive_dsym.out

            case ${CONFIGURATION} in
             *[Bb]eta*) prepare_adhoc_package "${1}" ;;
             *)      return ;;
            esac
        }

        case @${SDK_NAME} in
         @iphoneos*) archive_dsym_iphoneos "${1}" ;;
         @*)      : ;;
         @)       echo "Not running under Xcode." ;;
        esac
dsym-archiver

http://github.com/halostatue/
dsym-archiver

Main features:

  Build adhoc packages.

  Archives dSYM bundles.
One gotcha…
Should be done on every
releasable build.

Needs to run after code signing
for an ad-hoc package to be
usable.

Create a wrapper project; make
the original iPhone target a
dependent project.

Add a custom build step that
runs dsym-archiver at the end.
4. git Build Stamps
              Good idea to have build
              stamps in CFBundleVersion
              for error reporting.

                svn uses repository
                revision number

                Updated on every check-
                in.

              git doesn’t have a repository
              revision number.
CIMGF to the Rescue?
Marcus Zarra wrote a Perl
script to use the short git
commit sharef in April
2008.

  Uses regex replacement.

  Released before the
  iPhone SDK.

  I prefer Ruby.
My Rewrite

Rewrote the basic script to
use Ruby with RubyCocoa.

   I’m too lazy to compile
   MacRuby.

Info.plist loaded with
dictionaryWithContentsOfFile.


Formalized a version class.
iTunes Connect‽
The git SHA reference has
problems on iPhone
projects:

  Non-contiguous,
  confuses iTunes old/new
  for ad hoc builds.

  iTunes Connect wants
  only incrementing dotted
  integers.
git Tags
 git doesn’t have
 incrementing revisions

 We can fake it with tags on
 the commits.

   Downside is that
   repeated builds on the
   same commit means a lot
   of tags.
build-number.rb (1/2)

   #!/usr/bin/ruby

   require 'osx/cocoa'
   …

   # Full implementation at http://github.com/halostatue/xcode-git-version/
   class ProgramVersion
    attr_accessor :major, :minor, :patch, :build, :ref, :ref_type
    def <=>(other); …; end
    def self.parse_version(version_string); …; end
    def short_version; …; end
    def long_version; …; end
    def increment_build!; …; end
   end
build-number.rb (2/2)
   # Load the plist
   info_plist = OSX::NSDictionary.dictionaryWithContentsOfFile(path).mutableCopy
   # Get the current HEAD
   current_head = %x(git describe --always).chomp
   # Get the list of build tags and turn them into version numbers.
   build_tags = `git tag -l build-* --contains #{current_head}`.chomp.split($/)
   build_tags.map! { |tag| ProgramVersion.parse_version(tag.sub(/^build-/, '')) }

   # Get the CFBundleVersion from the plist.
   old_version = ProgramVersion.parse_version(info_plist['CFBundleVersion'])
   # Add the old version to the list of build tags.
   build_tags << old_version.dup
   # Get the largest version we know about for this head.
   new_version = build_tags.max
   # Increment the build number
   new_version.increment_build!

   puts "Version modified: #{old_version} -> #{new_version}"

   # Set the long version (M.m.p.b)
   info_plist['CFBundleVersion'] = new_version.long_version
   # Set the short version (M.m or M.m.p).
   info_plist['CFBundleShortVersionString'] = new_version.short_version
   # Write the file.
   info_plist.writeToFile_atomically(path, 1)
   # Tag the version
   `git tag build-#{new_version.long_version}`

More Related Content

What's hot

Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony TechniquesKris Wallsmith
 
The State of Lithium
The State of LithiumThe State of Lithium
The State of LithiumNate Abele
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Kris Wallsmith
 
The Origin of Lithium
The Origin of LithiumThe Origin of Lithium
The Origin of LithiumNate Abele
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Kris Wallsmith
 
What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?Alexandru Badiu
 
Introduction to the Pods JSON API
Introduction to the Pods JSON APIIntroduction to the Pods JSON API
Introduction to the Pods JSON APIpodsframework
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksNate Abele
 
Undercover Pods / WP Functions
Undercover Pods / WP FunctionsUndercover Pods / WP Functions
Undercover Pods / WP Functionspodsframework
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Developmentjsmith92
 
Legacy applications - 4Developes konferencja, Piotr Pasich
Legacy applications  - 4Developes konferencja, Piotr PasichLegacy applications  - 4Developes konferencja, Piotr Pasich
Legacy applications - 4Developes konferencja, Piotr PasichPiotr Pasich
 
Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8XSolve
 
Doctrine fixtures
Doctrine fixturesDoctrine fixtures
Doctrine fixturesBill Chang
 
Symfony without the framework
Symfony without the frameworkSymfony without the framework
Symfony without the frameworkGOG.com dev team
 

What's hot (20)

Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
The State of Lithium
The State of LithiumThe State of Lithium
The State of Lithium
 
Lithium Best
Lithium Best Lithium Best
Lithium Best
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
 
The Origin of Lithium
The Origin of LithiumThe Origin of Lithium
The Origin of Lithium
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)
 
What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?
 
Introduction to the Pods JSON API
Introduction to the Pods JSON APIIntroduction to the Pods JSON API
Introduction to the Pods JSON API
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate Frameworks
 
Undercover Pods / WP Functions
Undercover Pods / WP FunctionsUndercover Pods / WP Functions
Undercover Pods / WP Functions
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Development
 
Legacy applications - 4Developes konferencja, Piotr Pasich
Legacy applications  - 4Developes konferencja, Piotr PasichLegacy applications  - 4Developes konferencja, Piotr Pasich
Legacy applications - 4Developes konferencja, Piotr Pasich
 
Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8
 
Doctrine fixtures
Doctrine fixturesDoctrine fixtures
Doctrine fixtures
 
Perl Web Client
Perl Web ClientPerl Web Client
Perl Web Client
 
Symfony without the framework
Symfony without the frameworkSymfony without the framework
Symfony without the framework
 
Nubilus Perl
Nubilus PerlNubilus Perl
Nubilus Perl
 
this
thisthis
this
 
Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3
 

Similar to solving little problems

Writing Maintainable JavaScript
Writing Maintainable JavaScriptWriting Maintainable JavaScript
Writing Maintainable JavaScriptAndrew Dupont
 
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...DynamicInfraDays
 
Introduction To Moco
Introduction To MocoIntroduction To Moco
Introduction To MocoNaoya Ito
 
I Phone On Rails
I Phone On RailsI Phone On Rails
I Phone On RailsJohn Wilker
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkBen Scofield
 
Terrastore - A document database for developers
Terrastore - A document database for developersTerrastore - A document database for developers
Terrastore - A document database for developersSergio Bossa
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony AppsKris Wallsmith
 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappersPositive Hack Days
 
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for PerformanceMeet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for PerformanceIvan Chepurnyi
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For BeginnersJonathan Wage
 
Windows Azure Storage & Sql Azure
Windows Azure Storage & Sql AzureWindows Azure Storage & Sql Azure
Windows Azure Storage & Sql AzureMaarten Balliauw
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers StealBen Scofield
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesSiarhei Barysiuk
 

Similar to solving little problems (20)

Writing Maintainable JavaScript
Writing Maintainable JavaScriptWriting Maintainable JavaScript
Writing Maintainable JavaScript
 
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
 
Introduction To Moco
Introduction To MocoIntroduction To Moco
Introduction To Moco
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
 
I Phone On Rails
I Phone On RailsI Phone On Rails
I Phone On Rails
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
 
Terrastore - A document database for developers
Terrastore - A document database for developersTerrastore - A document database for developers
Terrastore - A document database for developers
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony Apps
 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappers
 
Doctrine and NoSQL
Doctrine and NoSQLDoctrine and NoSQL
Doctrine and NoSQL
 
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for PerformanceMeet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
 
Ant
AntAnt
Ant
 
DrupalCon jQuery
DrupalCon jQueryDrupalCon jQuery
DrupalCon jQuery
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Windows Azure Storage & Sql Azure
Windows Azure Storage & Sql AzureWindows Azure Storage & Sql Azure
Windows Azure Storage & Sql Azure
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers Steal
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
 

Recently uploaded

The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 

Recently uploaded (20)

The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 

solving little problems

  • 2. My First iPhone App On contract… for non-developer… who wants to use his own developer account. Presents some challenges. Only my second Objective-C program… what can I learn?
  • 3. Huh? On app store now (yay!). Simple idea—audio translation of silly phrases. Moderate dataset (4 languages, 202 phrases, 808 audio files). May expand later with StoreKit.
  • 4. Four Things Core Data Slow Startup and Progress Debug Archiving Build Numbering with git
  • 5. 1. Core Data Used for language/phrase reference information for easy update. Slightly confusing since I know SQL well. Lots of work to set up queries. Matt Gallagher (Cocoa with Love) showed code that helps.
  • 6. Core Data: one line fetch I adopted and extended this code as a category now on GitHub: github.com/halostatue/ coredata-easyfetch
  • 7. Apple’s Example NSManagedObjectContext *moc = [self managedObjectContext]; NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Employee" inManagedObjectContext:moc]; NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; [request setEntity:entityDescription]; // Set example predicate and sort orderings... NSNumber *minimumSalary = ...; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(lastName LIKE[c] 'Worsley') AND (salary > %@)", minimumSalary]; [request setPredicate:predicate]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"firstName" ascending:YES]; [request setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]]; [sortDescriptor release]; NSError *error = nil; NSArray *array = [moc executeFetchRequest:request error:&error]; if (array == nil) { // Deal with error... }
  • 8. Apple’s Example NSManagedObjectContext *moc = [self managedObjectContext]; NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Employee" inManagedObjectContext:moc]; 12+ NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; [request setEntity:entityDescription]; // Set example predicate and sort orderings... NSNumber *minimumSalary = ...; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(lastName LIKE[c] 'Worsley') AND (salary > %@)", minimumSalary]; [request setPredicate:predicate]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"firstName" ascending:YES]; Statements! [request setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]]; [sortDescriptor release]; NSError *error = nil; NSArray *array = [moc executeFetchRequest:request error:&error]; if (array == nil) { // Deal with error... }
  • 9. Matt’s Example [[self managedObjectContext] fetchObjectsForEntityName:@"Employee" withPredicate:@"(lastName LIKE[c] 'Worsley') AND (salary > %@)", minimumSalary]; 1 Statement!
  • 10. coredata-easyfetch #import “NSManagedObjectContext-EasyFetch.h” … [[self managedObjectContext] fetchObjectsForEntityName:@"Employee" predicateWithFormat:@"(lastName LIKE[c] 'Worsley') AND (salary > %@)", minimumSalary]; Made a category so it’s easy All objects, unsorted (1) to reuse. All objects, sorted (2) Refactored easy filtering. Some objects, unsorted (2) Added easy sorting. Some objects, sorted (4)
  • 11. How I Use It + (NSMutableArray*)fetchAllFromManagedObjectContext:(NSManagedObjectContext*)moc { return [[[moc fetchObjectsForEntityName:@"DataVersion"] mutableCopy] autorelease]; } + (NSMutableArray*)fetchAllFromManagedObjectContext:(NSManagedObjectContext*)moc { NSArray* fetched = [moc fetchObjectsForEntityName:@"Language"]; NSMutableArray* result = [fetched mutableCopy]; [result release]; return result; } + (NSMutableArray*)fetchAllFromManagedObjectContext:(NSManagedObjectContext*)moc { NSArray* fetched = [moc fetchObjectsForEntityName:@"Phrase" sortByKey:@"phraseId" ascending:YES]; NSMutableArray* result = [fetched mutableCopy]; [result release]; return result; }
  • 12. 2. Progress Original plan: Copy all media files from bundle to document area. Problem: Slow (~20–30 seconds) Solution: Show a progress monitor.
  • 14. MBProgressHUD Created in April 2009 Matej Bukovinski http://github.com/matej/ MBProgressHUD/ Other options exist, such as DSActivityView http://www.dejal.com/ developer/dsactivityview
  • 15. Beautiful, but… …the progress HUD blocked the application logo …immediately on launch. Request: Move the HUD to a different spot, and don’t show it unless the work takes 2 seconds or more.
  • 16. Easy enough… Added x- and y-offsets Added a delay-before-showing Later changed by Matej to be a “grace time” Pushed back to master and MBProgressHUD is reasonably active for a little project. My version is at github.com/ halostatue/MBProgressHUD
  • 17. 3. Save the dSYM Had crashes on the client’s iPhone that I couldn’t reproduce. Hadn’t been saving my dSYM bundles…so I couldn’t symbolicate the logs.
  • 19. Again, with feeling… Craig Hockenberry: http://furbo.org/2008/08/08/ symbolicatifination/ Crash logs have address offsets; if you have the dSYM bundles, you can “symbolicate” to restore method names.
  • 20. Simple script… # http://furbo.org/stuff/dSYM_Archive.txt ARCHIVE_ROOT="$PROJECT_DIR/dSYM_Archive" if [ $SDK_NAME = "iphoneos2.0" ]; then echo "Archiving $CONFIGURATION in $ARCHIVE_ROOT at `date`" >> /tmp/dSYM_Archive.out if [ $CONFIGURATION = "Distribution-Free" -o $CONFIGURATION = "Distribution-Paid" -o $CONFIGURATION = "Distribution-Beta-Free" ]; then ARCHIVE_CONFIG_FOLDER="$ARCHIVE_ROOT/$CONFIGURATION" mkdir -p -v "$ARCHIVE_CONFIG_FOLDER" >> /tmp/dSYM_Archive.out ARCHIVE_FOLDER="$ARCHIVE_CONFIG_FOLDER/`date "+%Y-%m-%d-%H%M%S"`" echo "Copying $DWARF_DSYM_FOLDER_PATH to $ARCHIVE_FOLDER" >> /tmp/dSYM_Archive.out cp -R $DWARF_DSYM_FOLDER_PATH $ARCHIVE_FOLDER >> /tmp/dSYM_Archive.out fi fi
  • 21. My script… #!/bin/bash function prepare_adhoc_package() { if [ ${#} -eq 1 ]; then BASE_NAME="${1}" else BASE_NAME="${PROJECT}" fi PAYLOAD_FOLDER="${ARCHIVE_FOLDER}/Payload" mkdir -p "${PAYLOAD_FOLDER}" if [ -d "${ARCHIVE_FOLDER}/${BASE_NAME}.app" ]; then cp -rp "${ARCHIVE_FOLDER}/${BASE_NAME}.app" "${PAYLOAD_FOLDER}" cp "${ARCHIVE_FOLDER}/${BASE_NAME}.app/iTunesArtwork" "${ARCHIVE_FOLDER}" (cd "${ARCHIVE_FOLDER}"; zip -qr "${BASE_NAME}.ipa" iTunesArtwork Payload) else for app in "${ARCHIVE_FOLDER}/*.app"; do cp -rp "${app}" "${PAYLOAD_FOLDER}" cp -rp "${app}/iTunesArtwork" "${ARCHIVE_FOLDER}" done (cd "${ARCHIVE_FOLDER}"; zip -qr "${BASE_NAME}.ipa" iTunesArtwork Payload) fi rm -rf "${ARCHIVE_FOLDER}/iTunesArtwork" "${PAYLOAD_FOLDER}" open "${ARCHIVE_FOLDER}" } function archive_dsym_iphoneos() { case ${CONFIGURATION} in *Distribution*) : ;; *) return ;; esac ARCHIVE_ROOT="${HOME}/projects/dSYMArchive/${PROJECT_NAME}" ARCHIVE_DATE=`date +"%Y%m%d-%H%M%S"` echo "Archiving ${CONFIGURATION} in ${ARCHIVE_ROOT} at ${ARCHIVE_DATE}" >> /tmp/archive_dsym.out ARCHIVE_CONFIG_FOLDER="${ARCHIVE_ROOT}/${CONFIGURATION}" mkdir -p -v "${ARCHIVE_CONFIG_FOLDER}" >> /tmp/archive_dsym.out ARCHIVE_FOLDER="${ARCHIVE_CONFIG_FOLDER}/${ARCHIVE_DATE}" echo "Copying ${DWARF_DSYM_FOLDER_PATH} to ${ARCHIVE_FOLDER}" >> /tmp/archive_dsym.out cp -Rp ${DWARF_DSYM_FOLDER_PATH} ${ARCHIVE_FOLDER} >> /tmp/archive_dsym.out case ${CONFIGURATION} in *[Bb]eta*) prepare_adhoc_package "${1}" ;; *) return ;; esac } case @${SDK_NAME} in @iphoneos*) archive_dsym_iphoneos "${1}" ;; @*) : ;; @) echo "Not running under Xcode." ;; esac
  • 22. My script… #!/bin/bash function prepare_adhoc_package() { if [ ${#} -eq 1 ]; then BASE_NAME="${1}" else BASE_NAME="${PROJECT}" fi PAYLOAD_FOLDER="${ARCHIVE_FOLDER}/Payload" mkdir -p "${PAYLOAD_FOLDER}" if [ -d "${ARCHIVE_FOLDER}/${BASE_NAME}.app" ]; then cp -rp "${ARCHIVE_FOLDER}/${BASE_NAME}.app" "${PAYLOAD_FOLDER}" cp "${ARCHIVE_FOLDER}/${BASE_NAME}.app/iTunesArtwork" "${ARCHIVE_FOLDER}" (cd "${ARCHIVE_FOLDER}"; zip -qr "${BASE_NAME}.ipa" iTunesArtwork Payload) else for app in "${ARCHIVE_FOLDER}/*.app"; do cp -rp "${app}" "${PAYLOAD_FOLDER}" You can read that, can’t you? cp -rp "${app}/iTunesArtwork" "${ARCHIVE_FOLDER}" done (cd "${ARCHIVE_FOLDER}"; zip -qr "${BASE_NAME}.ipa" iTunesArtwork Payload) fi rm -rf "${ARCHIVE_FOLDER}/iTunesArtwork" "${PAYLOAD_FOLDER}" open "${ARCHIVE_FOLDER}" } function archive_dsym_iphoneos() { case ${CONFIGURATION} in *Distribution*) : ;; *) return ;; esac ARCHIVE_ROOT="${HOME}/projects/dSYMArchive/${PROJECT_NAME}" ARCHIVE_DATE=`date +"%Y%m%d-%H%M%S"` echo "Archiving ${CONFIGURATION} in ${ARCHIVE_ROOT} at ${ARCHIVE_DATE}" >> /tmp/archive_dsym.out ARCHIVE_CONFIG_FOLDER="${ARCHIVE_ROOT}/${CONFIGURATION}" mkdir -p -v "${ARCHIVE_CONFIG_FOLDER}" >> /tmp/archive_dsym.out ARCHIVE_FOLDER="${ARCHIVE_CONFIG_FOLDER}/${ARCHIVE_DATE}" echo "Copying ${DWARF_DSYM_FOLDER_PATH} to ${ARCHIVE_FOLDER}" >> /tmp/archive_dsym.out cp -Rp ${DWARF_DSYM_FOLDER_PATH} ${ARCHIVE_FOLDER} >> /tmp/archive_dsym.out case ${CONFIGURATION} in *[Bb]eta*) prepare_adhoc_package "${1}" ;; *) return ;; esac } case @${SDK_NAME} in @iphoneos*) archive_dsym_iphoneos "${1}" ;; @*) : ;; @) echo "Not running under Xcode." ;; esac
  • 23. dsym-archiver http://github.com/halostatue/ dsym-archiver Main features: Build adhoc packages. Archives dSYM bundles.
  • 24. One gotcha… Should be done on every releasable build. Needs to run after code signing for an ad-hoc package to be usable. Create a wrapper project; make the original iPhone target a dependent project. Add a custom build step that runs dsym-archiver at the end.
  • 25. 4. git Build Stamps Good idea to have build stamps in CFBundleVersion for error reporting. svn uses repository revision number Updated on every check- in. git doesn’t have a repository revision number.
  • 26. CIMGF to the Rescue? Marcus Zarra wrote a Perl script to use the short git commit sharef in April 2008. Uses regex replacement. Released before the iPhone SDK. I prefer Ruby.
  • 27. My Rewrite Rewrote the basic script to use Ruby with RubyCocoa. I’m too lazy to compile MacRuby. Info.plist loaded with dictionaryWithContentsOfFile. Formalized a version class.
  • 28. iTunes Connect‽ The git SHA reference has problems on iPhone projects: Non-contiguous, confuses iTunes old/new for ad hoc builds. iTunes Connect wants only incrementing dotted integers.
  • 29. git Tags git doesn’t have incrementing revisions We can fake it with tags on the commits. Downside is that repeated builds on the same commit means a lot of tags.
  • 30. build-number.rb (1/2) #!/usr/bin/ruby require 'osx/cocoa' … # Full implementation at http://github.com/halostatue/xcode-git-version/ class ProgramVersion attr_accessor :major, :minor, :patch, :build, :ref, :ref_type def <=>(other); …; end def self.parse_version(version_string); …; end def short_version; …; end def long_version; …; end def increment_build!; …; end end
  • 31. build-number.rb (2/2) # Load the plist info_plist = OSX::NSDictionary.dictionaryWithContentsOfFile(path).mutableCopy # Get the current HEAD current_head = %x(git describe --always).chomp # Get the list of build tags and turn them into version numbers. build_tags = `git tag -l build-* --contains #{current_head}`.chomp.split($/) build_tags.map! { |tag| ProgramVersion.parse_version(tag.sub(/^build-/, '')) } # Get the CFBundleVersion from the plist. old_version = ProgramVersion.parse_version(info_plist['CFBundleVersion']) # Add the old version to the list of build tags. build_tags << old_version.dup # Get the largest version we know about for this head. new_version = build_tags.max # Increment the build number new_version.increment_build! puts "Version modified: #{old_version} -> #{new_version}" # Set the long version (M.m.p.b) info_plist['CFBundleVersion'] = new_version.long_version # Set the short version (M.m or M.m.p). info_plist['CFBundleShortVersionString'] = new_version.short_version # Write the file. info_plist.writeToFile_atomically(path, 1) # Tag the version `git tag build-#{new_version.long_version}`

Editor's Notes

  1. This past October and November, I developed my first production iPhone app. I developed it on contract for a non-developer designer who wanted to use his own developer account. This obviously presents some challenges. It&amp;#x2019;s also only my second Objective-C program. So, what can I learn while I&amp;#x2019;m doing this?
  2. http://cocoawithlove.com/2008/03/core-data-one-line-fetch.html
  3. http://cocoawithlove.com/2008/03/core-data-one-line-fetch.html