2017-02-04 23 views
2

我一直在研究iOS應用程序的構建過程。我創建了一個「單視圖應用程序」項目,並構建在Xcode 8.2.1中。 當我在查看構建報告時,我注意到Xcode使用clang編譯並鏈接.m文件,然後使用ibtool編譯和鏈接storyboard文件。我想知道在編譯和鏈接過程中ibtool實際做了什麼。在以下編譯命令後,在/Users/Kazu/Library/Developer/Xcode/DerivedData/ObjCHelloWorld-guewhpmwckompbfvsbhizkifcadg/Build/Intermediates/ObjCHelloWorld.build/Debug-iphonesimulator/ObjCHelloWorld.build/Base.lproj/目錄中創建.storyboardc文件,稍後將在「Link Storyboards」階段中使用該目錄。 .storyboardc文件是一系列包含Info.plist文件的二進制文件。ibtool在編譯和鏈接故事板階段以及鏈接故事板的結果如何與可執行文件一起工作時做了什麼?

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完成的前一個鏈接階段創建的可執行文件?

回答

0

不知道你是否已經找到答案或我的答案是你的,但我會發布它。

如果你把在編譯的應用程序(IPA文件)峯值,你會看到你平常XIB文件轉換爲NIB,並轉換爲*.storboardc*.storyboard(C應該是指編譯)。然後,如果您使用文本編輯器打開xib或storyboard文件,則應該看到xml內容。

我相信當你使用xcode並查看xib/storyboard文件時,ibtool的確會生成用戶界面的xml內容。然後,在構建時,它會生成二進制文件(nib,storyboardc)。

鏈接階段應創建一個路徑到這些編譯的文件,並創建一個地圖或類似的東西。當您打電話打開這些文件時,應用程序會在映射中找到路徑,並在特定的包(通常位於編譯的應用程序文件夾的根目錄下的主包)中爲您獲取預期的nib文件。

PS:這可能是爲什麼該方法是調用:initWithNibName,而不是initWithXibName