Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Xamarin + MvvmCross で作る iOS/Android アプリ
Search
Nobuhiro Ito
May 03, 2014
Programming
1
990
Xamarin + MvvmCross で作る iOS/Android アプリ
2014/05/03(Sat) Kyoto.なんか #kyotoasterisk
Nobuhiro Ito
May 03, 2014
Tweet
Share
More Decks by Nobuhiro Ito
See All by Nobuhiro Ito
Introduction of Aizome - 多言語対応とスタイル適用を両立する書式付き文字列ライブラリ
iseebi
0
93
Bitriseで本をビルドする / Build a book with Bitrise
iseebi
0
140
BitriseでmacOSアプリをビルドする / Build macOS apps with Bitrise
iseebi
1
780
iOS/Androidアプリ転送ツール TransporterPadの紹介
iseebi
0
6.1k
Apple Developer Enterprise Program でどこまでいけるのか
iseebi
0
770
ReactiveProperty を使ったアプリの設計に Realm Xamarin を組み合わせる
iseebi
0
640
ReactiveProperty で Xamarin アプリの作り方が変わった
iseebi
3
1.7k
600件のPull RequestからみたXamarinのはまりどころ
iseebi
3
4.2k
Yet Another Cross Platform Development
iseebi
0
4.2k
Other Decks in Programming
See All in Programming
Blueskyのプラグインを作ってみた
hakkadaikon
1
390
💎 My RubyKaigi Effect in 2025: Top Ruby Companies 🌐
yasulab
PRO
1
130
MLOps Japan 勉強会 #52 - 特徴量を言語を越えて一貫して管理する, 『特徴量ドリブン』な MLOps の実現への試み
taniiicom
2
620
推論された型の移植性エラーTS2742に挑む
teamlab
PRO
0
170
漸進。
ssssota
0
1.6k
Effect の双対、Coeffect
yukikurage
4
430
UPDATEがシステムを複雑にする? イミュータブルデータモデルのすすめ
shimomura
0
490
20250528 AWS Startupイベント登壇資料:AIコーディングの取り組み
procrustes5
0
140
Step up the performance game with Spring Boot and Project Leyden
mhalbritter
0
170
CSC307 Lecture 17
javiergs
PRO
0
110
Zennの運営完全に理解した #完全に理解したTalk
wadayusuke
1
170
コード書くの好きな人向けAIコーディング活用tips #orestudy
77web
3
240
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Rebuilding a faster, lazier Slack
samanthasiow
81
9k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
137
34k
Reflections from 52 weeks, 52 projects
jeffersonlam
349
20k
It's Worth the Effort
3n
184
28k
Designing for humans not robots
tammielis
253
25k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.2k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.5k
How to Ace a Technical Interview
jacobian
276
23k
Producing Creativity
orderedlist
PRO
346
40k
Building Adaptive Systems
keathley
42
2.6k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Transcript
Xamarin + MvvmCross で作る iOS/Androidアプリ 伊勢 シン (@iseebi) Kyoto.なんか 2014/05/03(Sat)
⾃自⼰己紹介 • 伊藤 伸裕 / 伊勢 シン – @iseebi / id:iseebi
• フェンリル株式会社 共同開発部所属 – iOS / Android / Windows 8 のアプリ開発してます • コミュニティ – スマートフォン勉強会@関⻄西 – すごいHaskell読書会 in ⼤大阪 • H本読んでます。(2週⽬目)
Xamarin 2.0 • ネイティブの iOS / Android / Mac アプリを
C# で書ける! – Windows プラットフォームを⾜足せば、だいたいのプラッ トフォームのソースをC#で書いてしまえる。
処理理を共通化できます! • C#だけで書ける=iOS/Androidで処理理を共通化できる • アプリの性質にもよるが、3割から4割くらい共通化できま す。 PCL
なぜXamarin? • C# を使うプラットフォームでは MVVM という概念念がすでに体系化されている。 – Model-View-ViewModel • クロスプラットフォーム開発で MVVM
をサポートするライブラリもすでにある – MvvmCross – QuickCross
MVVM • MVなんとかの中でもバインディングに ものすごく依存している • 移し替えのコードがバグ出やすいので、 なるべくバインディングで解決させたい (と僕は思う) http://msdn.microsoft.com/en-us/library/gg405484(v=PandP.40).aspx#sec1
%&.0
プロジェクト初期設定 • プロジェクトの初期設定 – http://www.slideshare.net/iseebi/cross-platform- development-with-xamarin-20- mvvmcross-32190450 • NuGetで導⼊入する際、下記のものも⼊入れる –
MvvmCross – MvvmCross – DownloadCache Plugin • MvvmCross.HotTuna.Plugin.DownloadCache – MvvmCross – File Plugin • MvvmCross.HotTuna.Plugin.File – Microsoft HTTP Client Libraries (Coreのみ) • Microsoft.Net.Http
はてなフォトライフへのアクセス • gistを参考に – https://gist.github.com/iseebi/492486
ViewModel の作成 • 取得したデータを出す IEnumerable をプロパ ティに出す • Start のタイミングで読み込みを⾏行行う
iOSの実装 – セルの作成 • iPhone Table View Cell を追加すると、 .cs
と .xib が⽣生成される。 • 継承元を MvxTableViewCell に変更更 • .xib にコントロールを配置し、アウトレット接続 – Xcode上で⾏行行う – UIImageView は MvxImageView にする。 URLでバインディングできるようになる。 • DelayBind を記述する
iOSの実装 - ViewController • MvxTableViewController にする • インナークラスで TableViewSource を作る
– コンストラクタで RegisterCellForReuse する • ViewDidLoad でバインディングを作成
Androidの実装 - ListItem • Layout を追加する • xmlns に local
を追加する – xmlns:local="http://schemas.android.com/apk/ res-auto" • 各要素に local:MvxBind を追加する – コントロール側のプロパティ ViewModel側のプロパテ ィ で記述する – ImageView は Mvx.MvxImageView にする。
Android の実装 - View • ListView のかわりに Mvx.MvxListView を使⽤用 する。
• local:MvxBind に ViewModel とのバインディン グを作成 • local:MvxItemTemplate で、使⽤用するレイアウ トを指定する
デメリット • ライセンスが⾼高い – 会社で使うと1開発者1プラットフォーム 約10万円 – チームを組むと iOS /
Android 3本ずつ=60万 (実際はディスカウント⼊入るのでもうちょっと安い) • こまかい制限もちょいちょい – 動的コンパイル必要な機能は動かない • まあ、「お⾦金金が出るならアリ」の技術… – コード共有で浮くお⾦金金でライセンスを買おう
まとめ • Xamarin と MvvmCross を使うと、 iOS / Android アプリを効率率率的に開発できます。
参考URL • 今回のソース – https://github.com/iseebi/FotolifeViewer • Qiita の Xamarin タグ
(国内のXamarin系の⼈人の Qiita 参加率率率⾼高い) – http://qiita.com/tags/xamarin • Xamarin ⽇日本語情報 (国内代理理店の⼈人のblog) – http://ytabuchi.hatenablog.com/ • Xamarin Japan グループ (facebook) – https://www.facebook.com/groups/778386365523431/ • backyard of 伊勢的新常識識 (僕のblogです) – http://iseebi.hatenablog.com/