分享方式:


Xamarin Apple 專案移轉

適用於 iOS 應用程式的 .NET 8 項目類似於下列範例:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0-ios</TargetFramework>
    <OutputType>Exe</OutputType>
    <Nullable>enable</Nullable>
    <ImplicitUsings>true</ImplicitUsings>
    <SupportedOSPlatformVersion>13.0</SupportedOSPlatformVersion>
  </PropertyGroup>
</Project>

對於連結庫專案,請完全省略 $(OutputType) 屬性,或指定 Library 為屬性值。

MSBuild 屬性的變更

下表顯示如何將 Xamarin Apple 專案中的屬性對應至 .NET 專案:

屬性 說明 .NET 項目轉換
MtouchExtraArgs mtouch 的其他自變數。 有些自變數仍然適用,有些自變數則不適用。 複製
MtouchArch 應用程式架構(s)。 N/A 轉換為 RuntimeIdentifier。 如需詳細資訊,請參閱 轉換為 RuntimeIdentifier
XamMacArch 應用程式架構(s)。 N/A 轉換為 RuntimeIdentifier。 如需詳細資訊,請參閱 轉換為 RuntimeIdentifier
HttpClientHandler 預設值為 HttpClientHandler UseNativeHttpHandler 轉換為 UseNativeHttpHandler。 如需詳細資訊,請參閱 轉換為UseNativeHttpHandler
MtouchHttpClientHandler 預設值 MtouchHttpClientHandler. UseNativeHttpHandler 轉換為 UseNativeHttpHandler。 如需詳細資訊,請參閱 轉換為UseNativeHttpHandler
EnableCodeSigning 指定是否啟用程式代碼簽署。 複製
CodeSigningKey 指定程式代碼簽署金鑰。 重新命名為 CodeignKey
CodesignKey 指定程式代碼簽署金鑰。 複製
CodesignProvision 指定布建配置檔。 複製
CodesignEntitlements 權利檔案的路徑。 複製
CodesignExtraArgs 額外的程式代碼簽署自變數。 複製
PackageSigningKey 指定要簽署封裝的程式代碼簽署金鑰。 複製
PackagingExtraArgs 指定封裝工具的額外自變數。 複製
ProductDefinition 封裝時要使用的產品定義檔路徑。 複製
MtouchEnableSGenConc 重新命名為 EnableSGenConc
EnableSGenConc 複製

轉換為 RuntimeIdentifier

下表顯示如何將 和 屬性轉換成 MtouchArch 屬性,或RuntimeIdentifiers將 Xamarin.iOS 項目移轉至RuntimeIdentifier適用於 iOS 的 .NET 時XamMacArch的屬性:

RuntimeIdentifier RuntimeIdentifiers
ARMv7 ios-arm
ARMv7s ios-arm
ARMv7+ARMv7s ios-arm
ARM64 ios-arm64
ARMv7+ARM64 ios-arm;ios-arm64
ARMv7+ARMv7s+ARM64 ios-arm;ios-arm64
x86_64 iossimulator-x64
i386 iossimulator-x86
x86_64+i386 iossimulator-x86;iossimulator-x64

重要

如果您有多個運行時間識別碼,請使用 RuntimeIdentifiers 屬性,而不是 RuntimeIdentifier 屬性。

下表顯示將 Xamarin.Mac 項目移轉至 .NET for macOS+ 時,如何將 和 XamMacArch 屬性RuntimeIdentifier轉換成 MtouchArch 屬性:

屬性 RuntimeIdentifier
x86_64 osx-x64

下表顯示將 Xamarin.tvOS 專案移轉至 .NET for tvOS 時,如何將 和 XamMacArch 屬性RuntimeIdentifier轉換成 MtouchArch 屬性:

屬性 RuntimeIdentifier
ARM64 tvos-arm64
x86_64 tvossimulator-x64

如需屬性的詳細資訊 RuntimeIdentifier ,請參閱 RuntimeIdentifier。 如需運行時間標識碼的詳細資訊,請參閱 .NET RID 目錄

轉換為 UseNativeHttpHandler

下表顯示將 Xamarin Apple 專案移轉至 .NET 8 時,如何將 和 MtouchHttpClientHandler 屬性UseNativeHttpHandler轉換成 HttpClientHandler 屬性:

UseNativeHttpHandler
HttpClientHandler false
NSUrlSessionHandler 未設定
CFNetworkHandler 未設定

其他項目的變更

下表顯示如何將 Xamarin Apple 專案中的其他項目對應至 .NET 專案:

項目 說明 .NET 項目轉換
LinkDescription Managed 連結器的其他 XML 檔案。 相同 複製

Info.plist 的變更

某些值已從 Info.plist 移至項目檔。

MinimumOSVersion 和 LSMinimumSystemVersion

MinimumOSVersionLSMinimumSystemVersion 屬性應該轉換成 .NET 8 專案中的屬性SupportedOSPlatformVersion。 如需詳細資訊,請參閱 確定 MinimumOSVersion 與 SupportedOSPlatformVersion 一致。

另請參閱