Xcode 5 Finally Makes Interface Builder a Viable Option for Teams
来源:互联网 发布:学java月薪多少 编辑:程序博客网 时间:2024/06/07 06:31
http://nilsou.com/blog/2013/08/07/xcode-5-finally-makes-interface-builder-a-viable-option-for-teams/
Last week as I was merging code to my working branch, I noticed something I had rarely (never?) seen before:
Git had just auto-merged a xib file for me! I figured this must have something to do with Xcode 5 and its “upgrading” of xib files, so I started digging.
It turns out that the xib files generated by Xcode 5 are of a completely new kind. It seems that Apple started from scratch with this and the changes make xib files finally usable in teams of all sizes for the first time.
Xcode 4 xib format
To demonstrate the difference between the 2 file formats I have created a new xib file in Xcode 4 and put a bunch of views in it: A UIScrollView with UIButtons, UILabels and more in it, a UITextView etc.
After that I right clicked on the file in the project navigator and selected Open As > Source Code
. Here is what that file looked like under the hood:
.xib file generated by Xcode 4 (you need to click “File suppressed. Click to show.” because github is being stupid)
1108 lines for a rather simple view! That’s a lot.
Try to make sense of the file, it’s not intelligible at least not easily. This is the main reason why people don’t like xib files and don’t use interface builder.
It gets worse: the format is non-deterministic. Meaning that if you and I create exactly the same UI in Interface builder, we might (will) not have the same file content. This use to make xib files very difficult or even impossible to merge. This is the other big reason for people not to use xib files.
Xcode 5 xib format
Then I opened the same project in Xcode 5. When you open a xib file that was created in Xcode 4 in Xcode 5 you are prompted to upgrade the file to the new format. You want to only do it if all the people working on the project use Xcode 5 because the new files can’t be opened by older versions of Xcode.
I clicked Upgrade and then opened the xib file as source code again to see what had changed. Here is what it looked like.
.xib file generated by Xcode 5 (again, click “File suppressed. Click to show.”)
103 lines! The old file had more than 10 times as many lines! Now this is what I call a drastic reduction.
And look at it, it’s actually understandable. The file now reflects the view hierarchy that you see in the left part of Interface Builder! With a little bit of practice you could even write that xml code. Ok, ok I am pushing it a little here.
On top of that, the code generated seems to be deterministic now. This means that with the same user interface in input it will generate the same xib file. This makes manual merging much easier if it is needed.
Conclusion
The best part is that this new file format is not only understandable by humans but git can also make sense of the changes happening and will now most of the time auto-merge your xib files for you!
Now if someone tells you that they don’t want to use xib files, send them to this article, I don’t think there are many reasons left not to use them.
This is not the only improvement that Xcode 5 brings to Interface Builder, for example, setting auto-layout constraints is now awesome whereas it was a pain before. If you have tried setting constraints in code you know that it is not a walk in the park.
- Xcode 5 Finally Makes Interface Builder a Viable Option for Teams
- Xcode 和Interface Builder
- Xcode 和Interface Builder
- Xcode Interface Builder Help Link
- Xcode 5中的Interface Builder更有利于团队协作开发
- Creating Hello World App Using Xcode 5 and Interface Builder
- [XCode] Interface Builder 是怎么工作的
- Xcode directory not found for option
- Open source makes a healthy site for healthy eaters
- Software Development for Small Teams: A RUP-Centric Approach
- Unit Testing A Growing Priority For Global Development Teams
- [Cocoa] Cocoa Tutorial 2: HelloWin without XCode and Interface Builder
- Mac Xcode Cocoa Interface Builder 菜单和Dock 隐藏
- 在Xcode以及Interface Builder下简单使用Cocoa
- Cocoa、Foundation、UIKit、Objective-c、XCode、Interface Builder的概念
- 在Xcode以及Interface Builder下简单使用Cocoa
- xcode 4 使用指南系列2-Interface Builder
- xcode 4 使用指南系列2-Interface Builder
- 20 个 jQuery 和 CSS 的文本特效插件
- 开启设计模式之旅(一)
- How to Have Two Versions of the Same App on Your Device
- Value must be an existing directory配置tomcat问题?
- TortoiseGit配合msysGit在Git@OSC代码托管的傻瓜教程
- Xcode 5 Finally Makes Interface Builder a Viable Option for Teams
- 26个Jquery使用小技巧
- hdu 4687 Boke and Tsukkomi(一般图匹配)
- VVDocumenter-Xcode
- 好书推荐-Spring in Action
- C/C++语言中闭包的探究及比较
- 基于手机音频通信应用
- getchar从字符串逐个读取字符
- Ry’s Objective-C Tutorial