Xamarin(ザマリン)でVisual Studioを使ってiOSアプリを作る方法

プログラミング
スポンサーリンク

プログラミング

 

 

Xamarinは、Visual StudioのC#を使ってAndroidやiOSアプリを作ることが可能なクロスプラットフォーム開発環境です。

 

Xamarinに関しては日本語に関していい本がなかなか見つからないです。

 

見つかるのは、この本ぐらいです。

C#によるiOS、Android、Windowsアプリケーション開発入門 (MSDNプログラミングシリーズ)

 

そこで今回、WindowsのVisual StudioでiOSアプリが作れるかどうか調べてみました。

 

 

スポンサーリンク

Windows 7にXamarin(ザマリン)をインストールする

 

Windows 7のパソコンにVisual Studio 2012がインストールされている前提でXamarin for Windowsをインストールします。

 

Xamarin App Development with Visual Studio | Visual Studio
Target all platforms with a single, shared codebase for Android, iOS, and Windows. Dowload our free IDEs on OS X and Windows with Xamarin.

からインストーラーXamarinInstaller.exeをダウンロードして実行します。

 

 

ダウンロードする際に、氏名、メールアドレス、会社名、ライセンス数を聞かれますので順番に入力します。

 

image

 

 

インストーラーを起動すると以下の画面が表示されます。「Continue」を押します。

 

WS000001

 

以下の画面が表示されたら、「Next」を押します。

 

image

 

この後表示される画面では、「Next」を押し続けるとインストールが実行されます。

インストールが順調に進んでいると思っていたのですが、最後に以下の画面が表示されました。

 

image

 

An error has occurred.
Please follow the steps outlined below in order to install the missing software.

 

 

どうやらインストールが失敗したようです。

「Open Log」を押してみます。

以下の画面が表示されました。

 

image

 

Installation of ‘Xamarin’ failed with more than one exception (attempt 3)
Errors while installing items.

Exception type: System.AggregateException
Installation of archive ‘C:\Users\xxx\AppData\Local\Temp\Xamarin\downloads\Xamarin.VisualStudio_3.9.289.msi’ failed with exception.
Exception type: Xamarin.Web.Installer.InstallException
Full stack trace:
場所 Xamarin.Web.Installer.Installer.InstallationArchiveHandler.Install(String path, Boolean needsPrivileges)
場所 Xamarin.Web.Installer.Installer.BaseSoftwareItem.InstallDownloadedItem(String url, InstallationArchiveHandler handler, DownloadServiceWorkItem download)
場所 Xamarin.Web.Installer.Installer.BaseSoftwareItem.Install(UInt32 tryNumber)
場所 Xamarin.Web.Installer.Installer.XamarinVSSoftwareItem.Install(UInt32 tryNumber)
場所 WindowsInstaller.ProgressPage.InstallationWorker()
Installation of archive ‘C:\Users\xxx\AppData\Local\Temp\Xamarin\downloads\Xamarin.VisualStudio_3.9.289.msi’ failed with exception.
Exception type: Xamarin.Web.Installer.InstallException
Full stack trace:
場所 Xamarin.Web.Installer.Installer.InstallationArchiveHandler.Install(String path, Boolean needsPrivileges)
場所 Xamarin.Web.Installer.Installer.BaseSoftwareItem.InstallDownloadedItem(String url, InstallationArchiveHandler handler, DownloadServiceWorkItem download)
場所 Xamarin.Web.Installer.Installer.BaseSoftwareItem.Install(UInt32 tryNumber)
場所 Xamarin.Web.Installer.Installer.XamarinVSSoftwareItem.Install(UInt32 tryNumber)
場所 WindowsInstaller.ProgressPage.InstallationWorker()
Installation of archive ‘C:\Users\xxx\AppData\Local\Temp\Xamarin\downloads\Xamarin.VisualStudio_3.9.289.msi’ failed with exception.
Exception type: Xamarin.Web.Installer.InstallException
Full stack trace:
場所 Xamarin.Web.Installer.Installer.InstallationArchiveHandler.Install(String path, Boolean needsPrivileges)
場所 Xamarin.Web.Installer.Installer.BaseSoftwareItem.InstallDownloadedItem(String url, InstallationArchiveHandler handler, DownloadServiceWorkItem download)
場所 Xamarin.Web.Installer.Installer.BaseSoftwareItem.Install(UInt32 tryNumber)
場所 Xamarin.Web.Installer.Installer.XamarinVSSoftwareItem.Install(UInt32 tryNumber)
場所 WindowsInstaller.ProgressPage.InstallationWorker()

 

C:\Users\xxx\AppData\Local\Temp\Xamarin\downloads\Xamarin.VisualStudio_3.9.289.msi

を直接実行してみます。

 

なんとかインストールが正常に実行されているように見えます。

 

image

 

Xamarinが正常にインストールされたようなので、Windowsのスタートメニューから「Xamarin Studio」を起動してみます。

 

Xamarin Studioは単体で起動するIDE、統合開発環境のようです。メニューもちゃんと日本語化されています。

 

WS000019

 

Xamarin Studio for Windowsでは、C#、F#、VBNetで開発を行うことが出来るようですが、開発を行えるのはAndroidのみです。

 

iOS用アプリの開発には、Visual Studioを使って開発を行い、かつ、実行するにはMac OSのXamarinと通信してiOSシミュレーターを実行する必要があります。

 

 

Mac OS X 10.10 YosemiteにXamarinをインストールする

今度は、Mac OS X 10.10 Yosemiteを起動してXamarinをインストールします。

 

Xamarin App Development with Visual Studio | Visual Studio
Target all platforms with a single, shared codebase for Android, iOS, and Windows. Dowload our free IDEs on OS X and Windows with Xamarin.

からMac用のインストーラーをダウンロードして実行します。

 

image

 

インストール作業は順番に「Continue」を押すだけで進みます。

 

image

 

Xamarin for OS Xが無事にインストール出来たように見えました。

 

ここで、Xamarin for OS Xでプロジェクトを作ってみます。

 

以下のエラーが表示されました。

 

A valid Xcode installation could not be found. If your copy of Xcode is installed to a non-standard prefix, please specify the location in Xamarin Studio’s Preferences under ‘SDK Locations

 

image

 

 

どうやらXamarinを動作させるには、iOSの標準開発環境であるXcodeをインストールしておく必要があるようです。

 

XcodeはMac App Storeから無償でダウンロードすることが出来ます。

 

App StoreからXcodeをインストールします。

 

image

 

無事にXcodeがインストールされました。

 

 

ここでXamarin for OS Xを起動して、iPad用のアプリケーションを選択してデバッグ実行してみます。

 

image

 

以下のエラーが表示されました。

 

No valid iphone code signing keys found in keychain

 

どうやらデバイスの指定を間違えているようです。

 

左上のデバイスの選択で「iPad2 iOS 8.1」を選択すると無事にデバッグ実行出来ました。

 

image

 

Xamarin.iOS with Visual Studioには、スターターではダメ。ビジネスライセンスが必要

WindowsでVisual StudioのC#で開発したアプリケーションをMac OS XのXamarin.iOS Build Hostと接続します。

 

Mac OS XでXamarin.iOS Build Hostを起動してみると以下のメッセージが表示されました。

 

Using Xamarin.iOS with Visual Studio requires Business edition or higher.

 

image

 

無償のスターター(Starter)ライセンスではダメなようです。

 

やむを得ず、「Begin a Trial」を押します。

 

以下の画面が表示されて、アクティベーションが完了しました。

 

image

 

この後、Xamarin.iOS Build Hostを起動して、以下の待ち受け画面になりました。

 

ここで表示されたピン番号を控えておきます。

 

image

 

WindowsでVisual Studioを起動します。

 

iOS ⇒ iPad の「OPenGL App(iPad)」を選択します。

 

WS000024

 

「OK」を押してプロジェクトを作成します。

 

Visual Studioのメニューから

ツール(T)⇒オプション(O)を押します。

 

image

 

上記の画面から「Find Mac Build Host」を押します。

 

以下の画面が表示されます。

 

WS000075

 

「Continue」を押します。

 

One or more Xamarin.iOS Mac Build Hosts were detected on your network. Please select one and click Connect.

 

と表示されたら、Macを選択してConnectします。

 

以下の画面が表示されます。

image

 

先ほどのPIN番号を入力して、Pairを押します。

 

image

 

The PIN you entered was invalid.
Please ensure you have entered the correct PIN. You may have to close this dialog retry from Visual Studio.

 

と表示されてつながりません。

 

その後、Macを再起動するとようやくつながりました。

 

image

 

この後、Visual Studioで

「デバッグ(D)」⇒「続行(C)」を押します。

 

するとMac OS X側で、iOSシミュレーターが起動します。

 

image

 

Visual Studio側で、ステップ実行することも確認できました。

 

Visual StudioでiOS用のネイティブアプリがコンパイルされてiOSに転送されて実行されているっていうことでしょうか。

 

Xamarinのファーストインプレッション感想

 

Xamarinは2013年11月に発表したリリースからほぼ完全にVisual StudioでiOSのアプリを開発できるようになったようです。

 

マイクロソフトカンファレンス2013で大々的に取り上げられて知るようになりました。

 

正直な感想を述べると、Xamarinを使っても、iPhone/iPad用のアプリを開発するには、Mac OS Xが必ず必要になります。

それなら、わざわざXamarin for Visual Studioを使わずに、Xcodeで開発すれば十分かなという気もします。

どうしてもC#で開発したいなら、Xamarin for Mac OS Xを使ってMac OS上で開発したほうが効率がよいと思います。

 

 

Visual StudioでiPhone/iPadのネイティブアプリを開発できること自体は素晴らしい技術なのですが、どうせMac OS Xが必要になるなら、そこまでVisual Studioにこだわる人はどのぐらいいるんでしょうか???

 

Mac OS Xで開発したほうが効率いいかなと思います。。。

 

 

Xamarinのライセンス価格

今回、WindowsのVisual Studio 2012でXamarinを使ってiOSアプリを開発するには、Xamarinの無料のスターターライセンスではなくてビジネスラインセンスが必要なことがわかりました。

 

Xamarinのライセンス販売は、エクセルソフトが行っているようです。

 

ライセンス価格は以下の通りです。

一般人が手を出すにはちょっと高いかなぁ。

 

製品名

価格(税抜)

Xamarin.Android Business (年間サブスクリプション)

\127,800 (税抜)

Xamarin.Android Enterprise (年間サブスクリプション)

\243,000 (税抜)

Xamarin.iOS Business (年間サブスクリプション)

\127,800 (税抜)

Xamarin.iOS Enterprise (年間サブスクリプション)

\243,000 (税抜)

Xamarin.Mac Business (年間サブスクリプション)

\127,800 (税抜)

Xamarin.Mac Enterprise (年間サブスクリプション)

\243,000 (税抜)

 

(http://www.xlsoft.com/jp/products/xamarin/price.html からの引用です。)

 

プログラミングの無料レッスン体験

 

約8,000名の受講生と80社以上の導入実績のあるプログラミングやWebデザインのオンラインマンツーマンレッスンCodecamp

<Codecampの特徴>

1 現役エンジニアによる指導

2オンラインでのマンツーマン形式の講義

3大手企業にも導入されている実践的なカリキュラム

↓無料体験レッスン実施中です。

プログラミングのオンラインスクールCodeCamp

 

 

 

コメント

  1. […] Xamarin(ザマリン)でVisual Studioを使ってiOSアプリを作る方法 Xamarinは、Visual Stu… […]

  2. […] Xamarin(ザマリン)でVisual Studioを使ってiOSアプリを作る方法 Xamarinは、Visual Stu… […]

タイトルとURLをコピーしました