关于Xcode

本文在Xcode4.6基础上介绍的,不一定适用其他版本的Xcode。

关于DWARF与dSYM

DWARF is a debugging file format used by many compilers and debuggers to support source level debugging. It addresses the requirements of a number of procedural languages, such as C, C++, and Fortran, and is designed to be extensible to other languages. DWARF is architecture independent and applicable to any processor or operating system. It is widely used on Unix, Linux and other operating systems, as well as in stand-alone environments.

DWARF与dSYM的关系是,DWARF是文件格式,而dSYM往往指一个单独的文件。在Xcode中如果不做特殊制定,debug information是被保存在executable文件中,可以使用dsymutil从executable中提取dSYM文件。

dsymutil

dsymutil is a tool to manipulate archived DWARF debug symbol files. 使用dsymutil可以对dSYM文件进行如下操作:从exe_path中提取成dSYM文件、将executable或者object文件中的symbol table dump出来、更新dSYM文件以让dSYM文件包含最新的accelerator tables and other DWARF optimizations。

Debug Info Format

在Xcode中可以选择DWARF和DWARF with dSYM file,推荐的设置是Debug用DWARF;Release使用DWARF with dSYM file。

使用dSYM file

如果我们有若干的build,有若干dSYM文件,而名字又有点乱,想知道哪个dSYM跟哪个build匹配,从而可以使用它们呢?办法就是查看UUID。

下面就是看怎么加载dSYM file了

关于dSYM和debug,这里有更多的信息。 

Build Architecture in Xcode

在Xcode中可以指定‘64-bit Intel’, '32-bit Intel'和’Standard (32/64-bit Intel)‘三种Architecture,但是实际上是只有两种:i386和x86_64。’Standard (32/64-bit Intel)‘也被映射为x86_64。这个可以从Valid Architecture中看到。i386是为32位上编译的,而且只能在32bit OS上执行;x86_64而是为64位编译的。

Mac OS X running on 64-bit hardware can (so far) always run 32-bit software, but Mac OS X running on 32-bit hardware can only run 32-bit software. Mac OS X itself was built for both until Lion; now, it requires a 64-bit Mac. 

So the only reason to build for 32-bit is that you want to support five-year-old hardware (e.g., if that's what you have). If you'd rather get the newer language features and don't mind abandoning the customers who have five-year-old Macs, then go 64-bit-only and don't look back.

That's assuming, of course, that you don't have any hand-written i386 assembly code or code that uses no-longer-supported functions in Carbon. If you do, then that's another potential incentive to stick with 32-bit. Just be aware that support for 32-bit programs in Mac OS X may go away someday.

Add new framework/link binaries to Xcode 

下面是添加framework的步骤:

  1. In the project navigator, select your project
  2. Select your target
  3. Select the 'Build Phases' tab
  4. Open 'Link Binaries With Libraries' expander
  5. Click the '+' button
  6. Select your framework

当我们打开'Build Phases' tab时,可以看到还有其他项目:Target Dependencies, Compile Sources, Link Binaries With Libraries,Copy Bundle Resources四项。已经介绍过一个了,Target Dependencies是将本project文件中的target建立依赖关系,Compile Sources是包含这个target需要编译的文件列表,还有就是Copy Bundle Resources就是一些xib文件、strings文件等。

如果我们有两个project文件A和B,A中编译出一个static library AS,一个dynamic library AD, 而B的target需要引入对他们的依赖,如何操作呢? 不论static 还是dynamic的都是在Link Binaries With Libraries中设置的。

Xcode中使用xcconfig文件

创建xcconfig文件:Pick File | New, choose Other and "Configuration Settings File", this gets you a new .xcconfig file.

制定xcconfig文件:Then click on the project icon on the upper left in the Project Navigator, on the right side, project/target list will show and click the project you want to edit, then it will show a page with Info and Build Settings tabs, choose Info tab, then you will see Deployment Target/Configurations/Localizations. In the Configurations section, you can specify which config you want to use for debug/Release, etc. 'Based on Configuration File' column is the xcconfig file name will be used.

使用Xcode中的Scheme

Scheme是包含描述Xcode一系列行为的配置,每次我们在Xcode中添加一个Target,就会自动添加一个Scheme,但这是Xcode的行为,并不意味着Target与Scheme是一一对应的关系。Scheme可以对应多个Target,一个Target也可以在多个Scheme被描述。Scheme描述了如下行为:Build,Run Test, Test, Profile, Analyze和Archive。其中Run Test是制定一个第三方的应用来启动我们的程序,并配置好命令行参数等信息来执行的。 

Xcode、GDB与LLDB

LLDB is a next generation, high-performance debugger. It is built as a set of reusable components which highly leverage existing libraries in the larger LLVM Project, such as the Clang expression parser and LLVM disassembler.

LLDB is the default debugger in Xcode on Mac OS X and supports debugging C, Objective-C and C++ on the desktop and iOS devices and simulator. 

虽然LLDB是默认的debugger,但是LLDB还不成熟,而GDB却经历多年发展,非常程序,LLDB能干的事,GDB都可以,所以,在LLDB成熟之前,还是选GDB吧。

原文链接: https://www.cnblogs.com/whyandinside/archive/2013/04/28/3048366.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    关于Xcode

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/86423

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月9日 下午10:33
下一篇 2023年2月9日 下午10:34

相关推荐