4

我一直在研究 iOS 应用的构建过程。我创建了一个“单视图应用程序”项目并在 Xcode 8.2.1 中构建。在查看构建报告时,我注意到 Xcode 使用 clang 编译和链接 .m 文件,然后使用 ibtool 编译和链接故事板文件。我想知道 ibtool 在编译和链接过程中实际上在做什么。在以下编译命令之后,会在目录下创建 .storyboardc 文件,这些文件/Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphonesimulator/ObjCHelloWorld.build/Base.lproj/将在稍后的“链接故事板”阶段使用。.storyboardc文件是包含 Info.plist 文件的二进制文件包。

 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

在链接阶段,执行以下命令,我不知道 ibtool 在做什么。我只能说它使用的是storyboardc在编译阶段生成的文件。

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

我的问题是,ibtool 在链接阶段做了什么?是否有任何产品或它链接到由 clang 完成的先前链接阶段创建的可执行文件?

4

1 回答 1

0

不知道你是否找到了答案,或者我的会回答你的,但无论如何我都会发布它。

如果您在编译的应用程序(IPA 文件)中达到顶峰,您会看到您的常用XIB文件转换为NIB,并*.storyboard转换为*.storboardc(c 应该表示已编译)。然后,如果您使用文本编辑器打开 xib 或故事板文件,您应该会看到 xml 内容。

我相信当您使用 xcode 并查看 xib / storyboard 文件时,ibtool 确实会为用户界面生成 xml 内容。然后,在构建时,它会生成二进制文件(nib、storyboardc)。

链接阶段应该为那些编译的文件创建一个路径并创建一个地图或类似的东西。当您调用打开这些文件时,应用程序将在地图中找到路径并在特定包(通常是主包,位于已编译应用程序文件夹的根目录)中为您获取预期的 nib 文件。

PS:这可能就是为什么方法是 call: initWithNibName,而不是initWithXibName

于 2017-07-25T07:29:34.380 回答