Xamarin 现在随时都会提供对 PCL 的官方支持。
在此之前,Mac 上的支持需要一些 .csproj 编辑才能构建 PC-nuget 解决方案。
构建这些项目的最简单方法是:
- 将程序集提示路径从
portable-win+net45+MonoAndroid16+MonoTouch40+sl40+wp71
路径切换到MonoTouch40
路径。
- 并将 System.Windows shim 程序集添加到列表中(如果您的核心项目使用这些区域,可能还需要 .Net 和 .Xml.Serialization shims)
在 N=21 中执行此操作后,Core csproj 文件的引用部分如下所示:
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows">
<HintPath>..\packages\MvvmCross.PortableSupport.3.0.6\lib\MonoTouch40\System.Windows.dll</HintPath>
</Reference>
<Reference Include="Cirrious.CrossCore">
<HintPath>..\packages\MvvmCross.HotTuna.CrossCore.3.0.6\lib\MonoTouch40\Cirrious.CrossCore.dll</HintPath>
</Reference>
<Reference Include="Cirrious.MvvmCross">
<HintPath>..\packages\MvvmCross.HotTuna.StarterPack.3.0.6\lib\MonoTouch40\Cirrious.MvvmCross.dll</HintPath>
</Reference>
<Reference Include="Cirrious.MvvmCross.Localization">
<HintPath>..\packages\MvvmCross.HotTuna.CrossCore.3.0.6\lib\MonoTouch40\Cirrious.MvvmCross.Localization.dll</HintPath>
</Reference>
<Reference Include="Cirrious.MvvmCross.Plugins.Json">
<HintPath>..\packages\MvvmCross.HotTuna.Plugin.Json.3.0.6\lib\MonoTouch40\Cirrious.MvvmCross.Plugins.Json.dll</HintPath>
</Reference>
<Reference Include="Cirrious.MvvmCross.Plugins.JsonLocalisation">
<HintPath>..\packages\MvvmCross.HotTuna.Plugin.JsonLocalisation.3.0.6\lib\MonoTouch40\Cirrious.MvvmCross.Plugins.JsonLocalisation.dll</HintPath>
</Reference>
<Reference Include="Cirrious.MvvmCross.Plugins.ResourceLoader">
<HintPath>..\packages\MvvmCross.HotTuna.Plugin.ResourceLoader.3.0.6\lib\MonoTouch40\Cirrious.MvvmCross.Plugins.ResourceLoader.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\MvvmCross.HotTuna.Plugin.Json.3.0.6\lib\MonoTouch40\Newtonsoft.Json.dll</HintPath>
</Reference>
</ItemGroup>
将此与https://github.com/slodge/NPlus1DaysOfMvvmCross/blob/master/N-21-Babel/Babel.Core/Babel.Core.csproj上的原始版本进行比较
如果这感觉太“hacky”,那么目前的替代方法是不使用 nuget,而是使用二进制文件夹 - 在 N=22 中有一个演练 - http://slodge.blogspot.com/2013/05/ n22-from-basics-on-mac-n1-days-of.html
希望当我写完这篇文章时,Xamarin 已经提供了他们的 PCL 支持,所以这将是过时的......