How to edit / refactor properties of XIB files in bulk? - iphone

I one of my big projects the customer just wished to change leading font in whole app.
It is quite simple for the fonts allocated by code (I have some kind of theme system which abstracts font creation).
But the problem starts with the fonts used in XIB files. Do I have to go thorough all of them and apply change to properties manually (I have literally dozens of them)?
Are there any smart terminal commands which could do this in more efficient way (combination of ibtool, xargs, find)?
I have accomplished similar problem - extracting all strings used in XIB as mentioned here:
https://stackoverflow.com/a/7754884/229229
And I hope there is some search (and replace) patterns also for any XIB properties.

The .xib files are plain .xml files and can be simply edited.
Only non-default fonts are defined in .xib files. Simplified example:
<object class="NSTextField" id="298830314">
<object class="NSTextFieldCell" key="NSCell" id="386648753">
<object class="NSFont" key="NSSupport">
<string key="NSName">Arial-BoldMT</string>
<double key="NSSize">18</double>
<int key="NSfFlags">16</int>
</object>
</object>
</object>
In other words, remove all <object class="NSFont"> paths to revert to default fonts.
To change all NSTextField to specific fonts, add something like:
<object class="NSFont" key="NSSupport">
<string key="NSName">Arial-BoldMT</string>
<double key="NSSize">18</double>
<int key="NSfFlags">16</int>
</object>
to all <object class="NSTextField">.
Xcode has no build-in feature to do this automatically in batch.
EDIT (Response to comment)
Choose specific fonts by clicking on the "Font Panel..." button:
Using the Font Panel you can select any font:

Related

contribution to change logo in all pages nuxeo

I want to change my nuxeo application logo. I've read how to change it for login page and it's working , but now i want to change logo for all my page and i can't find any tutorial of how to do this.
Here is what i've tried so far:
<component name="org.nuxeo.sample.loginPage">
<extension target="org.nuxeo.ecm.platform.ui.web.auth.service.PluggableAuthenticationService" point="loginScreen">
<loginScreenConfig>
<disableBackgroundSizeCover>false</disableBackgroundSizeCover>
<headerStyle></headerStyle>
<footerStyle></footerStyle>
<loginBoxWidth>400px</loginBoxWidth>
<logoUrl>${org.nuxeo.ecm.contextPath}/img/logo12.png</logoUrl>
<logoAlt>MyCompany</logoAlt>
<logoWidth>113</logoWidth>
<logoHeight>20</logoHeight>
<newsIframeUrl>https://www.nuxeo.com/embedded/dm-login</newsIframeUrl>
</loginScreenConfig>
</extension>
</component>
You got it for the login screen. For the other pages, give a look at the org.nuxeo.theme.styling.service component and its flavors extension point.
You will need such an XML contribution:
<extension target="org.nuxeo.theme.styling.service" point="flavors">
<flavor name="myCompanyFlavor" extends="default">
<logo>
<path>/img/logo12.png</path>
<previewPath>/img/logo12.png</previewPath>
<width></width>
<height></height>
<title>MyCompany</title>
</logo>
</flavor>
</extension>

How do I modify a .xib file outside of xcode?

I have a .xib file. I open it up with textfile or Dashcode or what ever.
Say it has 4 buttons on it. All the same but with different titles.
My goal is to change the color, font, and background image outside of xcode automatically and then import the file into xcode.
However these things are represented by a reference number that I can't seem to find any where in my project folder connecting it to the actual image, color, or font.
<reference key="IBUINormalBackgroundImage" ref="650551563"/> <!-- Button Background -->
So a button looks like this
`<!-- Button 1 -->
<object class="IBUIButton" id="580622739">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 124}, {280, 37}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="810145050"/>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<reference key="IBUIFont" ref="881065587"/> <!-- Button Font Type -->
<int key="IBUIButtonType">1</int>
<string key="IBUINormalTitle">Facebook</string> <!-- Button Name -->
<reference key="IBUIHighlightedTitleColor" ref="587412318"/>
<reference key="IBUINormalTitleColor" ref="523599070"/> <!-- Button Font Color -->
<reference key="IBUINormalTitleShadowColor" ref="457053782"/>
<reference key="IBUINormalBackgroundImage" ref="650551563"/> <!-- Button Background -->
</object>
`
EDIT: Based on some responses. What I can do is drag and drop a xib into xcode now. But when I am making a new app I want to use an existing xib but with different colors. I will use php to auto create this code file. Then just drag and drop again. I have done this for all my .h and .m and viewcontrollers. I need to figure this out for .xibs.
The xib files contain XML generated by IB in XCode. If you edit this XML, there is no guarantee that your changes won't get wiped out by IB the next time it writes the file.
But if I understand you correctly, you are trying to peek at the xib contents to get a better understanding of how to create a UI programmatically. Programmatically generated UI's are not done by writing xib files. You may get a hint about what parameters can be configured in IB, but there is a lot of content in a xib that is distracting, if that's what you are trying to do.
Previously in Xcode 3.2 and earlier, there was Interface Builder app which was functioning outside of Xcode... but now it is a part of Xcode. You can google for Interface Builder now also...But i think apple does not allow you to have Interface Builder separately....
general link : http://guides.macrumors.com/Interface_Builder
I am working on a xib decoder written in c# and even if for the moment it's not possible to edit a xib file it's possible to display it and see what it looks like. The xib parser is open-source and is a translation of the open source implementation of Cocoa called GNUstep.
Parser is available here : https://github.com/smartmobili/CocoaBuilder.

Custom font doesn't work in interface builder!

I've downloaded a font that's called "aldo the apache (.tff) " from dafont.com.
I used it with different programms like adobe illustrator and it seemed to work just fine.
Recently i tried to use it in a game that i'm making to experement. It didn't work -_-.
IB was displaying the font as a slightly bigger version of arial.
How can i solve this problem and get the font to display correctly?
If you have any suggestions, please post them down below.
-DD
You have to edit your <appname>-Info.plist file and create a new UIAppFonts key with type array, where each element is a String with the name of your font file, in this case AldotheApache.ttf. Then use the name in IB or with UIFont as it shows in the application Font Book app of your Mac, in your case Aldo the Apache. Obviously the font should also be added as a resource of your project.

Using custom fonts in Cocos2d

How do I use custom TTF fonts in my Cocos2d iPhone apps?
I searched for this for a while and decided to post as question and answer for people wanting to implement.
The solution is quite easy.
Find the fonts you want and download them. This website has a huge collection of free fonts.
Add the font files to your project.
Add the font names to your info.plist file using the array below as an example.
Find the font's name; Double click the font file and use the font name shown in the title of the window. In this example it is "Action Man"
To use the font name the way you would normally:
CCLabel* myLabel = [CCLabel labelWithString:#"Some Text" fontName:#"Action Man" fontSize:18];
Add this to your info.plist file:
<key>UIAppFonts</key>
<array>
<string>Action Man Bold.ttf</string>
<string>AdineKirnberg-S.ttf</string>
</array>
In Cocos2D, you can include the font file with your resources and then in fontName: simply supply the filename. For example:
CCLabelTTF *label = [CCLabelTTF labelWithString:#"whatever" fontName:#"FONTNAME.ttf" fontSize:18];
This is often easier than the method Hanaan has posted.
You should use the exact same file name capitalisation as the filename.
You do not need to add fonts to your info.plist if you are only using it in Cocos2D bits.
If, like Confused, you find that the font works on the simulator but not the device, it is probably a file name capitalisation mistake. The iPhone is case-sensitive, the simulator is not.
As these answers are outdated, I'm sure my question/ answer will help all those out there.
Importing fonts for cocos2dx iOS
this is for iOS and Android platform font importing, with just a single line of code!

Load (and display) a .XIB from the web

I want to be able to download (via a NSURLConnection request) a .XIB file, and have it presented in a view. I have implemented the NSURLConnection, and surely enough, when the connection completes, I am left with a NSString of XML data representing the XIB file. Example: (just the first few lines of many)
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">800</int>
<string key="IBDocument.SystemVersion">10D573</string>
<string key="IBDocument.InterfaceBuilderVersion">762</string>
<string key="IBDocument.AppKitVersion">1038.29</string>
<string key="IBDocument.HIToolboxVersion">460.00</string>
ET CETERA...
I looked through the documentation, and I believe that I cannot use "initWithNibName:" because it is being retrieved from the web. What I believe I need to do is save the .XIB to the app's document directory, and then use "loadNibFile:externalNameTable:withZone:"
Essentially what I want to do is have an iPad application, and there is a small 320x480 window, where a .XIB loaded from the web can be displayed. If I can attach it locally to a ViewController all the better, but not completely necessary.
I'm just not exactly sure how I should use "loadNibFile:externalNameTable:withZone:" Can anyone give me some advice or an example?
Thanks in advance!
loadNibFile:externalNameTable:withZone: is an AppKit method, so it only works on Mac OS, not iPhone or iPad.
In SDK 3.2 you can use -[UIViewController initWithNibName:bundle:] or -[NSBundle loadNibNamed:owner:options:], depending whether or not you want the File's Owner to be a UIViewController. While you're right that you can't download a .xib and install it into your main bundle's resources, you can probably download a bundle, save it into your Documents directory, pass it to +[NSBundle bundleWithPath:], and then extract a .xib from it using initWithNibName:bundle: or loadNibNamed:owner:options.
I haven't tried this, but is seems like it should work. I'll be curious to know if it does.
I'll also be very interested to know if Apple accepts this app. It seems like this would put section 3.2.2 of the iPhone SDK Agreement to the test.
You will not be able to do this with a plain .xib file, because those need to be compiled into a binary format for use within an actual application.
If you do compile the .xib files down into a proper iPhone .nib file, you might be able to place those within an external bundle and download that bundle to the application's Documents directory. You could then create an NSBundle instance using +bundleWithPath: or the like, and pass the Nib name and bundle into a UIViewController's –initWithNibName:bundle:.