我是靠谱客的博主 无奈铃铛,这篇文章主要介绍ios swift 宏定义Ifdef 模拟器 真机,现在分享给大家,希望可以做个参考。

swift

#if (arch(i386) || arch(x86_64)) && os(iOS)
    ...
#endif

swift 4.1 后

#if targetEnvironment(simulator)
  // your simulator code
#else
  // your real device code
#endif

原来可以这么写

#if TARGET_OS_IPHONE
#endif


#if !TARGET_IPHONE_SIMULATOR
#endif

参考

ios - How to detect if app is being built for device or simulator in Swift - Stack Overflow

Apple Developer Documentation

最后

以上就是无奈铃铛最近收集整理的关于ios swift 宏定义Ifdef 模拟器 真机的全部内容,更多相关ios内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(122)

评论列表共有 0 条评论

立即
投稿
返回
顶部