I've been researching the build process of an iOS app. I created a "Single view application" project and built in Xcode 8.2.1.
While I was looking at the build report, I noticed Xcode compiles and links .m files using clang, and then compiles and links storyboard files using ibtool. I am wondering what is ibtool actually doing in the compiling and linking process. After the following compiling command, .storyboardc files are created at /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphonesimulator/ObjCHelloWorld.build/Base.lproj/
directory, which will be used in later in "Link Storyboards" phase. .storyboardc
files were a bundle of binaries including Info.plist file.
ObjCHelloWorld/Base.lproj/LaunchScreen.storyboard
cd /Users/Kazu/Dropbox/ObjCHelloWorld
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.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-iphonesimulator/ObjCHelloWorld.build/LaunchScreen-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-iphonesimulator/ObjCHelloWorld.build/Base.lproj /Users/Kazu/Dropbox/ObjCHelloWorld/ObjCHelloWorld/Base.lproj/LaunchScreen.storyboard
In the linking phase, following command is executed, which I have no idea what ibtool is doing. All I can tell is it's using storyboardc
files generated in the compile phase.
LinkStoryboards
cd /Users/Kazu/Dropbox/ObjCHelloWorld
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.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-iphonesimulator/ObjCHelloWorld.app /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphonesimulator/ObjCHelloWorld.build/Base.lproj/LaunchScreen.storyboardc /Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphonesimulator/ObjCHelloWorld.build/Base.lproj/Main.storyboardc
My question is, what is ibtool doing in the linking phase? Is there any product or it links to executable created in previous linking phase done by clang?
Not sure if you've found the answer or mine will answer yours, but I'll post it anyway.
If you take a peak at compiled app (IPA files), you'll see your usual
XIB
files converted toNIB
, and*.storyboard
converted to*.storboardc
(c should mean compiled). Then, if you open the xib or storyboard files with a text editor, you should see xml contents.I believe ibtool does generate xml contents to user interface when you use xcode and view the xib / storyboard files. Then, when build, it generate to binary files (nib, storyboardc).
Linking phase should create a path to those compiled files and create a map or something like that. When you make a call to open those files, the app will find the path within the map and get the expected nib file for you, in a specific bundle (usually main bundle, which is at the root of the compiled app folder).
PS: That's probably why the method is call:
initWithNibName
, notinitWithXibName