ibtool 在编译和链接故事板阶段做什么,以及链接的故事板的结果如何与可执行文件一起使用



我一直在研究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 完成的上一个链接阶段创建的可执行文件?

不确定你是否找到了答案,或者我的答案会回答你的答案,但我还是会发布它。

如果您在编译的应用程序(IPA 文件(上达到峰值,您将看到您通常的 XIB 文件转换为 NIB ,并且*.storyboard转换为 *.storboardc(c 应该表示编译(。然后,如果使用文本编辑器打开 xib 或情节提要文件,则应看到 xml 内容。

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

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

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

最新更新