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
1k
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
110
Bitriseで本をビルドする / Build a book with Bitrise
iseebi
0
160
BitriseでmacOSアプリをビルドする / Build macOS apps with Bitrise
iseebi
1
800
iOS/Androidアプリ転送ツール TransporterPadの紹介
iseebi
0
6.1k
Apple Developer Enterprise Program でどこまでいけるのか
iseebi
0
780
ReactiveProperty を使ったアプリの設計に Realm Xamarin を組み合わせる
iseebi
0
660
ReactiveProperty で Xamarin アプリの作り方が変わった
iseebi
3
1.7k
600件のPull RequestからみたXamarinのはまりどころ
iseebi
3
4.3k
Yet Another Cross Platform Development
iseebi
0
4.2k
Other Decks in Programming
See All in Programming
KessokuでDIでもgoroutineを活用する / Go Connect #6
mazrean
0
140
「手軽で便利」に潜む罠。 Popover API を WCAG 2.2の視点で安全に使うには
taitotnk
0
280
FindyにおけるTakumi活用と脆弱性管理のこれから
rvirus0817
0
370
[FEConf 2025] 모노레포 절망편, 14개 레포로 부활하기까지 걸린 1년
mmmaxkim
0
1.4k
🔨 小さなビルドシステムを作る
momeemt
3
640
Microsoft Orleans, Daprのアクターモデルを使い効率的に開発、デプロイを行うためのSekibanの試行錯誤 / Sekiban: Exploring Efficient Development and Deployment with Microsoft Orleans and Dapr Actor Models
tomohisa
0
230
AIを活用し、今後に備えるための技術知識 / Basic Knowledge to Utilize AI
kishida
19
4.2k
CloudflareのChat Agent Starter Kitで簡単!AIチャットボット構築
syumai
2
340
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
140
Ruby Parser progress report 2025
yui_knk
1
260
個人軟體時代
ethanhuang13
0
290
CSC305 Summer Lecture 12
javiergs
PRO
0
130
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Building Adaptive Systems
keathley
43
2.7k
GraphQLとの向き合い方2022年版
quramy
49
14k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.7k
How to train your dragon (web standard)
notwaldorf
96
6.2k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.6k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Become a Pro
speakerdeck
PRO
29
5.5k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.5k
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/