mac ruby deployment
DESCRIPTION
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.TRANSCRIPT
Deploying MacRubyHow 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.amTwitter: @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)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"];}
HeaderfilesTypesMany BracetsSemicolon
Thats why I love: MacRuby
First Objective-C Appclass 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)! endend
Ruby => Less Noise
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
Obj-C Runtime
GCC
LLVMJIT/AOT
Ruby Code
GC
Obj-C
Std LibApp
IO
Frameworks
MacRuby 0.5
Obj-C Runtime
GCC
LLVMJIT/AOT
Ruby Code
GC
Obj-C
Std LibApp
IO
Frameworks
Object => NSObject
Ruby specific extensions
Primitives On Obj-C
MacRuby 0.5
Obj-C Runtime
LLVM
LLVMJIT/AOT
Ruby Code
GC
GCC
Std LibApp
IO
Frameworks
Generate Obj-C calls for Ruby code
Intermediate Representation (IR)
Optimization
JIT compiler to execute code
faster than 1.9
Ahead of Time Compiler
MacRuby 0.5
Obj-C Runtime
GCC
LLVMJIT/AOT
Ruby Code
GC
Obj-C
Std LibApp
IO
Frameworks
One runtime
One object space
Shared infrastructure
Multithreaded
NO GIL!Access to GCD
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 TemplatesTarget to RunTests/Compile/Embed
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.
MacRuby 0.5 -> 0.6
Improved API forGrand Central Dispatch
Job queueProxiesParallelisation extensions on Enumerable
MacRuby 0.5 -> 0.6
Better support for
MRI C-Extensions
<nokogiri/>
eg. NokoGiri and Postgresql
MacRuby 0.5 -> 0.6
ICU for Strings
and RegEx
弦樂加護病房和正則表達式
!"! #$% &'()**+,+ +(-.&'(/0 (.,)$%(*1. 21(/3.*0%
Threadsafe and Multibyte Char handling for your encoding pleasure.
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”, :level => 6
No Colon -> No parameter
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
Using StructsNSPoint(0,1)
NSpoint.new(0,1)
Like they are Objects
PointerNSError* error;
//MacRuby 0.5error = Pointer.new(:object)
As a means of an output parameter, mostly for error handling
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.
EASY
Build \^o^/
Embed
- Meaning copying MacRubyFramework inside the application Bundle- Updating file references to point inside the app. Bundle
Embed
your_project$ macruby_deploy --embed build/release/IntegrityX.app
Helpfull script.This is basicly the same what the embed target in XCode does
MacRubyFramework ~ 60MB
By Sergei Golyshev http://www.flickr.com/photos/29225114@N08/3112939993/ CC
Only Framework, no Gems, they will be excluded
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
MacRubyFramework without StdLib
~36 MB
Only Framework
Embed without Ruby StdLib
can easily add this options to your embed target in XCode
Embed
Customers don’t require MacRuby
Big Bundle even without StdLib
No Gems yet
0_0
Lets Move on to Packing
Pack
No support from XCode
Pack
your_project$ hdiutil create -srcfolder release/IntegrityX.app IntegrityX.dmg
This skript is a very basic version to create a dmg.
Pack: DMG
Is a:RAW Disk Image
Offers:Compression, Encryption, Meta Data
Used for:Apple Software DistributionFileVault
Pack: DMG Shell Scriptset -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"synchdiutil 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
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: AppCastPodcasting 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>
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.
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/
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
Updates \0_0/
Add SparkleFramework
Sign App Bundle
Publish with AppCast
Grand Finale
ChocTop
All you need at your command line
ChocTop
rake build # Build Xcode Releaserake dmg # Create the dmg file for appcastingrake feed # Create/update the appcast filerake upload # Upload the appcast and dmg to hostrake 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
ChocTop
Offers Custom DMG with Positioning
Doing this with Apple Script (requiers original apple ruby as it uses ruby cocoa)
ChocTop
Thanks
Start: macruby.org
Help: MacRuby-devel on MacOSForge
Twitter: @MacRuby
ResourcesChocTop 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