Anatomy of iOS Application Build process (Obj-C)

In this article, I’ll take a close look at the build report, hoping to learn something that helps to improve my development efficiency down the road. I believe knowing what’s going on under the hood helps to resolve problems much faster. I used Xcode Version 8.2.1 (8C1002) and build report may look different in other versions.

Build log analysis in Xcode #

In order to produce the most basic build report, I created a new single view application “ObjHelloWorld”, then run on my iPhone 6s Plus device (⌘r). Once the project is built and start running, open the Report Navigator (⌘8) and expand “ObjCHelloWorld” target, select most recent build session.

build_report.png

As you can see in the screenshot above, there are 13 steps to build the simple hello world application excluding duplicated steps. Let’s take a look one by one.

1. Create product structure #

“Create product structure” step is simply creating ObjCHelloWorld.app directory with intermediate folders at /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app. Now you can tell .app file is just a directory. “-p” creates intermediate directories as required.
From now on, I use BuildFolderPath for /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build

Executed Program
mkdir (/bin/mkdir)

Task Details

Create product structure

/bin/mkdir -p /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app

2. Compile data model ObjCHelloWorld.xcdatamodeld #

In this phase, Xcode compiles Core Data model file. The model is compiled into a runtime format—a file package with a .momd extension that contains individually compiled model files with a .mom extension. The momd package will be used to initialize NSManagedObjectModel.

Executed Program
momc (/Applications/Xcode.app/Contents/Developer/usr/bin/momc)

Task Details

DataModelCompile /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app/ ObjCHelloWorld/ObjCHelloWorld.xcdatamodeld
    cd /Users/Kazu/Dropbox/ObjCHelloWorld
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/usr/bin/momc --sdkroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk --iphoneos-deployment-target 10.2 --module ObjCHelloWorld /Users/Kazu/Dropbox/ObjCHelloWorld/ObjCHelloWorld/ObjCHelloWorld.xcdatamodeld /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app/

3. Compile .m files #

In this phase, all .m files are compiled into object files. Some of important flags are:

You can take a look at this Clang 5 documentation for more details.

Executed Program
clang (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)

Task Details

CompileC /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Objects-normal/arm64/ViewController.o ObjCHelloWorld/ViewController.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/Kazu/Dropbox/ObjCHelloWorld
    export LANG=en_US.US-ASCII
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch arm64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-cache-path=/Users/Kazu/Library/Developer/Xcode/DerivedData/ModuleCache -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/Kazu/Library/Developer/Xcode/DerivedData/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wdocumentation -Wunreachable-code -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DDEBUG=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -miphoneos-version-min=10.2 -g -Wno-sign-conversion -Winfinite-recursion -fembed-bitcode-marker -iquote /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/ObjCHelloWorld-generated-files.hmap -I/Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/ObjCHelloWorld-own-target-headers.hmap -I/Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/ObjCHelloWorld-all-target-headers.hmap -iquote /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/ObjCHelloWorld-project-headers.hmap -I/Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/include -I/Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/DerivedSources/arm64 -I/Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/DerivedSources -F/Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos -MMD -MT dependencies -MF /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Objects-normal/arm64/ViewController.d --serialize-diagnostics /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Objects-normal/arm64/ViewController.dia -c /Users/Kazu/Dropbox/ObjCHelloWorld/ObjCHelloWorld/ViewController.m -o /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Objects-normal/arm64/ViewController.o

4. Linking object (.o) files #

Link object files, libraries, and frameworks, and produce an executable

ObjCHelloWorld.LinkFileList

/Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Objects-normal/arm64/ViewController.o
/Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Objects-normal/arm64/AppDelegate.o
/Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Objects-normal/arm64/main.o

Executed Program
clang (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)

Task Details

Ld /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app/ObjCHelloWorld normal arm64
    cd /Users/Kazu/Dropbox/ObjCHelloWorld
    export IPHONEOS_DEPLOYMENT_TARGET=10.2
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk -L/Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos -F/Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos -filelist /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Objects-normal/arm64/ObjCHelloWorld.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -miphoneos-version-min=10.2 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Objects-normal/arm64/ObjCHelloWorld_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fembed-bitcode-marker -fobjc-arc -fobjc-link-runtime -Xlinker -dependency_info -Xlinker /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Objects-normal/arm64/ObjCHelloWorld_dependency_info.dat -o /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app/ObjCHelloWorld

5. Compile Storyboard file LaunchScreen.storyboard (and Main.storyboard) #

ibtool verifies, updates, and prints the contents of an Interface Builder document, generating its output in standard plist format. The tool follows a “read”, “modify”, “write”, “print” order of operations.

ibtool generates .storyboardc file at BuildFolderPath/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Base.lproj/ directory, which will be used in later in “Link Storyboards” phase.

Executed Program
ibtool (/Applications/Xcode.app/Contents/Developer/usr/bin/ibtool)

Task Details

CompileStoryboard ObjCHelloWorld/Base.lproj/Main.storyboard
    cd /Users/Kazu/Dropbox/ObjCHelloWorld
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    export XCODE_DEVELOPER_USR_PATH=/Applications/Xcode.app/Contents/Developer/usr/bin/..
    /Applications/Xcode.app/Contents/Developer/usr/bin/ibtool --errors --warnings --notices --module ObjCHelloWorld --output-partial-info-plist /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Main-SBPartialInfo.plist --auto-activate-custom-fonts --target-device iphone --target-device ipad --minimum-deployment-target 10.2 --output-format human-readable-text --compilation-directory /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Base.lproj /Users/Kazu/Dropbox/ObjCHelloWorld/ObjCHelloWorld/Base.lproj/Main.storyboard

6. Compile asset catalogs #

actool verifies, updates, and prints the contents of an asset catalog, generating its output in standard plist format. The tool follows a “read”, “modify”, “write”, “print” order of operations.

In this phase, actool generates assetcatalog_generated_info.plist out of Assets.xcassets at BuildFolderPath/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/assetcatalog_generated_info.plist, which will be used later in “Process Info.plist” phase. Since ObjCHelloWorld project does not contain any assests, assetcatalog_generated_info.plist does not contain any meaningful info.

assetcatalog_generated_info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>

Executed Program
actool (/Applications/Xcode.app/Contents/Developer/usr/bin/actool)

Task Details

CompileAssetCatalog /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app ObjCHelloWorld/Assets.xcassets
    cd /Users/Kazu/Dropbox/ObjCHelloWorld
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/usr/bin/actool --output-format human-readable-text --notices --warnings --export-dependency-info /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/assetcatalog_dependencies --output-partial-info-plist /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/assetcatalog_generated_info.plist --app-icon AppIcon --compress-pngs --enable-on-demand-resources YES --filter-for-device-model iPhone8,2 --filter-for-device-os-version 10.2 --sticker-pack-identifier-prefix com.kazus.ObjCHelloWorld.sticker-pack. --target-device iphone --target-device ipad --minimum-deployment-target 10.2 --platform iphoneos --product-type com.apple.product-type.application --compile /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app /Users/Kazu/Dropbox/ObjCHelloWorld/ObjCHelloWorld/Assets.xcassets

/* com.apple.actool.compilation-results */
/Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/assetcatalog_generated_info.plist

7. Process Info.plist #

In this phase, builtin-infoPlistUtility generates Info.plist at BuildFolderPath/Products/Debug-iphoneos/ObjCHelloWorld.app/Info.plist which looks following:

Info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>BuildMachineOSBuild</key>
    <string>15F34</string>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDocumentTypes</key>
    <array/>
    <key>CFBundleExecutable</key>
    <string>ObjCHelloWorld</string>
    <key>CFBundleIdentifier</key>
    <string>com.kazus.ObjCHelloWorld</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>ObjCHelloWorld</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSupportedPlatforms</key>
    <array>
        <string>iPhoneOS</string>
    </array>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>DTCompiler</key>
    <string>com.apple.compilers.llvm.clang.1_0</string>
    <key>DTPlatformBuild</key>
    <string>14C89</string>
    <key>DTPlatformName</key>
    <string>iphoneos</string>
    <key>DTPlatformVersion</key>
    <string>10.2</string>
    <key>DTSDKBuild</key>
    <string>14C89</string>
    <key>DTSDKName</key>
    <string>iphoneos10.2</string>
    <key>DTXcode</key>
    <string>0821</string>
    <key>DTXcodeBuild</key>
    <string>8C1002</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>MinimumOSVersion</key>
    <string>10.2</string>
    <key>UIDeviceFamily</key>
    <array>
        <integer>1</integer>
        <integer>2</integer>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>arm64</string>
    </array>
    <key>UIRequiresFullScreen</key>
    <true/>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
</dict>
</plist>

Executed Program
builtin-infoPlistUtility

Task Details

ProcessInfoPlistFile /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app/Info.plist ObjCHelloWorld/Info.plist
    cd /Users/Kazu/Dropbox/ObjCHelloWorld
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    builtin-infoPlistUtility /Users/Kazu/Dropbox/ObjCHelloWorld/ObjCHelloWorld/Info.plist -genpkginfo /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app/PkgInfo -expandbuildsettings -format binary -platform iphoneos -additionalcontentfile /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/LaunchScreen-SBPartialInfo.plist -additionalcontentfile /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/assetcatalog_generated_info.plist -additionalcontentfile /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Main-SBPartialInfo.plist -requiredArchitecture arm64 -o /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app/Info.plist

In this phase, ibtool links compiled .storyboardc files.

Executed Program
ibtool (/Applications/Xcode.app/Contents/Developer/usr/bin/ibtool)

Task Details

LinkStoryboards
    cd /Users/Kazu/Dropbox/ObjCHelloWorld
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    export XCODE_DEVELOPER_USR_PATH=/Applications/Xcode.app/Contents/Developer/usr/bin/..
    /Applications/Xcode.app/Contents/Developer/usr/bin/ibtool --errors --warnings --notices --module ObjCHelloWorld --target-device iphone --target-device ipad --minimum-deployment-target 10.2 --output-format human-readable-text --link /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Base.lproj/LaunchScreen.storyboardc /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/Base.lproj/Main.storyboardc

9. Process product packaging (provisioning profiles) #

In this phase, builtin-productPackagingUtility uses the provisioning profile for the project and generates embedded.mobileprovision file at BuildFolderPath/Products/Debug-iphoneos/ObjCHelloWorld.app/embedded.mobileprovision
The app won’t be installed if the device’s UDID is not included in the provisioning profile.

Executed Program
builtin-productPackagingUtility

Task Details

ProcessProductPackaging /Users/Kazu/Library/MobileDevice/Provisioning\ Profiles/dbd72690-25ba-485d-909b-f011a8fd90a2.mobileprovision /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app/embedded.mobileprovision
    cd /Users/Kazu/Dropbox/ObjCHelloWorld
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    builtin-productPackagingUtility /Users/Kazu/Library/MobileDevice/Provisioning\ Profiles/dbd72690-25ba-485d-909b-f011a8fd90a2.mobileprovision -o /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app/embedded.mobileprovision

10. Touch ObjCHelloWorld.app #

ObjCHelloWorld.app has already been created in step 1. This is just updating the timestamp.

Executed Program
touch (/usr/bin/touch)

Task Details

Touch /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app
     cd /Users/Kazu/Dropbox/ObjCHelloWorld
     export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
     /usr/bin/touch -c /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app

11. Process product packaging (entitlement) #

In this phase, Xcode uses builtin-productPackagingUtility to create ObjCHelloWorld.app.xcent file at
BuildFolderPath/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/ObjCHelloWorld.app.xcent

This file is used in the signing phase.

ObjCHelloWorld.app.xcent

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>application-identifier</key>
    <string>P83PA3BM9L.com.kazus.ObjCHelloWorld</string>
    <key>com.apple.developer.team-identifier</key>
    <string>P83PA3BM9L</string>
    <key>get-task-allow</key>
    <true/>
    <key>keychain-access-groups</key>
    <array>
        <string>P83PA3BM9L.com.kazus.ObjCHelloWorld</string>
    </array>
</dict>
</plist>

Executed Program
builtin-productPackagingUtility

Task Details

ProcessProductPackaging "" /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/ObjCHelloWorld.app.xcent
    cd /Users/Kazu/Dropbox/ObjCHelloWorld
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"


Entitlements:

{
    "application-identifier" = "P83PA3BM9L.com.kazus.ObjCHelloWorld";
    "com.apple.developer.team-identifier" = P83PA3BM9L;
    "get-task-allow" = 1;
    "keychain-access-groups" =     (
        "P83PA3BM9L.com.kazus.ObjCHelloWorld"
    );
}


    builtin-productPackagingUtility -entitlements -format xml -o /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/ObjCHelloWorld.app.xcent

12. Sign ObjCHelloWorld.app #

In this step, the application is signed with codesign, and entitlement info (.xcent) is embeded in the signature as entitlement data. All apps must be signed in order for iPhone, which isn’t jailbroken, to execute the program.

Executed Program
codesign (/usr/bin/codesign)

Task Details

CodeSign /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app
    cd /Users/Kazu/Dropbox/ObjCHelloWorld
    export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

Signing Identity:     "iPhone Developer: kazu_ochiai[at]me.com (S583AV7KGC)"
Provisioning Profile: "iOS Team Provisioning Profile: com.kazus.ObjCHelloWorld"
                      (dbd72690-25ba-485d-909b-f011a8fd90a2)

    /usr/bin/codesign --force --sign <Signing Identity> --entitlements /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphoneos/ObjCHelloWorld.build/ObjCHelloWorld.app.xcent --timestamp=none /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app

13. Validate ObjCHelloWorld.app #

builtin-validationUtility validates the application before installing onto the device. This phase won’t appear for the simulators.

Executed Program
builtin-validationUtility

Task Details

Validate /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app
    cd /Users/Kazu/Dropbox/ObjCHelloWorld
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    export PRODUCT_TYPE=com.apple.product-type.application
    builtin-validationUtility /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Products/Debug-iphoneos/ObjCHelloWorld.app

Conclusion #

There are lots of stuff going on under the hood when you build and run an application. I learned quite a bit by doing the build report analysis, and realized I should do this more often. There are tons of other things happens when you run actual production apps. Followings are things I learned:

What I want to figure out #

Clang 5 Documentation
objc.io - The Build Process
Model File Format and Versions

 
1
Kudos
 
1
Kudos

Now read this

Injecting code in a process with Cycript

In this article, I’m going to show you how to inject code in running process on an iOS device using Cycript. In this example, I injected code into viewWillAppear: function, so that every time a view controller receives viewWillAppear:... Continue →