20

Alright, I'm curious about the build process with Xcode. Setting up multiple Targets, how to automate versioning and generally understanding the system so I can manipulate it to do what I want.

Does anyone have any books or can point me to some documentation somewhere so that I can figure all of this out?

Thanks a ton.

Another thing, if anyone actually sees this since changing it.

But any books anyone is aware of that will focus on Xcode 4? There's Xcode 3 Unleashed but I'd be real curious if there are any books that focus heavily on Xcode 4.

gks
  • 785
  • 1
  • 7
  • 11

2 Answers2

10

One thing that is really essential for consistent, reproducible, automatable builds is knowledge of the xcodebuild command. Sadly I can't find any official docs on it apart from the manpage (type man xcodebuild). There's a useful guide to automating iphone builds here that includes building with xcodebuild and versioning with agvtool. This is just as relevant to general building of Mac apps.

Generally building with xcodebuild is very simple:

cd project_dir
xcodebuild -project myproject.xcodeproj -configuration Release ARCHS="x86_64 i386" build

Once you can build from a script like this it's very easy to slot into an automated build system.

the_mandrill
  • 28,524
  • 6
  • 61
  • 90
  • Now this is the type of stuff I'm looking for. Thanks! – gks Apr 21 '11 at 18:15
  • It works great! But can I get progress of build ? Which one file compiling, how many files in project, etc? thanks – Sergey Kopanev Nov 15 '11 at 23:12
  • xcodebuild usually needs some other software like security (open up the user's keychain) and PlistBuddy (update values like build number) to create a fully automated build. – Gerard Apr 29 '15 at 05:03
0

Xcode build process

Xcode uses xcodebuild internally

[ONLY_ACTIVE_ARCH]
[Bitcode]
[SKIP_INSTALL]
[DEFINES_MODULE]

.swift -> Abstract Syntax Tree(AST) -> Swift Intermediate Language(SIL) -> Intermediate Representation(IR) -> .o 

Xcode exposes some of these steps:

  1. Preprocessing:
  • Replace macros

  • Splits .h and .m.

    In Xcode, you can look at the preprocessor output of .m file by selecting

      select .m file -> Product -> Perform Action -> Preprocess
    
  1. Compiling - translates a low-level intermediate code.
    Often you can see this file when debug a code that you are not owned. Xcode allows you to review the output.

     select .m file -> Product -> Perform Action -> Assemble
    
  2. Assembling(produce .o) - translates code into object file (.o file)[Mach-O] In Xcode, you’ll find these object files inside the <product_name>.build/Objects-normal folder inside the derived data directory.

  3. Static Linking(produce .app, .a, .framework ...) - It is a part of static linker that has to resolve symbols between object files and libraries/frameworks. This process produce a merged executable file which can contain additional resources and dynamic binary

  4. Dynamic linking - linking in a loading or runtime. This process can generate errors during binary execution

Also you can use Xcode Report Navigator to learn more about build process

[LLVM]

[Static vs Dynamic linking]

yoAlex5
  • 21,739
  • 5
  • 148
  • 151