xibless is a Python library that generates Objective-C code that builds Cocoa UIs. The goal of this library is to replace XIBs in XCode and, if you want, get rid of XCode altogether.
With xibless, instead of designing UIs with a WYSIWYG editor, you build them in a Python script, similarly to what you do when you build Qt UIs without the Designer. For example, a script like this:
result = Window(200, 200, 330, 110, "Tell me your name!")
nameLabel = Label(result, text="Name:")
nameField = TextField(result, text="")
helloLabel = Label(result, text="")
button = Button(result, title="Say Hello")
nameLabel.width = 45
nameField.packRelativeTo(nameLabel, Pack.Right, Pack.Middle)
helloLabel.packRelativeTo(nameLabel, Pack.Below, Pack.Left)
button.packRelativeTo(helloLabel, Pack.Below, Pack.Right)
would generate Objective-C code that build a form with a name field, a text label and a button. The second part of the script places the widgets on the form appropriately.
Although xibless is written in Python, the Objective-C code it generates has no Python dependency, so this tool is suitable for any Cocoa developer.
xibless runs on Python 2.7 and up. This means that if you're on OS X 10.7 or newer, you can use the built-in Python. Otherwise, you'll have to install a more recent version of Python.
For many people XCode and its integrated interface builder work fine and to be fair, XCode is a nice tool. However, it has shortcomings, mostly just annoyances, but still, after a while, annoyances become... annoying. For example, when a XIB UI reaches a certain level of complexity, you never know, when doing minor updates, if you mistakenly messed up something else. Because every modification, however minor it is, changes a big part of the XIB file, you can't tell in the diff if the modification you've made was exclusively the one you wanted to make. There's also XIB localization, with its one-xib-copy-per-localization, which is less than optimal but hard to work around. Anyway, I'm not going to try to convince you. If you don't already want to get rid of XCode and/or XIBs, you probably don't need xibless.
You can install xibless through pip:
pip install xibless
or by downloading the source package and running:
python setup.py install
To build the demos in the demos folder, cd into it and type:
The resulting app will be in the build folder.
xibless can be used either from the command line or through Python. To use it from the command line, you type:
xibless < source > < dest >
source is the path of the Python module you wrote that describes the UI you want to build. dest is the path you want your resulting Objective-C file to be written at. To use xibless directly from Python, the usage is similar:
Now, all this does is that it generates UI code. xibless hasn't, yet, any integrated solution to let you easily build a XCode-less program. However, what you can do is to look at the demos folder and base yourself on those demos (which are completely XCode-less) to build your own project.
xibless is in very early development and there's no API documentation yet. For now, you'll have to figure that API from the demos and by digging directly in the source. Also, note that this API could wildly change before v1.0.
Also, the number of rough edges at the moment are incalculable. There are no error message for invalid UI scripts, so it might be very hard, for now, to figure out why your scripts don't work.
Oh, yes, and memory leaks, there's tons of them.
What's New in This Release: [ read full changelog ]
· Added VHLayout.
· Added Box.
· In View, added delegate, fixedHeight, fixedWidth and accessibilityDescription attributes as well as moveTo() (a more powerful version of packToCorner()) and fillAll() methods.
· In Segment, added image and accessibilityDescription attributes.
· Added SplitView.dividerStyle and added documentation for a direct split view hierarchy.
· Added TableView.borderType and View.focusRingType.
· Added Button.bordered
· Added MenuItem.state
· Added TabView.tabViewType.
· Added TextField.usesSingleLineMode.
· Added margin and align arguments to layouts.
· Deprecated View.packToCorner().
· Layouts can now contain sublayouts.
· Allow Color() to receive values in the range of 0-255 in addition to 0.0-1.0.
· Don't localize strings containing only "-" (they're used to indicate a separator menu item).
· RadioButtons' height now depends on the number of rows it has.
· Fixed filler resizing in layouts in cases where there are other views next to the filler.
· Allow UI scripts to import units that are from the same folder.
· Replaced Button.keyEquivalent with Button.shortcut.
· Fixed runtemplate so that the XiblessSupport unit is compiled in the RunUI executable.
· Fixed a bug where we would sometimes end up with two generated item with the same varname.
· Always set growX/growY to False in setAnchor() for views that have a fixed width/height.
· The "text" argument of TextField's constructor is now optional.
· Support sides and middle in View.setAnchor().
· Generated units now have a comment indicating generation time and xibless version.
· Moved TextField.alignment down to Control
· Only copy XiblessSupport unit when it changed, thus avoiding needless recompilation.
· Fixed TabView's layout deltas for cases where there's no tabs.
· Support shortcuts involving the '+' character.
· Improved default margins in layouts, control heights and all other little tweaks of this sort.