Aug 03

To completely uninstall XCode and all IPhone Developer Platforms just write this command in a Terminal Shell.

sudo /Developer/Library/uninstall-devtools –mode=all

After the command as ended just do a restart to your machine.

Jun 15

An interesting project that gives a framework for an AR project using the GPS and the Compass

http://www.iphonear.org/

Jun 09

Found this great post about compiling OpenCV on the IPhone.

Feb 05

Recently we had a small project for the IPhone where we need to retrieve data from a web service.

Our first aproach was to see if in the Apple SDK for the IPhone was something like the WSMakeStubs tool in Mac OSx.

We didn’t found anything similar  and we are almost implementing the requests and xml parsing manually until our colleague Barrenho found these nice tools:

  • http://sudzc.com/ – Generates a full project with classes, gives full source code, test application, documentation and wsdl file. Our current pick.
  • http://code.google.com/p/wsdl2objc/ – Also generates classes but has some problems with more complex types in the WSDL specification.

Thanks Barrenho.

Dec 09

After some time developing iphone applications I was starting to have a huge codebase that was shared between several projects. In order to avoid to mantain the same classes files to all the projects I started to look for a way to create a shared library. After some “google” around I found some techniques, but the one more accepted by the community and recommended by Apple was the use of static libraries.

How to create and use them? Just follow these instructions:

Create a new project in the XCode using the template static library. In this example we will create a project called MyLibrary. Make sure you store the project in a permanent place because Xcode will need to reference the files every time you compile your project.
Add to this project all the files that you want to use in your custom library. After you have completed just build the project to check if you have no errors in you library.

After you have you library ready you will want to use in other projects for that locate in Finder the “MyLibrary.xcodeproj” file under your project folder. Drag “MyLibrary.xcodeproj” and drop it onto the root of your Xcode project’s “Groups and Files” sidebar. A dialog will appear — make sure “Copy items” is unchecked and “Reference Type” is “Relative to Project” before clicking “Add”.

Now you need to link the your new static library to your project. Click the “MyLibrary.xcodeproj” item that has just been added to the sidebar. Under the “Details” table, you will see a single item: libMyLibrary.a. Check the checkbox on the far right of libMyLibrary.a.

Now you need to add your library as a dependency of your project, so Xcode compiles it whenever you compile your project. Expand the “Targets” section of the sidebar and double-click your application’s target. Under the “General” tab you will see a “Direct Dependencies” section. Click the “+” button, select “MyLibrary”, and click “Add Target”.

Finally, we need to tell your project where to find your library headers. Open your “Project Settings” and go to the “Build” tab. Look for “Header Search Paths” and double-click it. Add the relative path from your project’s directory to the “MyLibrary/src” directory.

While you are in Project Settings, go to “Other Linker Flags” under the “Linker” section, and add “-ObjC” and “-all_load” to the list of flags.

You’re ready to go. Just #import files from you library anywhere you want to use MyLibrary classes in your project.

References:

  • http://blog.stormyprods.com/2008/11/using-static-libraries-with-iphone-sdk.html
  • http://www.clintharris.net/2009/iphone-app-shared-libraries/
  • http://blog.costan.us/2009/02/iphone-development-and-code-sharing.html
Nov 08

One of the problems that I stumble upon was when doing long network operations on the IPhone, like downloading a big file, the operation never ended with success.

The download always failed with an IO problem, after some investigation I found out that the problem was the battery saver of the IPhone.

The thing is that when you don’t interact with an aplication after some minutes the IPhone will enter in a battery save mode, first it will dim the screen and after some time it will turn off the screen and disable any wi-fi or 3g connections.

To avoid this you must disable the idle timer on the application when doing long network operations. There is a simple property on the UIApplication class called IdleTimerDisabled. Just do this on your code:

   [UIApplication sharedApplication].idleTimerDisabled = YES;
   // do long network operation
   [UIApplication sharedApplication].idleTimerDisabled = NO;
Apr 01

Sometimes you start a project with a name in mind for your application. Then you discover that the name is already taken by other app or you want to change it.

If you only want to change the name that appears bellow the application icon just go to your info.plist file and change the CGBundleDisplayName value.

But if you want to clean all references to the old name for the new name you will need to do the following:

  • Select the target in XCode and then do a get info.
  • Click on General and change the name.
  • Then go to build and scroll down and change any names there.
  • Close the project in XCode
  • After this open the [OldApp].xcodeproj folder
  • Edit the project.pbxproj file (better to do a backup of the file first) and do a search and replace for OldApp.app to NewApp.app.
  • Open the project in XCode and check if everything , in case of any problem restore the old file.
  • Go to your info.plist and change the CGBundleDisplayName value.
Oct 20

To know how much free disk you have available on your iPhone/iTouch just execute this simple code:

NSDictionary * fsAttributes = [ [NSFileManager defaultManager]
                    fileSystemAttributesAtPath:NSTemporaryDirectory()];
NSNumber * freeSize = [fsAttributes objectForKey:NSFileSystemFreeSize];

You can also use the same dictionary to know the total disk size by reading the NSFileSystemSize key.

Aug 29

One of the security features of the iPhone is the Auto-Lock feature, this feature basically locks your phone if you don’t use it for a configured time ( normally one minute). The problem of this feature is that it turns off WIFI or 3G connectivity. This can be hassle when you need to run a long network background process.

In order to avoid this in you application you just need to use the property idleTimerDisabled in the UIApplication class. Here is a example:

[UIApplication sharedApplication].idleTimerDisabled = NO;

Don’t forget to turn it on after your process is done, or else, you can drain the device battery very fast because the device will never idle when running your application.

Aug 28

After you subscribe and pay for the IPhone Developer Program, you will have access to the “Program Portal”. In this page you have a step by step guide for configure your XCode for device compilation.

Unfortunately Apple forgot some of the instructions, here are the missing steps:

  • Your “Bundle identifier” property in the Info.plist file must have the same base url that you specify in the App ID tabs in the “Program Portal”. For example if your App ID is CB7U3KHAPJ.com.your_company.* your “Bundle identifier” must be com.your_company.my_app.
  • For Ad-Hoc distribuition you must create and add an Entitlement file called dist.plist to your project. In that file you must disable the “get-task-allow” property. After you create file you need to add it to your build configuration. Go the Build Menu and in the Code Signing section add a new property called “Code Signing Entitlements” and use the value “dist.plist”.
  • Remember you need to create a Distribution Profile in the “Program Portal” and use it in XCode a Developer Profile is only for direct compilation for your test device

You can find more detailed info here .

Update: Apple finally updated their documentation with this information.

See you soon.