Deploying MacRuby
How to do it the Apple Way




                             Thilo Utke - RailsWayCon 2010
HI, I’M THILO!
Outline
 Intro

 MacRuby

 MacRuby 0.5 - 0.6 The last year

 Using MacRuby

 Build

 Embed

 Pack

 Updates

 Bonus
HI, I’M THILO!
UPSTREAM

Our Company: http://upste.am
Twitter: @upstream_agile
Our Coworking Space: http://co-up.de or http://coup.cobot.me
Twitter: @co_up
I Love
I like the Software
Don’t Like Obj-C
First Objective-C App
   @interface Foo : NSObject
   {
     IBOutlet NSTextField *textField;
   }

   - (IBAction)gerneat...
Thats why I love: MacRuby
First Objective-C App
   class Foo
   ! attr_writer :text_field
   !
   ! def seed(sender)
   ! ! @text_field.StringValue ...
MacRuby?




 Ruby’s first class
citizenship on OSX
MacRuby give access to most frameworks on OSX Plattform
MacRuby?




          Replaces RubyCocoa which is
            already gone from XCode



RubyCocoa was included before
MacRuby 0.5

  App       Std Lib
                                 Frameworks
     Ruby Code

                             ...
MacRuby 0.5
         Object => NSObject
         Ruby specific extensions
  App        Std Lib
                            ...
MacRuby 0.5
           Generate Obj-C calls for Ruby code
           Intermediate Representation (IR)
  App       Std Lib
...
MacRuby 0.5
                       One runtime
           App         One Lib
                       Std object space
    ...
MacRuby 0.5




This Was basically MacRuby 0.5
MacRuby 0.6




Current 0.6 is considered stable for Cocoa development
MacRuby 0.5 -> 0.6



       DEBUGGER:
       macrubyd




Usable like gnu debugger.
MacRuby 0.5 -> 0.6



       XCODE:
       Integration Improved




New Templates
Target to RunTests/Compile/Embed
MacRuby 0.5 -> 0.6



        Primitives:
        Refactoring
                             Hash.ancestors
                ...
MacRuby 0.5 -> 0.6



        Improved API for
        Grand Central Dispatch




Job queue
Proxies
Parallelisation extens...
MacRuby 0.5 -> 0.6


       Better support for
       MRI C-Extensions

                              <nokogiri/>



eg. N...
MacRuby 0.5 -> 0.6


       ICU for Strings
       and RegEx
                                           !"! #$% &'()**+,+ ...
MacRuby 0.5 -> 0.6



        Got slower:




Performance will be a focus for the 0.7 release with a new VM and compiler
That was what changed from 0.5 to 0.6
Using MacRuby




short overview over functional and language extensions
Using Frameworks
    #import <Cocoa/Cocoa.h>

framework 'Cocoa'
 
 
Calling Obj-C Methods
       [dog makeNoise:@”wuff” level:6];

   dog.makeNoise “wuff”, level:6

   dog.makeNoise “wuff”, ...
Defining Methods for Obj-C
   - (id) makeNoise:(NSString)noise
   level:(NSInteger)level;

   def makeNoise(noise, level:le...
Using Structs
       NSPoint(0,1)

   NSpoint.new(0,1)
    




Like they are Objects
Pointer
       NSError* error;

   //MacRuby 0.5
   error = Pointer.new(:object)
    




As a means of an output paramete...
alloc & init

[[NSMutableArray alloc] init]

Array.alloc.init

Array.new

Array.arrayWithArray [1]
Build
       Embed MacRuby
       Packing
       Deliver Updates




Tasks ahead
Build




Click in XCode
Build
   your_project$ xcodebuild -configuration Release
   -target IntegrityX




Command line is better.
Build   ^o^/


EASY
Embed




- Meaning copying MacRubyFramework inside the application Bundle
- Updating file references to point inside the a...
Embed
   your_project$ macruby_deploy --embed build/
   release/IntegrityX.app




Helpfull script.
This is basicly the sa...
MacRubyFramework ~ 60MB




                                 By Sergei Golyshev http://www.flickr.com/photos/29225114@N08/3...
Embed without Ruby StdLib
   your_project$ macruby_deploy --embed --no-stdlib
   build/release/IntegrityX.app
   your_proj...
MacRubyFramework
                   without StdLib
                      ~36 MB




Only Framework
Embed without Ruby StdLib




can easily add this options to your embed target in XCode
Embed                                0_0



       Customers don’t require MacRuby
       Big Bundle even without StdLib
 ...
Pack




No support from XCode
Pack
   your_project$ hdiutil create -srcfolder release/
   IntegrityX.app IntegrityX.dmg




This skript is a very basic ...
Pack: DMG

Is a:
RAW Disk Image
Offers:
Compression, Encryption, Meta Data
Used for:
Apple Software Distribution
FileVault
Pack: DMG Shell Script
   set -ex

   dir="$TEMP_FILES_DIR/disk"
   dmg="$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg"

   rm -rf...
Packing in Xcode
Pack                            (@_@)



DMG
Creation easy scriptable
No initial support from XCode
Ready for distribution   ($_$)




and earn you money ;)
Updates
Updates: Sparkle




OpenSource Update Framework
Updates: AppCast
 Podcasting Feed for your App
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="..." xmlns:sparkle=...
Adding Sparkle
     1.Add Sparkle Framework to App Bundle
     2.Add Check for Update Option
     3.Generate Key Pair for ...
In the original presentation was a video here to show
how to setup Sparkle but you can follow the
instructions in this art...
Release with Sparkle
1.Create Signature for your App Bundle
2.Create AppCastFeed with current Signature
3.Add Release Note...
Updates                0_0/


Add SparkleFramework
Sign App Bundle
Publish with AppCast
Grand Finale


  ChocTop
ChocTop
 All you need at your command line


rake   build                #   Build Xcode Release
rake   dmg               ...
ChocTop
           Offers Custom DMG with Positioning




Doing this with Apple Script (requiers original apple ruby as it...
ChocTop
Thanks


Start: macruby.org


Help: MacRuby-devel on MacOSForge
Twitter: @MacRuby
Resources
ChocTop and Logo Dr. Nic William http://drnic.github.com/choctop/

Macruby and Logo http://macruby.org

Framewor...
Mac ruby deployment
Mac ruby deployment
Mac ruby deployment
Upcoming SlideShare
Loading in …5
×

Mac ruby deployment

4,524 views

Published on

The talk focuses on the processes and requirements to ship a software, which was written with MacRuby, to the end user. I present libraries and tools, that are helpful for this purpose and show how to use them.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,524
On SlideShare
0
From Embeds
0
Number of Embeds
40
Actions
Shares
0
Downloads
18
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Mac ruby deployment

  1. Deploying MacRuby How to do it the Apple Way Thilo Utke - RailsWayCon 2010
  2. HI, I’M THILO!
  3. Outline Intro MacRuby MacRuby 0.5 - 0.6 The last year Using MacRuby Build Embed Pack Updates Bonus
  4. HI, I’M THILO!
  5. UPSTREAM Our Company: http://upste.am Twitter: @upstream_agile
  6. Our Coworking Space: http://co-up.de or http://coup.cobot.me Twitter: @co_up
  7. I Love
  8. I like the Software
  9. Don’t Like Obj-C
  10. First Objective-C App @interface Foo : NSObject { IBOutlet NSTextField *textField; } - (IBAction)gerneate:(id)sender; - (IBAction)seed:(id)sender; @end @impelemtation Foo - (IBAction)generate:(id)sender { int generated = (random() % 100) +1; [textField setIntValue:generated]; } - (IBAction)seed:(id)sender { srandom(time(NULL)); [textField setStringValue:@"Generator seeded"]; } Headerfiles Types Many Bracets Semicolon
  11. Thats why I love: MacRuby
  12. First Objective-C App class Foo ! attr_writer :text_field ! ! def seed(sender) ! ! @text_field.StringValue = "Generator doesn't need to be seeded ;)" ! end ! ! def generate(sender) ! ! @text_field.StringValue = (rand(100) + 1) ! end end Ruby => Less Noise
  13. MacRuby? Ruby’s first class citizenship on OSX
  14. MacRuby give access to most frameworks on OSX Plattform
  15. MacRuby? Replaces RubyCocoa which is already gone from XCode RubyCocoa was included before
  16. MacRuby 0.5 App Std Lib Frameworks Ruby Code Obj-C LLVM JIT/AOT GC IO GCC Obj-C Runtime
  17. MacRuby 0.5 Object => NSObject Ruby specific extensions App Std Lib Frameworks Ruby Code Obj-C LLVM Primitives On Obj-C JIT/AOT GC IO GCC Obj-C Runtime
  18. MacRuby 0.5 Generate Obj-C calls for Ruby code Intermediate Representation (IR) App Std Lib Optimization Frameworks Ruby Code JIT compiler to execute code GCC LLVM faster than 1.9 JIT/AOT GC IO LLVM Ahead of Time Compiler Obj-C Runtime
  19. MacRuby 0.5 One runtime App One Lib Std object space Frameworks Shared infrastructure Ruby Code Multithreaded Obj-C LLVM JIT/AOT GC IO GCC Obj-C Runtime NO GIL! Access to GCD
  20. MacRuby 0.5 This Was basically MacRuby 0.5
  21. MacRuby 0.6 Current 0.6 is considered stable for Cocoa development
  22. MacRuby 0.5 -> 0.6 DEBUGGER: macrubyd Usable like gnu debugger.
  23. MacRuby 0.5 -> 0.6 XCODE: Integration Improved New Templates Target to RunTests/Compile/Embed
  24. MacRuby 0.5 -> 0.6 Primitives: Refactoring Hash.ancestors => [Hash, NSMutableDictionary, NSDictionary, Enumerable, NSObject, Kernel] String.ancestors => [String, NSMutableString, NSString, Comparable, NSObject, Kernel] New Ruby primitives are sub classes instead of aliases plus extensions.
  25. MacRuby 0.5 -> 0.6 Improved API for Grand Central Dispatch Job queue Proxies Parallelisation extensions on Enumerable
  26. MacRuby 0.5 -> 0.6 Better support for MRI C-Extensions <nokogiri/> eg. NokoGiri and Postgresql
  27. MacRuby 0.5 -> 0.6 ICU for Strings and RegEx !"! #$% &'()**+,+ +(-.&'(/ 0 (.,)$%(*1. 21(/3.*0% Threadsafe and Multibyte Char handling for your encoding pleasure.
  28. MacRuby 0.5 -> 0.6 Got slower: Performance will be a focus for the 0.7 release with a new VM and compiler
  29. That was what changed from 0.5 to 0.6
  30. Using MacRuby short overview over functional and language extensions
  31. Using Frameworks #import <Cocoa/Cocoa.h> framework 'Cocoa'    
  32. Calling Obj-C Methods [dog makeNoise:@”wuff” level:6]; dog.makeNoise “wuff”, level:6 dog.makeNoise “wuff”, :level => 6     No Colon -> No parameter
  33. Defining Methods for Obj-C - (id) makeNoise:(NSString)noise level:(NSInteger)level; def makeNoise(noise, level:level)   Obj-C style methods mostly need for Delegates
  34. Using Structs NSPoint(0,1) NSpoint.new(0,1)   Like they are Objects
  35. Pointer NSError* error; //MacRuby 0.5 error = Pointer.new(:object)   As a means of an output parameter, mostly for error handling
  36. alloc & init [[NSMutableArray alloc] init] Array.alloc.init Array.new Array.arrayWithArray [1]
  37. Build Embed MacRuby Packing Deliver Updates Tasks ahead
  38. Build Click in XCode
  39. Build your_project$ xcodebuild -configuration Release -target IntegrityX Command line is better.
  40. Build ^o^/ EASY
  41. Embed - Meaning copying MacRubyFramework inside the application Bundle - Updating file references to point inside the app. Bundle
  42. Embed your_project$ macruby_deploy --embed build/ release/IntegrityX.app Helpfull script. This is basicly the same what the embed target in XCode does
  43. MacRubyFramework ~ 60MB By Sergei Golyshev http://www.flickr.com/photos/29225114@N08/3112939993/ CC Only Framework, no Gems, they will be excluded
  44. Embed without Ruby StdLib your_project$ macruby_deploy --embed --no-stdlib build/release/IntegrityX.app your_project$ macruby_deploy --embed --stdlib yml build/release/IntegrityX.app --no-stdlib will remove the entire std lib from the framework, eg. FileUtils, Net, openssl, zlib, yml. -> Not a big problem we have the Cocoa libs but they aren’t as nice to use as the stdlib ones. --stlib can embed single stdlibs only
  45. MacRubyFramework without StdLib ~36 MB Only Framework
  46. Embed without Ruby StdLib can easily add this options to your embed target in XCode
  47. Embed 0_0 Customers don’t require MacRuby Big Bundle even without StdLib No Gems yet Lets Move on to Packing
  48. Pack No support from XCode
  49. Pack your_project$ hdiutil create -srcfolder release/ IntegrityX.app IntegrityX.dmg This skript is a very basic version to create a dmg.
  50. Pack: DMG Is a: RAW Disk Image Offers: Compression, Encryption, Meta Data Used for: Apple Software Distribution FileVault
  51. Pack: DMG Shell Script set -ex dir="$TEMP_FILES_DIR/disk" dmg="$BUILT_PRODUCTS_DIR/$PROJECT_NAME.dmg" rm -rf "$dir" rm -f "$dmg" mkdir "$dir" cp -R "$BUILT_PRODUCTS_DIR/$PROJECT_NAME.app" "$dir" chmod -Rf go-w "$dir" ln -s "/Applications" "$dir/Applications" sync hdiutil create -srcfolder "$dir" -volname "$PROJECT_NAME" -imagekey zlib-level=9 -format UDZO "$dmg" hdiutil internet-enable -yes "$dmg" rm -rf "$dir" A more throughout script for XCode
  52. Packing in Xcode
  53. Pack (@_@) DMG Creation easy scriptable No initial support from XCode
  54. Ready for distribution ($_$) and earn you money ;)
  55. Updates
  56. Updates: Sparkle OpenSource Update Framework
  57. Updates: AppCast Podcasting Feed for your App <?xml version="1.0" encoding="UTF-8"?> <rss xmlns:atom="..." xmlns:sparkle="..." version="2.0"> <channel> <title>IntegrityX</title> <description>IntegrityX updates</description> <link>http://freaklikeme.de/pub/res</link> <language>en</language> <pubDate>Sun, 02 May 2010 16:18:44 +0200</pubDate> <atom:link type="application/rss+xml" href="..." rel="self"/> <item> <title>IntegrityX 0.1</title> <sparkle:releaseNotesLink>...</sparkle:releaseNotesLink> <pubDate>Sun, 02 May 2010 16:18:44 +0200</pubDate> <guid isPermaLink="false">IntegrityX-0.1</guid> <enclosure type="application/dmg" url="http://...IntegrityX-0.1.dmg" length="10784979" sparkle:version="0.1" sparkle:dsaSignature="MC0CFQCvYKP +elGXrPUEV2Yoxj6OTLKioA="/> </item> </channel> </rss>
  58. Adding Sparkle 1.Add Sparkle Framework to App Bundle 2.Add Check for Update Option 3.Generate Key Pair for Signing 4.Add Info where to find Updates and PubKey A Video to show it.
  59. In the original presentation was a video here to show how to setup Sparkle but you can follow the instructions in this article: http://foolsworkshop.com/rubycocoa/2008/06/adding- a-check-updates-feature-for-rubycocoa-and-macruby/
  60. Release with Sparkle 1.Create Signature for your App Bundle 2.Create AppCastFeed with current Signature 3.Add Release Note Yes there is a script for that: http://github.com/CraigWilliams/appcastautomation
  61. Updates 0_0/ Add SparkleFramework Sign App Bundle Publish with AppCast
  62. Grand Finale ChocTop
  63. ChocTop All you need at your command line rake build # Build Xcode Release rake dmg # Create the dmg file for appcasting rake feed # Create/update the appcast file rake upload # Upload the appcast and dmg to host rake version:bump:major # Bump the major version. rake version:bump:minor # Bump the minor version. rake version:bump:patch # Bump the patch version. rake version:current # Display the current version
  64. ChocTop Offers Custom DMG with Positioning Doing this with Apple Script (requiers original apple ruby as it uses ruby cocoa)
  65. ChocTop
  66. Thanks Start: macruby.org Help: MacRuby-devel on MacOSForge Twitter: @MacRuby
  67. Resources ChocTop and Logo Dr. Nic William http://drnic.github.com/choctop/ Macruby and Logo http://macruby.org Framework Foto: http://www.flickr.com/photos/29225114@N08/3112939993/ Sparke Instructions: http://foolsworkshop.com/rubycocoa/2008/06/adding-a-check- updates-feature-for-rubycocoa-and-macruby/ Sparkle Video, Tweetscreen DMG Design, web site screen shoot from Patrick Hüsler: http://huesler-informatik.ch/ Sparkle Framework: http://github.com/andymatuschak/Sparkle

×