Learning and Understanding the Xcode Build System

后端 未结 2 1956
清酒与你
清酒与你 2020-12-09 09:38

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

相关标签:
2条回答
  • 2020-12-09 10:04

    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.

    0 讨论(0)
  • 2020-12-09 10:13

    When you compile a source file, the next steps are run.

    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
      
    2. 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 yo review the output.

      select .m file -> Product -> Perform Action -> Assemble
      
    3. 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.

    4. 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

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

    Take a look at example of static dynamic frameworks

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

    0 讨论(0)
提交回复
热议问题