如何在Xcode中打开优化? [英] How do I turn on optimization in Xcode?

查看:120
本文介绍了如何在Xcode中打开优化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Xcode 7.2中有一些运行良好的Swift代码,但是当我从命令行运行 swift -O main.swift 来运行它的优化版本时,我的代码运行得非常快。



如何在Xcode中打开代码优化?我尝试过产品->构建为->正在运行,但这并不是以最佳速度运行。我在项目设置中看不到启用优化或发布版本的任何内容。

解决方案

选择 Product->方案->编辑方案,然后针对运行方案,您将看到它具有两个构建配置:




  • Debug :使用选项 -O0 构建,无需优化。

  • 发布:使用选项 -Os 用于最快/最小的优化。



您可以在项目的构建设置中的 Apple LLVM下找到这些值。 7.0-代码生成,优化级别



一个选项是编辑运行方案的构建配置,默认为调试,然后将其更改为发布。 / p>

另一种方法是为性能分析进行构建,默认为发布,并将构建可进行概要分析的优化版本。


I have some Swift code in Xcode 7.2 that runs well, but when I run swift -O main.swift from a command line to run an optimized build of it, my code runs really fast.

How do I turn on code optimization in Xcode? I've tried Product -> Build For -> Running, but that isn't running it at optimized speed. I don't see anything in the project settings for "enable optimization" or "make a release build".

解决方案

If you select Product -> Scheme -> Edit Scheme, then target the Run scheme, you'll see that it has two build configurations:

  • Debug: Builds with option -O0 for no optimization.
  • Release: Builds with option -Os for fastest/smallest optimization.

You can find those values in the project's Build Settings, under Apple LLVM 7.0 - Code Generation, Optimization Level.

One option is to edit the Run scheme's build configuration, which defaults to Debug, and change it to Release.

Another option is to build for profiling which defaults to Release, and will build an optimized version that can be profiled.

这篇关于如何在Xcode中打开优化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆