トライアル版を放り込んだのが土曜日ですが、色々あって、もう火曜日です。
月曜は9時半まで残業でした。
仕様書書くの面倒です。
愚痴終了。
本題。

タイトル通り、初心に返ってHello,World!!しましょう。
こんなの書いたの何年ぶりかと。
C#に触れたのが大学1年か2年だから?7年振りくらいですね、この気持ち。

さて、とりあえずさくっと、サンプルを作りますか。

1

Xamarin.iOSをインストールするとこんな項目が増えています。iPad,iPhone,Universal
ここはどっちでも動きそうなUniversalにしましょうか。

で、HelloWorld Applicationを選択して作成。

で、しばらくMacと接続してると、準備が終わってソリューションエクスプローラーに出てきます。

2

  • MyViewController.cs
  • AppDelegate.cs
  • Info.plist
  • Main.cs

Info.plistって何?

3

って開いたのがこれ。
設定ファイルみたいものね。
ちなみにエクスプローラーから開くと中身はただのxmlでした。

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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"[]>
<plist version="1.0">
<dict>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>MinimumOSVersion</key>
<string>3.2</string>
</dict>
</plist>

Xamarinのページによると、

Info.plist In addition to source code editing, the tabbed interface includes support for certain platform specific files. For example, when opening an Info.plist file, which is used by iOS applications to store various configuration data, the following user interface is presented to allow easy editing of the file:

~略~。例えば、Info.plistを開くと、これは。様々な設定データを保存するためにiOSアプリケーションに使用され、下(※この説明文の下に画像があります)のユーザーインターフェイスはこのファイルを簡単に編集できるのがわかります。

やっぱり設定ファイルですね。

で、とりあえずビルド。
が、動きません。

とりあえず、

Application Name is not set in iOS Application Property Page Identifier is not set in iOS Application Property Page

これは、アプリケーション名がiOSアプリケーションのプロパティページで設定されていません iOSアプリケーションプロパティページで識別子が設定されていません

ですんで、Info.plistを見ます。

まあそれらしいのがあるけど、何入れるの?

Xamarinのページによると、

Application name: Corpy2 Indentifier:com.zamarin.sample.corpy2 Version:1

ってあった。Application nameはわかるけど、IdentifierってJavaの名前空間みたいね。きもちわるいわー。
とりあえず適当に放り込んで…

クラッシュした\(^o^)/

気持ち新たにもう一回。

あれ?入力しても保存されない?ビルドしても同じエラー。
なんぞ?よーわからんので、プロジェクトファイルのプロパティを見ると…

こんなん出ましたけどー。

なので、iOS Applicationから、Application name、Indentifier、Versionを放り込んで再度ビルド。

キタ―――(゚∀゚)―――― !! 嘘です。

ERROR: Could not find the selected device Available devices: iPhone (Retina) 7.1 iPad 7.1 iPad (Retina) 7.1 Try to refresh the device list with the Refresh button


選択したデバイスが見つかりません。利用可能なのは、iPhone (Retina) 7.1,iPad 7.1,iPad (Retina) 7.1。リフレッシュボタンを押してデバイスリストを更新して。

って言われても…

ん?
これですか?

どっちにつなぐの?Windows?Mac?
Macにつないでみたら、VisualStudioの表示が変わりました。

だめだ、ビルドしても同じエラー。困った。
…ひょっとして、実機は駄目?
というか、iPhoneSimulatorが無いんですが?

…あ、ソリューションプラットフォームから選択ですか? iPhoneになっているのをiPhoneSimulator これでビルド!!

動きましたーーーー 1時間くらい経ってようやくここまできました。
実機が駄目だったりしましたが、とりあえず動かすことが出来たので、次はソースを編集してサンプルをいじくり回したいと思います。