RubyMotionとXcodeでのプロジェクトの設定方法を比較してみた
こんにちは!
前回は、RubyMotionを軽く触ってみました。
今回は、予告通りにプロジェクトの設定の仕方を調べていきます。
ドキュメントによると、設定はRakefileに記述していくようです。
No GUI!!
設定はドキュメントを何度も見ることになりそうなので、自分なりに比較しながらメモしてみる。
まずRakefileの基本的な設定方法をみてみる。
motion createで作成されたデフォルトのRakefileは例えばこんな感じ
# -*- coding: utf-8 -*- $:.unshift("/Library/RubyMotion/lib") require 'motion/project' Motion::Project::App.setup do |app| # Use `rake config' to see complete project settings. app.name = 'Sample' app.deployment_target = '6.0' end
まず最初のおまじない$:.unshift("/Library/RubyMotion/lib")
で、Motion::Project::App.setup do |app|以下に、いろいろかけるみたい。
app.に続いて設定したいものを記述する。
では、ここからRubyMotionと、Xcodeとの雑な比較です。(間違っていたら教えて下さい。)
補足ですが、Xcode上ではInfo-plist or Build Settingsで指定していきます。
name iPhoneなどにインストールしたときにアイコンの下に表示される文字列(String)
- RubyMotion
app.name ="hoge"
RubyMotionではmotion createで作成したプロジェクト名になっています。
Info->Bundle display name
Xcodeでも作成したプロジェクト名になっています。
version プロジェクトのバージョン (String)
- RubyMotion
app.version = "1.0" # デフォルト値は"1.0"
Info->Bundle version
Xcodeでのデフォルト値は”1.0.0”
short_version プロジェクトのショートバージョン (String)。 App Store にリリースするごとにユニークな値にする必要があります。
- RubyMotion
app.short_version = "1" # デフォルト値は"1"
Xcodeでのデフォルト値は”1.0.0”
Info->Bundle versions string, short
identifier プロジェクト識別子 (String)
- RubyMotion
app.identifier = "com.yourcompany."
Info->Bundle identifier
Xcodeでプロジェクトを作成する際は、何かしら埋めないといいけない。
delegate_class アプリケーションの delegate クラス名 (String)
- RubyMotion アプリケーションの delegate クラス名 (String)
app.delegate_class = "AppDelegate" # app_delegate.rbのクラス定義になっている
class AppDelegate def application(application, didFinishLaunchingWithOptions:launchOptions) @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) true end end
デフォルトではAppDelegate.mがプロジェクト作成時に生成される。
files プロジェクトで使用するファイル (Array)
- RubyMotion
app.files = ["./app/app_delegate.rb"]
デフォルト値は Dir.glob(./app/*/.rb) を評価した結果となります (app ディレクトリ内のすべての .rb)。
Build Phases->Compile Sources
ここに含まれていれば、プロジェクトに含まれていることになる。
frameworks リンクする iOS フレームワークの名前 (Array)
- RubyMotion
app.frameworks = ["UIKit", "Foundation", "CoreGraphics"]
Build Phases->Link Binary With Library Requiredであること
weak_frameworks frameworks と同様のものですが、deployment_target で指定したバージョンのデバイスで利用可能な場合にのみリンクされます。
- RubyMotion
app.weak_frameworks = [] # デフォルトは空
Build Phases->Link Binary With Library Optionalであること
libs リンクするライブラリのパス (Array)
- RubyMotion
app.libs = [] # デフォルトは空
Build Settings->Search Paths->Library Search Paths
build_dir アプリをビルドする際に使用するディレクトリのパス (String)
- RubyMotion
app.build_dir = "./build"
Build Setings->Build Locations->Build Products Path
resources_dirs リソースファイルを置くディレクトリのパス (Array)
- RubyMotion
app.resources_dirs = ["./resources"] # デフォルトは["./resources"]
Build Phasee->Copy Bundle Resourcesに該当ファイルがあるかないか
specs_dir spec ファイルを置くディレクトリのパス (String)
- RubyMotion
app.specs_dir = "./spec"
TARGETSにUnitテスト用ターゲットをバンドルされる
icons アイコンに使用するリソースファイル名のリスト (Array)
- RubyMotion
app.icons = ["Icon.png", "Icon-72.png", "Icon@2x.png"] #デフォルト値は空
Icon files (iOS 5)->Primary Icon->Icon filesに該当のアイコンファイル名を追加し、Build Phasee->Copy Bundle Resourcesにもファイルを追加
fonts リソースディレクトリ内のフォントファイル名のリスト (Array) デフォルト値は、リソースディレクトリ内のすべての .ttf と .otf のリストです。デフォルト値を使うことを推奨します。
- RubyMotion
app.fonts = ["Inconsolata.otf"] # デフォルト値は空
Build Phasee->Copy Bundle Resourcesにフォントファイルを追加することで、新たにそのフォントファイルが使用できるようになる
prerendered_icon icons のアイコンファイルが、HIG guidelines に従ってあらかじめ描画されているかを指定します。false を指定すると、iOS がアイコンにリフレクション効果を適用します。
- RubyMotion
app.prerendered_icon = false # デフォルト値はfalse
Icon already includes gloss effectsで指定する。
device_family サポートするデバイスを指定。iphone と ipad 、[:iphone, :ipad] (ユニバーサルアプリ) を指定できます。
- RubyMotion
‘app.device_family = [:iPhone] # デフォルト値はiPhone’
Build Settings->Targeted Device Familyで指定
プロジェクト作成時に選択する。
interface_orientations サポートするデバイスのインタフェースの向きを指定します。(Array)
- RubyMotion
app.interface_orientations = [:portrait, :landscape_left, :landscape_right] # デフォルト値
濃いグレーでチェックが入っているものが適応されるもの。
複数対応させる場合チェックする順番が関係するらしいです。
iOS 6 では Supported interface orientations の順番に注意! -24/7 twenty-four seven-
xcode_dir Xcode がインストールされているディレクトリを指定します (String)
- RubyMotion
デフォルト値は /usr/bin/xcode-select -printPath が返す値。
もし正しい値でなければ/Applications/Xcode.app/Contents/Developerが使われます。
同様。
sdk_version 使用する SDK のバージョン番号 (String)
- RubyMotion
app.sdk_version = "5.0" # デフォルトは最新バージョン
Build Settings->Archtectures->Base SDK
同様。
deployment_target ターゲットとする SDK のバージョン番号 (String)
- RubyMotion
app.deployment_target= "5.0" #デフォルト値はsdk_versionを同じ
Build Settings->Deployment->iOS Deployment Target
同様。
codesign_certificate CodeSign に使用する証明書の名前を指定します (String)
- RubyMotion
app.codesign_certificate = "iPhone Developer: Darth Vader (A3LKZY369Q)" # 例
Build Settings->Code Signing->Code Signing identifier
ここから、該当のものを選択。
provisioning_profile deployment に使用するプロビジョニングプロファイルのパスを指定します (String)
- RubyMotion
app.provisioning_profile = “/Users/username/Library/MobileDevice/Provisioning Profiles/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.mobileprovision”
Window->Organizer->Provisioning Profiles
とくに意識する必要は無いと思う。使いたいやつがValid profileになっていればいいと思います。
seed_id アプリケーションのプロビジョニング識別子 (String)
- RubyMotion
iOSプロビジョニングポータル (iOS Provisioning Portal) によって生成された 10 文字の (App Store内で) ユニークな識別子です。デフォルト値は provisioning_profile で最初に見つかるアプリケーション識別子です。
まとめ
いつもは、Xcodeからポチポチやるだけだったので、深い意味とかは考えずにやっていました。
こうやって調べてみると、再発見があったりしていいですね。