-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
399 lines (261 loc) · 15.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<title>RubyMotion、はじめの一歩 - Watson's Blog</title>
<meta name="author" content="Watson">
<meta name="description" content="RubyMotion は MacRuby をベースとした、Ruby で iOS アプリを開発するための枠組みを提供します。これまで、iOS アプリを開発するために Objective-C や、JavaScript で開発できる Titanium Mobile などが利用されてきましたが、これからは …">
<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="canonical" href="http://watson1978.github.com/blog/2012/05/03/first-step-in-rubymotion_ja/">
<link href="/favicon.png" rel="icon">
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<script src="/javascripts/modernizr-2.0.js"></script>
<script src="/javascripts/ender.js"></script>
<script src="/javascripts/octopress.js" type="text/javascript"></script>
<link href="/atom.xml" rel="alternate" title="Watson's Blog" type="application/atom+xml">
<!--Fonts from Google"s Web font directory at http://google.com/webfonts -->
<link href="http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-31153551-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body >
<header role="banner"><hgroup>
<h1><a href="/">Watson's Blog</a></h1>
</hgroup>
</header>
<nav role="navigation"><ul class="subscription" data-subscription="rss">
<li><a href="/atom.xml" rel="subscribe-rss" title="subscribe via RSS">RSS</a></li>
</ul>
<form action="http://google.com/search" method="get">
<fieldset role="search">
<input type="hidden" name="q" value="site:watson1978.github.com" />
<input class="search" type="text" name="q" results="0" placeholder="Search"/>
</fieldset>
</form>
<ul class="main-navigation">
<li><a href="/">Blog</a></li>
<li><a href="/blog/archives">Archives</a></li>
<li><a href="/MacRuby-DoJo/">MacRuby DoJo</a></li>
</ul>
</nav>
<div id="main">
<div id="content">
<div>
<article class="hentry" role="article">
<header>
<h1 class="entry-title">RubyMotion、はじめの一歩</h1>
<p class="meta">
<time datetime="2012-05-03T00:00:00+09:00" pubdate data-updated="true">May 3<span>rd</span>, 2012</time>
| <a href="#disqus_thread">Comments</a>
</p>
</header>
<div class="entry-content"><p><a href="http://www.rubymotion.com/">RubyMotion</a> は MacRuby をベースとした、Ruby で iOS アプリを開発するための枠組みを提供します。これまで、iOS アプリを開発するために Objective-C や、JavaScript で開発できる Titanium Mobile などが利用されてきましたが、これからは Ruby でも iOS アプリを開発することができます。</p>
<!-- more -->
<h2>RubyMotion をインストール</h2>
<p>インストールパッケージをダウンロードしてインストールすると、RubyMotion は /Library/RubyMotion にインストールされます。また、コマンドラインツールとして /usr/bin/motion というシンボリックリンクが作成されます。</p>
<p>/Library/RubyMotion にインストールされるディレクトリ構成は以下のようになります。</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>/Library/RubyMotion/
</span><span class='line'>├── bin
</span><span class='line'>├── data
</span><span class='line'>└── lib</span></code></pre></td></tr></table></div></figure>
<p>アンインストール場合には /Library/RubyMotion/ と /usr/bin/motion を削除してください。</p>
<h2>サンプルを動かしてみる</h2>
<p>RubyMotion にはいくつかサンプルが<a href="https://github.com/HipByte/RubyMotionSamples">GitHub</a> 上で用意されています。ここでは hello というサンプルを動かしてみます。Terminal で、以下のようにコマンドを実行します。</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$ git clone https://github.com/HipByte/RubyMotionSamples.git
</span><span class='line'>$ cd RubyMotionSamples/Hello/
</span><span class='line'>$ rake
</span><span class='line'> Build ./build/iPhoneSimulator-5.1-Development
</span><span class='line'> Compile ./app/app_delegate.rb
</span><span class='line'> Compile ./app/hello_view.rb
</span><span class='line'> Compile ./app/hello_view_controller.rb
</span><span class='line'> Create ./build/iPhoneSimulator-5.1-Development/Hello.app
</span><span class='line'> Link ./build/iPhoneSimulator-5.1-Development/Hello.app/Hello
</span><span class='line'> Create ./build/iPhoneSimulator-5.1-Development/Hello.app/Info.plist
</span><span class='line'> Create ./build/iPhoneSimulator-5.1-Development/Hello.app/PkgInfo
</span><span class='line'> Copy ./resources/icon.png
</span><span class='line'> Create ./build/iPhoneSimulator-5.1-Development/Hello.dSYM
</span><span class='line'> Simulate ./build/iPhoneSimulator-5.1-Development/Hello.app
</span><span class='line'>(main)>> </span></code></pre></td></tr></table></div></figure>
<p>RubyMotion では Ruby で書かれたコードをコンパイルしてネイティブな実行ファイルを作成します。コンパイルが成功すると iOS シミュレータが起動し hello アプリが実行されます。</p>
<p><img src="/images/blog/hello.png" alt="hello アプリ"></p>
<p>RubyMotion は、まだ Xcode と連携する機能が無いため、Terminal での操作が基本になります。Rakefile が置かれているディレクトリで <code>rake -T</code> を実行すると、ビルドに使用するコマンドなどを確認できます。</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$ rake -T
</span><span class='line'>rake archive # Create archives for everything
</span><span class='line'>rake archive:development # Create an .ipa archive for development
</span><span class='line'>rake archive:release # Create an .ipa and .xcarchive for release (AppStore)
</span><span class='line'>rake build # Build everything
</span><span class='line'>rake build:device # Build the device version
</span><span class='line'>rake build:simulator # Build the simulator version
</span><span class='line'>rake clean # Clear build objects
</span><span class='line'>rake config # Show project config
</span><span class='line'>rake ctags # Generate ctags
</span><span class='line'>rake default # Build the project, then run the simulator
</span><span class='line'>rake device # Deploy on the device
</span><span class='line'>rake simulator # Run the simulator
</span><span class='line'>rake spec # Run specs</span></code></pre></td></tr></table></div></figure>
<p>次回は、実際にアプリを作成してみたいと思います。</p>
</div>
<footer>
<p class="meta">
<span class="byline author vcard">Posted by <span class="fn">Watson</span></span>
<time datetime="2012-05-03T00:00:00+09:00" pubdate data-updated="true">May 3<span>rd</span>, 2012</time>
<span class="categories">
<a class='category' href='/blog/categories/rubymotion/'>RubyMotion</a>
</span>
</p>
<div class="sharing">
<a href="http://b.hatena.ne.jp/entry/" class="hatena-bookmark-button" data-hatena-bookmark-layout="standard"><img src="http://b.st-hatena.com/images/entry-button/button-only.gif" width="20" height="20" style="border: none;" /></a><script type="text/javascript" src="http://b.st-hatena.com/js/bookmark_button.js" charset="utf-8" async="async"></script>
<a href="http://www.delicious.com/save" class="delicious-bookmark-button" onclick="window.open('http://www.delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;"><img src="http://previous.delicious.com/static/img/delicious.small.gif" height="20" width="20" style="border: none;" alt="Delicious" /></a>
<script type="text/javascript" src="http://static.evernote.com/noteit.js"></script>
<a href="#" onclick="Evernote.doClip({}); return false;"><img src="http://static.evernote.com/site-mem-32.png" height="20" width="20" style="border: none;" alt="Clip to Evernote" /></a>
<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://watson1978.github.com/blog/2012/05/03/first-step-in-rubymotion_ja/" data-via="watson1978" data-counturl="http://watson1978.github.com/blog/2012/05/03/first-step-in-rubymotion_ja/" >Tweet</a>
<div class="fb-like" data-send="false" data-layout="button_count" data-show-faces="true"></div>
<div class="g-plusone" data-size="medium"></div>
</div>
<p class="meta">
<a class="basic-alignment right" href="/blog/2012/05/03/creating-an-ios-application-using-rubymotion_ja/" title="Next Post: RubyMotion で簡単な iOS アプリを作ってみよう">RubyMotion で簡単な iOS アプリを作ってみよう »</a>
</p>
</footer>
</article>
<section>
<h1>Comments</h1>
<div id="disqus_thread" aria-live="polite"><noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
</section>
</div>
<aside class="sidebar">
<section>
<h1>About Me</h1>
<img src="/images/watson.jpg"/>
<ul>
<li>Author: Watson</li>
<li><a href="https://github.com/MacRuby/MacRuby">MacRuby</a> / <a href="http://www.rubymotion.com/">RubyMotion</a> チームのメンバー</li>
<li><a href="https://twitter.com/watson1978">Twitter</a>, <a href="https://github.com/Watson1978">Github</a></li>
</ul>
</section>
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="/blog/2013/03/31/rubymotion-conference-2013/">RubyMotion Conference 2013</a>
</li>
<li class="post">
<a href="/blog/2013/02/12/rubymotion-build-plugin-for-jenkins/">jenkins-rubymotion-plugin ってものを作ってます</a>
</li>
<li class="post">
<a href="/blog/2013/02/11/tokyo-rubykaigi-3rd/">東京 Ruby 会議 10 3日目にいってきました</a>
</li>
<li class="post">
<a href="/blog/2013/01/30/rubymotion-jenkins-tap/">Jenkins に TAP Plugin というものを導入しました</a>
</li>
<li class="post">
<a href="/blog/2013/01/25/motion-pixate-observer/">motion-pixate-observer という gem を作りました</a>
</li>
</ul>
</section>
<section>
<h1>Latest Tweets</h1>
<ul id="tweets">
<li class="loading">Status updating...</li>
</ul>
<script type="text/javascript">
$.domReady(function(){
getTwitterFeed("watson1978", 4, false);
});
</script>
<script src="/javascripts/twitter.js" type="text/javascript"> </script>
<a href="http://twitter.com/watson1978" class="twitter-follow-button" data-show-count="false">Follow @watson1978</a>
</section>
</aside>
</div>
</div>
<footer role="contentinfo"><p>
Copyright © 2013 - Watson -
<span class="credit">Powered by <a href="http://octopress.org">Octopress</a></span>
</p>
</footer>
<script type="text/javascript">
var disqus_shortname = 'watsonsblog';
// var disqus_developer = 1;
var disqus_identifier = 'http://watson1978.github.com/blog/2012/05/03/first-step-in-rubymotion_ja/';
var disqus_url = 'http://watson1978.github.com/blog/2012/05/03/first-step-in-rubymotion_ja/';
var disqus_script = 'embed.js';
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/' + disqus_script;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}());
</script>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#appId=212934732101925&xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<script type="text/javascript">
(function() {
var script = document.createElement('script'); script.type = 'text/javascript'; script.async = true;
script.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(script, s);
})();
</script>
<script type="text/javascript">
(function(){
var twitterWidgets = document.createElement('script');
twitterWidgets.type = 'text/javascript';
twitterWidgets.async = true;
twitterWidgets.src = 'http://platform.twitter.com/widgets.js';
document.getElementsByTagName('head')[0].appendChild(twitterWidgets);
})();
</script>
</body>
</html>