MAUI Blazor 常见问题
1、ZipArchive' contains bitcode
APP Store审核过程中提示 ZipArchive' contains bitcode
解决方法是在,MAUI项目的csproj文件中,Project节点下添加如下代码,编译发布时即可关闭bitcode。
<PropertyGroup>
<!-- Properties used to strip bitcode from frameworks when using Visual Studio for Mac -->
<_StripBitcodeFromFrameworksMasterAfterTargets Condition="'$(OS)'=='Unix'">_ExpandNativeReferences</_StripBitcodeFromFrameworksMasterAfterTargets>
<_StripBitcodeFromFrameworksMasterDependsOnTargets Condition="'$(OS)'=='Unix'">_StripBitcodeFromFrameworksOnMac</_StripBitcodeFromFrameworksMasterDependsOnTargets>
<!-- Properties used to strip bitcode from frameworks when using Visual Studio for Windows -->
<_StripBitcodeFromFrameworksMasterAfterTargets Condition="'$(OS)'!='Unix'">_ComputeFrameworkFilesToPublish</_StripBitcodeFromFrameworksMasterAfterTargets>
<_StripBitcodeFromFrameworksMasterDependsOnTargets Condition="'$(OS)'!='Unix'">_StripBitcodeFromFrameworksOnWindows</_StripBitcodeFromFrameworksMasterDependsOnTargets>
</PropertyGroup>
<Target Name="_StripBitcodeFromFrameworksMasterTarget" Condition="'$(_StripBitcodeFromFrameworksMasterDependsOnTargets)'!='' AND @(_FrameworkNativeReference->Count()) != 0" AfterTargets="$(_StripBitcodeFromFrameworksMasterAfterTargets)" DependsOnTargets="$(_StripBitcodeFromFrameworksMasterDependsOnTargets)" />
<Target Name="_StripBitcodeFromFrameworksOnMac" Condition="('$(OutputType)'!='Library' OR '$(IsAppExtension)'=='True') AND '$(_SdkIsSimulator)'=='False'">
<!-- Find the bitcode_strip command -->
<Exec Command="xcrun -find bitcode_strip" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="_BitcodeStripCommand" />
</Exec>
<!-- Strip the bitcode from frameworks -->
<Exec Command="$(_BitcodeStripCommand) %(_FrameworkNativeReference.Identity) -r -o %(_FrameworkNativeReference.Identity)" />
</Target>
<Target Name="_StripBitcodeFromFrameworksOnWindows" Condition="('$(OutputType)'!='Library' OR '$(IsAppExtension)'=='True') AND '$(_SdkIsSimulator)'=='False' AND '$(IsMacEnabled)'=='true'">
<!-- Strip the bitcode from frameworks -->
<Exec SessionId="$(BuildSessionId)" Command=""%24(xcrun -find bitcode_strip)" %(_FrameworkNativeReference.Identity) -r -o %(_FrameworkNativeReference.Identity)" />
<CopyFileFromBuildServer SessionId="$(BuildSessionId)" File="%(_FrameworkNativeReference.Identity)" TargetFile="%(_FrameworkNativeReference.Identity)" />
</Target>
2、希望Android MAUI Blazor字体缩放不受系统字体缩放影响
系统字体缩放会影响我们的UI显示,我们可以通过在MainActivity 重写Resources来实现强制修改字体缩放
public class MainActivity : MauiAppCompatActivity {
public override Resources Resources
{
get
{
var resources = base.Resources;
if (resources != null && resources.Configuration?.FontScale != 1.0f)
{
var configuration = resources.Configuration;
configuration.FontScale = 1.0f;
resources.UpdateConfiguration(configuration, resources.DisplayMetrics);
}
return resources;
}
}
.....