Skip to content

Instantly share code, notes, and snippets.

@rubenfonseca
Created March 4, 2012 18:15
Show Gist options
  • Save rubenfonseca/1974242 to your computer and use it in GitHub Desktop.
Save rubenfonseca/1974242 to your computer and use it in GitHub Desktop.
Rakefile + CoffeeScript + Titanium Mobile example
var app = {
classes: { },
models : { }
};
Ti.include('js/main.js');
Ti.include '/lib/underscore.js'
Ti.include '/lib/backbone.js'
Ti.include '/js/main_view_controller.js'
mvc = new app.classes.MainViewController()
mvc.open()
class MainViewController
constructor: ->
@window = Ti.UI.createWindow
title: "Main Window"
@button = Ti.UI.createButton
title: "button"
@window.add @button
@button.addEventListener 'click', this.handle_btn_click
open: ->
@window.open()
handle_btn_click: (e) =>
Ti.API.warn "button clicked: #{JSON.stringify e}"
app.classes.MainViewController = MainViewController
DEV_PROVISIONING_UUID = "3E4D9E49-E44B-4B73-AFAD-248C720ECD53"
DEV_SIGN = "Ruben Fonseca"
DEV_APP_NAME = "My greatest app"
DEV_APP_ID = 'com.0x82.app'
TITANIUM_SDK_VERSION = '1.8.2'
IPHONE_SDK_VERSION = '5.0'
BUILDER_PATH = "/Library/Application Support/Titanium/mobilesdk/osx/#{TITANIUM_SDK_VERSION}/iphone/builder.py"
if File.exists?(BUILDER_PATH)
BUILDER = BUILDER_PATH
elsif File.exists?(File.expand_path('~') + BUILDER_PATH)
BUILDER = File.expand_path('~') + BUILDER_PATH
else
raise "Couldn't found builder.py for iPhone Titanium SDK #{TITANIUM_SDK_VERSION}"
end
task :run do
sh 'coffee -c -l -o Resources/js coffee'
FileUtils.mkdir_p('build/iphone')
sh BUILDER, 'simulator', IPHONE_SDK_VERSION, File.dirname(__FILE__), DEV_APP_ID, DEV_APP_NAME
end
task :clean do
sh "rm -rf ./build"
end
task :fresh => %w(clean run)
task :coffee do
sh 'coffee -c -w -l -o Resources/js coffee'
end
task :default => [:run]
@davidslvto
Copy link

cool 1 line of my contribution was accepted =D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment