Xcode编译选项有关资料

关于Xcode编译性能优化的研究工作总结 关于Xcode编译性能优化的研究工作总结本文为原创文章,转载注明出处,谢谢!本文链接:关于Xcode编译性能优化的研究工作总结近来(8月1–8月12)结合Xcode的官方文档和网上资料经验对Xcode的一些配置选项进行了编译优化的尝试研究,所谓优化主要从编译耗时及编译出的安装包大小进行优化。在研究分析过程中将手上的几个Demo项目进行了编译测试,有Swift项目也有Object-C项目。此外,对于不 阅读详情

转自:http://blog.sina.com.cn/s/blog_666380790100hlto.html


This is a collection of the most useful hidden and hard-to-find settings in Xcode related to building, debugging and file templates.

This post is about hard-to-find settings in Xcode that most programmers can't live without. I felt strange writing a post on this topic since most of this information is documented elsewhere. But I still find myself forgetting and needing to rediscover these tidbits (even though I've been using ProjectBuilder/Xcode for 7 years and should remember), so I think that it's probably information worth reinforcing.

Custom compiler settings

The default compiler settings in Xcode projects are pretty good. Even so, it's a programmer's mission to play with everything and playing with the compiler settings is at the heart of a programming project.

Custom compile settings are buried pretty deep in Xcode. To access the custom compiler settings, you must:

  1. Have a project window or project-contained document window frontmost in Xcode.
  2. Select the menu item "Edit Project Settings" from the "Project" menu in the menubar 
    or
    Right-click the project icon in the "Groups & Files" tree-view of the Project window and select "Get Info" from the popup menu (the project's icon is a blue document icon located at the very top of this tree-view by default).
  3. Select the "Build" tab at the top of the Project Info window that appears.
  4. Set the "Configuration" to "Debug", "Release" or "All Configurations" from the popup menu at the top of the tab panel (compile settings will only be changed for the configuration that you select).
  5. Scroll down to the heading named "GCC 4.0 - Language".
  6. Each of these checkboxes allow customization of build settings. If you want to know what setting each will affect, click on the row and show the "Research Assistant" (Control-Command-?).

Completely custom command line settings can be passed to the compiler using the "Other C Flags" line (for C and Objective-C) or the "Other C++ Flags" (for C++).

More on Xcode's build settings can be found in the "Xcode Build Setting Reference".

Post or pre build scripts

Build phases are how Xcode performs the different steps in a build. If you expand one of the targets in the "Targets" node of the "Groups & Files" tree-view of the Project window, you can see the different steps in the build. For a normal "Cocoa Application", the steps will be "Copy Bundle Resources", "Compile Sources" and "Link Binary with Libraries".

You can add a new build stage to a target by right-clicking the target and selecting the build phase you want from the "Add" submenu of the popup menu.

You can also choose one of the options in the "New Build Phase" submenu of the "Project" menu in the menubar to add a build phase to the current target.

To add a "script" build stage, select "New Run Script Build Phase". This will add a new script as the last phase of the build. If you want the script to be a "pre-build" script, you must drag it to the top of the list of build phases shown for the target in the "Targets" node of the "Groups & Files" tree-view of the Project window. An "inter build" script would also be possible by dragging to a location between other stages.

Finally, you must enter the script itself. Select the build phase and choose "Get Info" from the "File" menu in the menubar. Select the "General" tab and you can enter the script in the "Script" field.

A list of variables you can use in your script is listed on the Run Script Build Phase page of the Xcode documentation.

Changing the built program's name

This can be a little tricky to find since the the built program's name ("MyProgram.app" for example) does not exist in any complete form in Xcode.

  1. Have a project window or project-contained document window frontmost in Xcode with the "Active Target" set to the target whose product you'd like to rename.
  2. Select the menu item "Edit Active Target '...'" from the "Project" menu in the menubar 
    or
    Right-click the target's name under "Targets" in the "Groups & Files" tree-view of the Project window and select "Get Info" from the popup menu.
  3. Select the "Build" tab at the top of the Project Info window that appears.
  4. Set the "Configuration" to "Debug", "Release" or "All Configurations" from the popup menu at the top of the tab panel (compile settings will only be changed for the configuration that you select).
  5. Scroll down to the heading named "Packaging".

The name of the application will be a combination of the "Executable Prefix" (normally empty), the "Product Name" (initially the same as the Project's name), the "Executable Prefix", and the "Wrapper Extension" (normally ".app" for Applications).

In short, most of the time you will just need to change the "Product Name" field.

Replacing __MyCompanyName__ in the new file templates

Enter the following line:

defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{ "ORGANIZATIONNAME" = "Your Company Name" ; }'

into a Terminal window, replacing "Your Company Name" with whatever you choose.

You can also open the file at ~/Library/Preferences/com.apple.Xcode in "Property List Editor" and insert your company name as a string value for the key "ORGANIZATIONNAME" under the dictionary "PBXCustomTemplateMacroDefinitions". You may need to create "PBXCustomTemplateMacroDefinitions" at the top level if it doesn't already exist.

Changing the new file templates

The complete set of file templates that Xcode uses for new files can be found at "/Developer/Library/Xcode/File Templates/", sorted by API (we love Cocoa the best).

You can add or modify them as you choose, although it's a good idea to backup changed files at a different location since "/Developer/Library/Xcode/File Templates/" may be lost if you move your account to a new computer or reinstall Xcode.

Text macros

The "Text macros" in Xcode are a great time saver. You can find them under "Insert Text Macro" in the "Edit" menu but they are most useful when you know their shortcuts. Type the shortcut in a document in Xcode when you're editing, hit "F5" to autocomplete and it expands the macro to its full form, complete with variable locations.

For a full list of the default text macros and their shortcuts, visit Apple's "Xcode User Guide: Repeating Code".

The first way to customize text macros are to create entries for "BlockSeparator", "IndentedBlockSeparator", "InExpressionsSpacing", "PostBlockSeparator" and "PreExpressionsSpacing" in the "XCCodeSenseFormattingOptions" dictionary in your "com.apple.Xcode" preferences file.

As before, you can do that like this:

defaults write com.apple.Xcode XCCodeSenseFormattingOptions '{ "BlockSeparator" = "\n" ; }'

or by editing the "~/Library/Preferences/com.apple.Xcode" file directly.

You may also want to add completely new macros or customise more than these variables will allow. The best way to do this is to copy the "TextMacros.xctxtmacro" directory from:

/Developer/Applications/Xcode/Contents/PlugIns

to

~/Library/Application Support/Developer/Shared/Xcode/Specifications

and modify or add to the macros that Apple provide.

It is not advisable to edit the original "TextMacros.xctxtmacro" definitions contained inside Xcode.app directly. We copy them to our own Library since the Xcode.app versions will be replaced without warning every time you update Xcode.

Note: the destination path to which you should copy "TextMacros.xctxtmacro" is correct here but wrong in the Apple-provided "Repeating Code" documentation linked above (the documentation currently omits the "Xcode" directory between "Shared" and "Specifications").

Macros are sorted by programming language. I'll leave you to work out exactly how the macros are formatted. I'm not aware of any formal documentation for the xctxtmacro file format but it's plain text in a "Property List"-style format so you shouldn't find it too hard to decipher.

Environment Variables and Executable Arguments

With the desired Project and Target selected, choose "Edit Active Executable ..." from the "Project" menu in the menubar. The environment variables and executable arguments can be chosen on the "Arguments" tab.

The following environment variables are of particular importance when programming in Cocoa:

  • NSDebugEnabled set to value YES — turns on extra debug information in Foundation
  • NSZombieEnabled set to value YES — notifies when messages are incorrectly sent to deallocated objects allowing better debugging of this problem

For more debugging environment variables, check the "Technical Note TN2124: Mac OS X Debugging Magic" page from Apple.




苹果官方:

http://developer.apple.com/library/mac/#recipes/xcode_help-project_editor/Articles/AddingaRunScriptBuildPhase.html


http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/0-Introduction/introduction.html


关于适配XCode 12 跑模拟器编译报错的错误 报错内容: building for iOS Simulator, but linking in object file built for iOS, xxxx for architecture arm64 项目再迁移到XCode12 的时候跑模拟器遇到了下面这个报错。真机没有问题 在Stack Overflow: xcode-12-building-for-ios-simulator-but-linking-in-object-file-built-for-ios上查大多数都给出了在build set 阅读详情

相关推荐

【开发技巧】OS X上搭建distcc使用XCode进行分布式编译

distcc 是 google开源的分布式编译工具,通过使用它可以提高编译速度。 本人通过对XCode进行研究,让其也能使用distcc从而实现分布式编译。

lucky_06的专栏 7740

XCode如何添加编译选项

1)命令行:比较简单,直接通过OTHER_CFLAGS就可以添加。 xcodebuild -project RSAUtil.xcodeproj build OTHER_CFLAGS="-Xclang -g " 2) 界面上添加 选择【项目】->【Building Settings】->【Apple Clang - Customer Clang Flags】 双击 其中一行...

jimmyleeee的专栏 5793

CCC数字钥匙Release 3实战:如何用BLE/UWB实现无钥匙进入(附避坑指南)

本文深入解析CCC数字钥匙Release 3标准下BLE/UWB无钥匙进入系统的开发实践,涵盖硬件选型、安全测距协议、时序同步等关键环节,并提供实战调试技巧与安全攻防案例。特别针对BLE芯片配置、UWB模块选型等常见陷阱给出解决方案,帮助开发者高效实现厘米级精度的数字钥匙系统。

weixin_29326909的博客 254

Xcode 常用编译选项设置

Xcode 常用编译选项设置 在xcconfig文件中指定即可。 用标准库连接 LINK_WITH_STANDARD_LIBRARIES = YES如果激活此设置,那么编译器在链接过程中会自动使用通过标准库的链接器。 Info.plist 输出编码 INFOPLIST_OUTPUT_FORMAT = binary指定Info.plist文件的输出编码(默认情况下,输出与输...

aycj34508的博客 434

Shopee 虾皮API接口:商品详情采集的实践

随着电商行业的蓬勃发展,数据采集和分析在商业决策中扮演着越来越重要的角色。Shopee作为东南亚领先的电商平台,拥有大量的商品数据。通过Shopee的API接口,我们可以方便地获取商品详情,为数据分析和市场研究提供有力支持。本文将介绍如何使用Shopee API接口采集商品详情,并分享一些实践技巧。提供了丰富的数据接口,包括商品详情、店铺信息、订单数据等。通过API接口,开发者可以轻松地获取Shopee平台上的数据,进行进一步的处理和分析。Shopee API接口:商品详情采集的实践与技巧。

An4480的博客 1881

Windows下构建ImGui.Net

工具 Visual Studio 2017 操作 下载项目 git clone https://github.com/mellinoe/ImGui.NET.git 编译 右键以下两个项目并调试: ImGui.NET.SampleProgram ImGui.NET.SampleProgram.XNA Error fix 中间遇到一些问题: SDK版本不对 去微软官网下载安装对应版本 由于设置了代理被远程服务器拒绝连接 关闭代理(也许在环境变量中) nuget源无对应资源,404 NOT FOUN

jojozym的博客 1486

[Xcode]Xcode中的编译过程以及编译器

编译过程基本的编译过程分为四个步骤:预处理(Pre-process):把宏替换,删除注释,展开头文件,产生 .i 文件。编译(Compliling):把之前的 .i 文件转换成汇编语言,产生 .s文件。汇编(Asembly):把汇编语言文件转换为机器码文件,产生 .o 文件。链接(Link):对.o文件中的对于其他的库的引用的地方进行引用,生成最后的可执行文件(同时也包括多个 .o 文件进行 li...

超越 8029

Ubuntu下NVIDIA驱动安装全攻略:从报错到完美运行nvidia-smi的完整流程

本文提供了在Ubuntu系统中安装NVIDIA驱动的完整解决方案,重点解决因驱动版本冲突、内核模块未加载或Secure Boot安全启动导致的`nvidia-smi`报错问题。通过彻底清理旧驱动、处理Secure Boot、选择兼容版本并正确安装,最终确保驱动完美运行。

weixin_29196891的博客 364

xcode编译-优化策略

代码层面优化 1.在Objective-C的项目中, @class通常放在.h文件中, 主要作用在于提升编译性能, 且能防止头文件的递归import. 编译性能的考虑 通常, 使用#import引入一个类的头文件, 编译时会将该类的头文件中的所有信息都引入, 包含属性和方法, 但有时候却不需要这么多, 且包含这些信息会降低编译性能. 而@class就表示这只是一个类而已, 我们所关心的仅...

Ideainnet 3106

PCB设计AD规则设置(按照嘉立创设置)

按照嘉立创的相关加工能力进行设置: 1.Hole Size(钻孔孔径) 嘉立创要求钻孔孔径在0.2-6.3mm,并给了公差(如下图给出了钻孔孔径和公差) 规则设置位置:Manufacturing->Hole Size,这里就改一下数值,最小设置为0.2mm,最大设置为6.3mm 2.Width(线宽) 嘉立创要求线宽多层板双层板最小为3.5mil,单双层板最小为5mil(如下图给出了线宽) 规则设置位置:Routing->Width,我目前只画过双层板,按我的设置如下,最小的线宽设置为10

subtitle_的博客 4万+

用Python玩转LQR控制:3行核心代码实现倒立摆稳定控制(附Jupyter Notebook)

本文通过Python实战演示了如何使用LQR算法实现倒立摆的稳定控制。文章以直观方式解释LQR原理,提供从系统建模、核心代码求解到参数调优的完整流程,并附有可运行的Jupyter Notebook代码。重点介绍了如何利用SciPy库快速计算最优反馈增益,并通过仿真验证控制效果,为运动控制实践提供了即学即用的指南。

weixin_29311017的博客 83

XCODE编译初学

在工作中,采用XCODE编译IOS客户端sdk,在此记录使用XCODE的一些事项(我所采用的xcode版本为11.6) 1.打开项目,打开xcodeproj 2. 编译工程,点击左上角的编译符号 3. 真机编译vs模拟机编译 在进行编译之前,最好先进行clean,防止之前编译的中间文件造成影响, clean 方式:cmd+shift+K或者菜单栏 product--clean build Folder 真机编译:左上角选择架构为,编译完成后,可用lipo -info查看架构,应为armv7,

Jum_Summer的博客 3272

JavaScript - Blob / File / base64 使用场景介绍与相互转换

前言 本文首先介绍一下这三种对象使用场景,最后介绍下它们之间互转格式的解决方案。 您前端一旦涉及到文件或图片上传到服务器, 就势必离不了Blob/File/base64三种主流的类型。 Blob MDN:https://developer.mozilla.org/zh-CN/docs/Web/API/Blob 您可以观察到,像一些图片处理插件(例如有名的vue-cropper)图片裁剪插件, 它们将图片处理完毕后,都将使用blob对象返回处理好的图片,供开发者用于上传服务器。

🏆 前端领域优质创作者 4491

XCode编译器介绍

    在XCode中,我们经常会看到这些编译选项(如下图),有些人可能会有些茫然,本文将对GCC4.2、LLVM GCC 4.2、LLVM compliler 2.0三个编译选项进行一个详细的介绍。   GCC     GCC(GNU Compiler Collection,GNU编译器套装),是一套由 GNU 开发的编程语言编译器。它是一套以 GPL 及 LGPL 许可证所发行的...

weixin_34088583的博客 946

写给开发人员的实用密码学 - Hash算法

说到Hash(哈希),开发人员应该不陌生,比如Hash表是一种非常常用的数据结构,通过Hash表能够根据键值快速找到数据。哈希函数将文本(或其他数据)映射为整数,从而能够提高检索效率。密...

云水木石 1503

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Xcode 编译选项详解

以下所有编译选项都基于Xcode 4.6。本文基于Apple Xcode文档、《Professional Xcode 3》、以及Google搜索结果翻译而成。我对于编译认识较浅。如有解释不当的地方请谅解。在某些翻译可能会不恰当的地方,都附上了英文原文。 Architectures 架构 Additional SDKs 在编译的时候需要附加的SDK。 Architectures 支持的

江湖两把刀的技术博客 2807

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

Xcode 编译速度慢是什么原因?如何提高编译速度?

2. 编译选项设置不当:Xcode 提供了一些编译选项,例如优化级别、调试信息等,不同的选项设置会影响编译速度。5. 使用缓存和预编译机制:Xcode 提供了缓存和预编译机制,可以将一些较少变动的文件或者库进行预编译,以减少编译时间。4. 编译器版本不匹配:Xcode 的每个版本都附带了一个特定版本的编译器,如果你的项目使用了较旧的编译器进行开发,可能会导致编译速度变慢。3. 频繁的依赖项更新:如果你的项目依赖于其他库或者框架,并且这些依赖项经常更新,那么每次编译都需要重新编译依赖项,这会增加编译时间。

2301_80794191的博客 1700

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

加快XCode的编译链接速度(200%+)—XCode编译速度慢的解决方案

最近在开发一个大项目的时候遇到一个很头疼的问题,由于项目代码较多,每次都要编译链接1分钟左右,调试的时候很浪费时间,于是研究了一下如何提高编译链接的速度,在这里分享给大家。

心砚THU的专栏 3万+

IOS5 XCODE4.2每次全部编译文件的问题

无论我是否修改文件,所有的文件都必须重新编译一次,实在是非常浪费时间。 网上查到一点资料 源地址:http://hi.baidu.com/%CD%F5%D7%D36%BA%C5/blog/item/6053bea4a37c9aea9052eef3.html 关于xcode4全量编译 会全部重新编译的问题 2011-11-28 11:24 这二天,项

zltianhen的专栏 2877

Xcode 中的编译过程以及编译器

Xcode的编译过程: 基本步骤大概可以分为4个: (1).预处理(Pre-process):把宏替换,删除注释,展开头文件,产生.i文件 (2).编译(Compliling):把之前的.i文件转换成汇编语言,产生.s文件 (3).汇编(Asembly):把汇编语言文件转换为机器码文件,产生.o文件 (4).链接(Link):对.o文件中的对于其他的库的引用的地方进行引用,生成最后的可执行文件(同时也包括多个.o文件进行 link) 通过解析 xcode 编译 log,可以发现...

程序猿老樊的博客 2507

MacOS下XCode配置OpenCV,开启QT选项。

安装布置下载CMake下载OpenCV下载QT编译OpenCV发生错误:![在这里插入图片描述](https://img-blog.csdnimg.cn/20190127173731383.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2x...

lzf_lamer的博客 1071

libUV编译步骤以及参与编译的源文件编译选项链接选项

libUV库下载地址: https://github.com/libuv/libuv https://dist.libuv.org/dist/ 解压之后,进入源文件打开readme.md文件就可以看到编译步骤 别人libUV的blog Build Instructions For GCC there are two build methods: via autotools or via GYP. ...

qq_36451221的博客 808
上一篇: 使用UIPickerView需要注意的问题时候
下一篇: 打包程序如何生成程序下的资源目录
StudyRecord
博客等级 码龄16年 96粉丝 114原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值