Xamarin adventures – Differences between iOS simulator and device
I had been happily coding an iOS app (targeting iPad) using Xamarin/VS.Net with everything working fine when debugging in the iOS simulator, however as soon as I started trying to push the app to a physical device (iPad 4th gen) I started getting problems.
Problem 1 – failed to resolve System.Linq.Expressions.MethodCallExpression
The IOC framework I was using was internally using Linq expressions to construct objects. This in turn invokes some form of JIT compilation which is not allowed on iOS. (To be fair the IOC framework didn’t specifically support Monotouch, but I recompiled as a PCL and referenced it from my iOS project and all seemed to be working fine in the iOS simulator).
To fix the problem I switched out the IOC framework with TinyIoC (a simple IOC container that you can include in your project by including a single cs file – nice!).
Problem 2 – Attempting to JIT compile method ‘…’ while running with –aot-only
The ‘…’ in the error message (which has been stripped out for readability) was reference to a generic method. Even though Xamarin.iOS 6.4 includes “iOS generic compiler improvements” resulting in “fewer ‘Attempting to JIT compile method’ errors” it turns out that it didn’t like generics in one particular method that I had in the code base. (I haven’t been able to figure out exactly why this use of generics was any different to other usages).
To fix the problem I rewrote the offending code without using generics.
Thoughts
I’m loving being able to build iOS apps using familiar tools (VS.Net) and languages (C#) but it helps to be aware of some of the potential gotchas. More (hopefully not too many more) to come…
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
2012-08-06 未能在指定文件夹中创建本地存储区,请选择其他位置。可以检查事件日志以了解详细信息
2010-08-06 SQL Server 2000 安装错误,解决方法 Process Exit Code: (1060) 指定的服务未安装
2010-08-06 SQLServer无法安装-提示command line option syntax error
2010-08-06 SQL未能排它地锁定数据库以执行该操作解决
2010-08-06 MS SQL 2000 安全设置
2010-08-06 SQL日志文件丢失,只有MDF恢复