Showing posts with label Xcode. Show all posts
Showing posts with label Xcode. Show all posts

Apr 19, 2011

Xcode 4 bugfix update is out. Part 2.

Part 1.

Recently Apple has released another bug-fix update for Xcode: Xcode 4.0.2.

Whatʼs New in Xcode 4.0.2

  • Fixed a bug in the iOS Simulator when running OpenGL ES apps on some Macs
  • Fixed a bug handling some Core Data mapping models
  • Fixed a bug in LLVM compiler 2.0 that could cause apps to crash on iOS devices
  • Additional bug fixes and stability improvements

Mar 28, 2011

Xcode 4 bugfix update is out

In short, Apple has just released a new version of Xcode 4.0.1. This is mostly a bugfix release:

Improved Assistant editor logic when switching among different file types 
Fixed a bug that prevented indexing of some projects 
Fixed a bug related to nil settings in the Core Data model editor 
Fixed a bug in LLVM GCC 4.2 and LLVM compiler 2.0 for iOS projects 
Additional bug fixes and stability improvements


Mar 23, 2011

Xcode + AStyle. Part 2. (for Xcode 4.x)

Anar here...

Long time ago I've described a recipe to use astyle from within Xcode 3.x.

Now as you may know, Xcode 4 doesn't provide the "user script" menu. I knew about it since Xcode 4 developer preview versions, but kept hoping the menu item would be back.
This didn't happen :( We have now a stable release of Xcode 4 and there is no sign of user's script in it.

What I think is that Apple either couldn't implement a support for "user script" or they want us to use automator services.
So, now I try to use automator to accomplish the same as I did in XCode 3's user script menu.


#1
Run Automator. Start a new service workflow.

#2
Select, that you service will receives selected "text" and check that it will "Replace selected text"

#3
Drag the "Run Shell Scrip" to your workflow and add commands as in the following screenshot:

Save your service and now when you want to re-indent your code, just select the whole source file content and select your service from the service menu. Works OK, but there are some drawbacks, see below (at the very end of the post).

Of course you must write the path to your own astyle option file, in my case I use "/Users/anar/Documents/workspace/Support/astylerc", as you can see on the screenshot, which sets the following:
#Indent a C or C++ file.
mode=c
# ANSI style formatting/indenting
style=ansi
# Do not retain a backup of the original file
suffix=none
# Indent 'class' and 'struct' blocks so that the blocks 'public:', 'protected:' and 'private:' are indented.
indent-classes
# Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block.
indent-switches
# Indent 'case X:' blocks from the 'case X:' headers.
indent-cases
# Add extra indentation to namespace blocks.
indent-namespaces
# Indent multi-line preprocessor definitions ending with a backslash.
indent-preprocessor
# Converts tabs into single spaces.
convert-tabs
# Set the minimal indent that is added when a header is built of multiple-lines.
min-conditional-indent=0
# Indent a maximum of # spaces in a continuous statement
max-instatement-indent=80
# Insert space padding around operators.
pad=oper
# Insert space padding around parenthesis on the inside only. 
pad=paren-in
# Remove extra space padding around parenthesis on the inside and outside.
unpad=paren


Drawbacks

The following is the only, what I found so far:

  • Unfortunately I don't see any way to keep the potision of the cursor after the service is called.
  • One should select the whole file content and execute the service on it. Which is inconvenient in some cases. I didn't find a way to get a file name of the current file, which I could then provide to the service.

Mar 9, 2011

Xcode 4 is out (Updated)

Apple has just released its new IDE - Xcode 4.
The main news here is that it is not not entirely for free as it was with Xcode 3.

Members of iOS and Mac Developer programs will get it for free, others can purchase Xcode 4 in App Store for 3.99 Euro ($ 4.99).



Well, I've been using Xcode 4 since the first developer preview and I can only say that it definitely costs more than 4 Euro ;)

Updated:
Just in case you want to uninstall a previous version of Xcode and don't know how to do so:
sudo /Developer/Library/uninstall-devtools --mode=all

or in case of Xcode 4 Developer Preview:
sudo /Xcode4/Library/uninstall-devtools --mode=all

Jan 11, 2011

Xcode 4 Developer Preview 6



If you are a member of the Mac Developer Program, than there is a very good news for you ;)
Xcode 4 Developer Preview 6 has now been released (actually yesterday ;) ).
Rush to download it!



Sep 20, 2010

Xcode + AStyle

Anar here...

You know, I think there are many people, who find the auto-formatting of source code in Xcode is really terrible :( I mean, it is very weak (in terms of configuration) for such a descent development environment, which XCode actually is.

Since a very long time I use AStyle (Artistic Style) to format my code. It actually does remarkable job and it is an extremely tunable tool. You can adjust it almost for all, if not for all, indentations schemas...

I have already posted a long time ago a recipe of how to setup astyle for eclipse. Now, it is time to use it in XCode.

I use a user script menu to add my own script, which will than trigger the astyle command to format a source code for me.

Use the User Script menu to add a new script. You should add your script to a section "Text", the type of the script should - a shell script.
Next is the properties of the script:
Input: Entire Document
Directory: Selection
Output: Replace Document Contents
Errors: Display in Alert

And the content of the script:

#!/bin/bash

# I pass selected file instead of a selection, because astyle 1.24
# fails to parse struct with access modifiers. It just hangs instead.
# I also use a tmp file in order to avoid annoying Xcode message, that
# source file was changed outside of Xcode.

# Important: there must be always a new line at the end of the source file.
# Next time I provide a fix for that.


TMP=`mktemp -t xcode.XXXXXXXXXX` || exit 1

cat << 'EOFEOFEOF' > "$TMP"
%%%{PBXAllText}%%%EOFEOFEOF

astyle --options=<***PATH_TO_YOUR_ASTYLE_RC_FILE***> $TMP &>/dev/null

echo -n "%%%{PBXSelection}%%%"
cat $TMP
echo -n "%%%{PBXSelection}%%%"

rm $TMP

Restriction: Be advised, there must be always a new line at the end of the source file!

BTW, don't forget to change that <***PATH_TO_YOUR_ASTYLE_RC_FILE***> to a real path to your astyle resource file ;)

The script above is actually a second version of my script. The first one was much simpler:

#!/bin/sh

echo -n "%%%{PBXSelection}%%%"
/usr/bin/astyle --options=<***PATH_TO_YOUR_ASTYLE_RC_FILE***> <&0 echo -n "%%%{PBXSelection}%%%"
But this version didn't work for me with astyle 1.24. This is why in the second version of the script:
I pass selected file instead of a selection, because astyle 1.24 fails to parse struct with access modifiers. It just hangs instead. I also use a tmp file in order to avoid annoying Xcode message, that source file was changed outside of Xcode.
Finally, just assign some shortcuts (I prefer Options + Command + L) to you script and voilà...

Apr 15, 2009

Development under Mac OS X

Since long time already I have been not posting here... :( So, let's try to reload this blog...

With this post I am going to start a series of posts about development under Mac OS X. I will post about something I find interesting, difficult to implement, and some tricks I developed or just googled. :) Hope it helps to someone or at least it will help me to order my experience on that field.

Well, let's start from the environment.
I consider myself to be an experienced Windows and Linux developer. This stuff I do for many years already.
With Mac I met about five(!) moths ago. I mean, I knew it exists and I even worked briefly on it some years ago, but the truth is that, most of my projects were related to Windows or Linux.

I met Mac and that was love at first sight ;) As soon as I started to work on it I immediately suffered from the filling that I want to start an application development project under Mac and use it in my daily work... really!

As the hardware I use a new MacBook Pro, 15''



The only thing I can say is - WOW! It is a fucking amazing piece of hardware! Apple did a terrific job on this one.
I am just in love with the new trackpad device and the new keyboard of MacBook. No more words... Just get this laptop and enjoy!

BTW, I still do a lot of Linux development. In order to continue to do that on my Mac I use VMware Fusion. It works like a charm. One screen is a full screened Fedora 10 guest, another is a MS Windows XP guest and all under control of Mac OS X. ;)


The OS I am using is Mac OS X Leopard.
As the development environment I decided to use XCode (v. 3.1.2). Well, I am a bit disappointed with XCode and I tell you why. Mainly because of two thinks I see missing.
  1. A terrible SVN support. For example, I didn't find a way to set SVN properties on files. Also SVN plug-in sometimes living its own live and could be doing something, which blocks all version control operations on files in XCode. I didn't find a better way to just stop that plug-in by restarting XCode.
  2. No way to define custom formating rules. Formating preferences are very weak: a couple of checkboxes and that's it... If you do Objective-C development, then in a couple of weeks you will used to default formating and syntax coloring XCode does. But anyway, I would prefer to have a bit more flexible formating settings.
I think XCode is a very new and fresh product and Apple is developing it very fast (you can tell that from new thinks you get every new release). So I believe we will see soon a strong competitor to MS Visual Studio and to Eclipse. So far I would say MS VS is the best, at least for C++ development.

Anyway I would give a big plus to XCode and the best mark just for its very good integration with Objective-C and Cocoa. In combination with Interface Builder, which is by the way just the best GUI builder I have ever seen, XCode does all you need for application development.

James Bond will return... I mean, I will continue posting on that subject ;)