RubyMotionでiOS開発
Upcoming SlideShare
Loading in...5
×
 

RubyMotionでiOS開発

on

  • 3,343 views

【豊橋】第1回 iPhoneアプリ開発勉強会でLTしたときの資料です

【豊橋】第1回 iPhoneアプリ開発勉強会でLTしたときの資料です

Statistics

Views

Total Views
3,343
Views on SlideShare
1,867
Embed Views
1,476

Actions

Likes
3
Downloads
4
Comments
0

5 Embeds 1,476

http://ios-nagoya.jimdo.com 1265
https://twitter.com 119
http://www58.jimdo.com 46
http://dev.eventdots.jp 45
http://webcache.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

RubyMotionでiOS開発 RubyMotionでiOS開発 Presentation Transcript

  • RubyMotionで iOS開発2013/04/27【豊橋】第1回iPhoneアプリ開発勉強会加藤匡邦 (エアーズ株式会社)
  • 自己紹介@mackatoMr. kato (bruce lee) in Green Hornet.
  • fromHamamatsu!Original Update by hirotomo
  • エアーズ株式会社毎日つかえるアプリを作る
  • Hi-Cube浜松本社
  • TokyoofficeinTSUKIJI※写真はイメージですOriginal Update by graney
  • ウェブ開発RubyonRails
  • おいしいはiPhoneが覚えてる
  • お財布はスリムに、お店はスマートに
  • WWDC2012attendee
  • WWDC2013sellsoutin2minutes!
  • Hamamatsu.rb#1Hamamatsu.rb2011.03.09∼
  • HamackathonHamackathon#2 Mobile - 2010.12.04Hamackathon
  • JAWS-UG浜松http://jaws-ug.jp/bc/hamamatsu/
  • Ruby
  • Rubyオブジェクト指向シンプルな文法動的な型付け
  • Web開発サーバー管理パッケージ管理
  • RubyMotion
  • RubyMotionRubyで書けるiOSネイティブiOSライブラリが使える
  • $199.99有料です
  • ¥20,513アベノミクス2013/4/27現在
  • WritewithRubyclass AppDelegatedef application(application, didFinishLaunchingWithOptions:launchOptions)@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)@window.makeKeyAndVisible@blue_view = UIView.alloc.initWithFrame(CGRectMake(10, 10, 100, 100))@blue_view.backgroundColor = UIColor.blueColor@window.addSubview(@blue_view)trueendendapp_delegate.rb
  • UsePowerofRubyclass AppDelegatedef application(application, didFinishLaunchingWithOptions:launchOptions)@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)@window.makeKeyAndVisible %w(blue-lagoon red-ocean black-coffee).each_with_index do |str, i|UIView.alloc.init.tap do |view|view.frame = [[50 * i, 50 * i + 20], [100, 100]]view.backgroundColor = UIColor.send(:"#{$1}Color")@window.addSubview(view)end if str =~ /^(?!black)(w+)-.+/end trueendendapp_delegate.rb
  • Metaprogramminghttp://clayallsopp.com/posts/rubymotion-metaprogramming/def tableView(tableView,didSelectRowAtIndexPath:indexPath)menu_row = self.menu_items[indexPath.row]# => profileself.send("open_#{menu_row}")enddef open_profile; #...; enddef open_messages; #...; enddef open_feed; # ...; endclass Profile# EX: has_one :userdef self.has_one(name)klass = make_klass_from_name(name)# EX: => User# Effect: (a_profile.user = a_user)# === a_user.profile_id = 4define_method("#{name}=") do |value|value.send("#{self.class.stringify}_id=", self.id)value.savevalueendenddef self.stringify; "profile"; endendsend define_method
  • HelloMotion% motion create HelloMotionCreate HelloMotionCreate HelloMotion/.gitignoreCreate HelloMotion/RakefileCreate HelloMotion/appCreate HelloMotion/app/app_delegate.rbCreate HelloMotion/resourcesCreate HelloMotion/resources/Default-568h@2x.pngCreate HelloMotion/specCreate HelloMotion/spec/main_spec.rb
  • GoodbyeXcodeHelloMotion/"## Rakefile"## app$   %## app_delegate.rb"## resources$   %## Default-568h@2x.png%## spec%## main_spec.rbGoodbyeXcode/"## GoodbyeXcode$   "## Default-568h@2x.png$   "## Default.png$   "## Default@2x.png$   "## GXAppDelegate.h$   "## GXAppDelegate.m$   "## GoodbyeXcode-Info.plist$   "## GoodbyeXcode-Prefix.pch$   "## en.lproj$   $   %## InfoPlist.strings$   %## main.m"## GoodbyeXcode.xcodeproj$   "## project.pbxproj$   "## project.xcworkspace$   $   "## contents.xcworkspacedata$   $   %## xcuserdata$   $   %## kato.xcuserdatad$   $   %## UserInterfaceState.xcuserstate$   %## xcuserdata$   %## kato.xcuserdatad$   %## xcschemes$   "## GoodbyeXcode.xcscheme$   %## xcschememanagement.plist%## GoodbyeXcodeTests"## GoodbyeXcodeTests-Info.plist"## GoodbyeXcodeTests.h"## GoodbyeXcodeTests.m%## en.lproj%## InfoPlist.strings
  • RunApplication% rakeBuild ./build/iPhoneSimulator-6.1-DevelopmentCompile ./app/app_delegate.rbCreate ./build/iPhoneSimulator-6.1-Development/HelloMotion.appLink ./build/iPhoneSimulator-6.1-Development/HelloMotion.app/HelloMotionCreate ./build/iPhoneSimulator-6.1-Development/HelloMotion.app/Info.plistCreate ./build/iPhoneSimulator-6.1-Development/HelloMotion.app/PkgInfoCopy ./resources/Default-568h@2x.pngCreate ./build/iPhoneSimulator-6.1-Development/HelloMotion.dSYMwarning: no debug symbols in executable (-arch i386)Simulate ./build/iPhoneSimulator-6.1-Development/HelloMotion.app(main)>
  • REPL-interactiveconsole% rakeBuild ./build/iPhoneSimulator-6.1-DevelopmentCompile ./app/app_delegate.rbLink ./build/iPhoneSimulator-6.1-Development/HelloMotion.app/HelloMotionCreate ./build/iPhoneSimulator-6.1-Development/HelloMotion.app/Info.plistCreate ./build/iPhoneSimulator-6.1-Development/HelloMotion.app/PkgInfoCreate ./build/iPhoneSimulator-6.1-Development/HelloMotion.dSYMSimulate ./build/iPhoneSimulator-6.1-Development/HelloMotion.app(main)> 2013-04-27 15:31:48.161 HelloMotion[1990:c07] Application windows ...(main)> self=> main(#<UIView:0x7648df0>)> self.backgroundColor = UIColor.whiteColor=> #<UICachedDeviceWhiteColor:0xa96f180>(#<UIView:0x7648df0>)>
  • motion-cocoapodsRakefile#  -­‐*-­‐  coding:  utf-­‐8  -­‐*-­‐$:.unshift("/Library/RubyMotion/lib")require  motion/projectrequire  rubygemsrequire  motion-­‐cocoapods  Motion::Project::App.setup  do  |app|    #  Use  `rake  config  to  see  complete  project  settings.    app.name  =  HelloMotion      app.pods  do        pod  JSONKit    endend
  • BundlerRakefile#  -­‐*-­‐  coding:  utf-­‐8  -­‐*-­‐$:.unshift("/Library/RubyMotion/lib")require  motion/projectrequire  bundlerBundler.require  Motion::Project::App.setup  do  |app|    #  Use  `rake  config  to  see  complete  project  settings.    app.name  =  HelloMotion      app.pods  do        pod  JSONKit    endendGemfilesource  https://rubygems.org  gem  rakegem  motion-­‐cocoapodsgem  bubble-­‐wrapgem  sugarcube
  • BubbleWrap# Uses the front cameraBW::Device.camera.front.picture(media_types: [:movie, :image]) do |result|image_view = UIImageView.alloc.initWithImage(result[:original_image])endCameraBW::Location.get do |result|p "From Lat #{result[:from].latitude}, Long #{result[:from].longitude}"p "To Lat #{result[:to].latitude}, Long #{result[:to].longitude}"endLocationBW::HTTP.get("https://api.github.com/users/mattetti") do |response|p response.body.to_strendHTTP
  • Sugarcube0xffffff.uicolor  #  =>  UIColor.colorWithRed(1.0,  green:1.0,  blue:1.0,  alpha:1.0)5.days.ago    #  =>  2012-­‐12-­‐29  11:42:24  -­‐0700Fixnum#  UIApplication.sharedApplication.openURL(NSURL.URLWithString("https://github.com"))"https://github.com".nsurl.openNSURL#  UIImage  from  name"my_image".uiimage    #  =>  UIImage.imageNamed("my_image")#  UIFont  from  name"my_font".uifont(20)  #  =>  UIFont.fontWithName("my_font",  size:20)#  NSLocalizedString  from  string"hello".localized    #  =>  NSBundle.mainBundle.localizedStringForKey("hello",  value:nil,  table:nil)"hello"._                    #  ==  "hello".localizedNSString
  • In therealworldEverClipWinnerofEvernoteDevCup2012!Basecamp37signalsproducthttp://www.rubymotion.com/apps/
  • CommunityRubyMotionもくもく会次回 2013/05/22RubyMotionKaigi20132013/05/29
  • BooksRubyMotion RubyMotion入門@clayallsopp @naoya_ito
  • SeealsoRubyMotionDeveloperCenterhttp://www.rubymotion.com/developer-center/RubyMotionJPhttp://rubymotion.jp/RubyMotionWrappershttp://rubymotion-wrappers.com/
  • ConclusionRubyが書けてiOS未経験の方にはお薦めRubyMotion以外にRuby使わない人には??xcodeprojが無いので共同作業はしやすい
  • Thanks!2013/05/819:00∼Hamamatsu.rb#27参加者募集中!http://atnd.org/events/38863