FacebookSDK/FacebookSDK.h file not found

If you are getting “FacebookSDK/FacebookSDK.h file not found” error, even if you have Facebook SDK included in your project? It might be possible that project is not able to access FacebookSDK because of some mis-configuration in references.

Your best bet to resolve this error is by  removing FacebookSDK.framework from your project and then start over with these steps. Re-linking the framework won’t help in many cases –

Step 1. Go to Build Phases in your Project Target.
Step 2. In Link Binary With Libraries, click the “+” button.
Step 3. Click on “Add Other…” button
Step 4. Browse your FacebookSDK folder. Generally in ~/Documents/FacebookSDK/
Step 5. Clik on (select) “FacebookSDK.framework” and then OPEN.

Hope this will save someone’s time!

Keyboard not working in iOS simulator?

If your keyboard (mac keyboard) is not working in the iPhone simulator you must have something wrong in iPhone Simulator preference file.

To fix the problem follow this –

0) Quit Xcode and simulator
1) Press ‘command+shift+g’ .. it will open the “go to folder” dialog.
2) type “~/Library/Preferences” in this dialog to go to your preference folder.
3) Delete “com.apple.iphonesimulator.plist” in this folder
4) Done. “com.apple.iphonesimulator.plist” will be regenerated when you start simulator again.

Alternatively you can also do this with just one command.

Open terminal and fire –

rm ~/Library/Preferences/com.apple.iphonesimulator.plist

This will do the trick in one step! Just make sure you quit Xcode and simulator before running this.

Where is MainWindow.xib in Xcode 4.2 ?

In Xcode 4.2 the MainWindow.xib is not included for some of the project templates. Its means now we have to generate GUI elements by code or we can reconstruct the MainWindow.xib in project. I am describing you the second option here.

If you create a new project in XCode 4.2, and choose the Empty Application template to start from, change nothing and try running it in your iPhone 5.0 simulator, you will see an empty – black – screen. The only thing you get from the template is an AppDelegate.h and AppDelegate.m.

We’ll now reconstruct the MainWindow.xib file in our project. So the next thing is now to create a empty user interface file. Choose iOS > User Interface > Empty as template. The name of this file is not very important but we’ll use MainWindow.xib because this name is familiar to us.

Now select the Empty MainWindow.xib file we just created in previous step.

Change the Class of File’s Owner to UIApplication

Now drop a Object from Library to Objects in xib file.

Change the class of that object to the AppDelegate class


Now add a window to objects pane.

Now we need to bind this window object to our code. To do this we have to add IBOutlet to window object in AppDelegate.h file. You code of AppDelegate.h should look like this –
#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) IBOutlet UIWindow *window;


Note the IBOutlet just before UIWindow.

Now continue with editing MainWindow.xib file –

Control-Drag from the delegate outlet of the File Owner to the xAppDelegate object.

Control-Drag from the window outlet of the xAppDelegate to the Window.

Navigate to the project, and in the Summary tab, select MainWindow as the Main Interface.

We are almost done now..  But there is one more thing we need to fix. In AppDelegate.m, there was actually code that creates a window as well, so we have to delete this code.

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

We are done now

Remove NSLog from whole xcode project

This is very good optimization if you remove all your NSLog statement from project. But its hard to find every NSLog and remove it if you have a big project.

This is very good optimization if you remove all your NSLog statement from project. But its hard to find every NSLog and remove it if you have a big project. Well here are two tips –

1) Use ifndef to replace NSLog with blank. Here is an example –

#ifndef __OPTIMIZE__
#define NSLog(...) NSLog(__VA_ARGS__)
#define NSLog(...) {}

2) User regular expression in Find and replace to remove NSLogs

a) Press command + shift + f to open find and replace in whole project.
b) Search for


and replace it with blank

How to create .ipa file for your iPhone app : xcode build and archive

Build and Archive builds your application, code signs it, and stores the application folder along with its symbols file (which you need to decode crash logs generated by ad hoc or release builds).

In Xcode 3.2, Apple added a new feature to Xcode that makes ad hoc distribution more than a fair bit better. But, for the first few weeks of using Xcode 3.2, I didn’t even notice this item. This new item lives under the Build menu.

Build and Archive builds your application, code signs it, and stores the application folder along with its symbols file (which you need to decode crash logs generated by ad hoc or release builds). Xcode’s Organizer window gives you ready access to any previous build, and lets you e-mail an ad hoc build packaged up as an .ipa file with the mobile provisioning profile you compiled with embedded right into the application. This allows your clients or tester to simply drag the generated .ipa file into iTunes. The organizer will even generate an e-mail with the .iap embedded in it.

As part of Build and Archive, Xcode checks your application to make sure it’s code signed and provisioned properly. It may also (depending on your project settings) automatically run the new Validate feature that checks to make sure your application is valid for app store submission. This is the same check that the app review team will run on your app before actually looking at it. The details of what Validate checks are not documented, but in general terms, it will make sure everything is okay and that you haven’t used anything you shouldn’t have used. It’s not a guarantee that your app won’t get rejected because there’s still the manual review for content and HIG, but if your app passes validation, that’s one less possible obstacle between you and the app store. In other words, make sure you validate your apps before submitting them.

One thing to note, however, is that when you use Validate for ad hoc builds instead of building for submission to the app store (and I recommend that you do so that you find problems before testing rather than after), your app may fail one of the Validate checks. If you get this warning message when using either Build and Archive or Build and Validate with an ad hoc build:

warning: Application failed codesign verification. The signature was invalid, or it was not signed with an Apple submission certificate. (-19011)

You might be fine (assuming you received no other warnings or errors). The difficult thing is that this warning can be generated by more than one specific problem, so there’s no way to know for sure whether this needs to be addressed other than to try and install the generated .ipa file on a non-development phone. You may (will?) get this warning with ad hoc builds even if the build is fine because you don’t use an “Apple submission certificate” for ad hoc builds.

One of the best things you can do is to have a second iPhone or iPod touch that’s not used for development (ever) that you can use to test ad hoc distributions. Even a second-hand, cheap iPod touch is sufficient since all you’re testing is that the install works If you do this, make sure you add the UDID of this unit to your ad hoc distribution profiles, but not to your development profile.

When you see this warning with Validate when building using an Ad Hoc Distribution configuration, don’t panic, but do try and install it on a machine that doesn’t have your development profile installed before sending it to a tester or client.

How to create Xcode project templates

To make your own Xcode Project Template for iPhone development follow these steps:

To make your own Xcode Project Template for iPhone development follow these steps:

1. Open a new finder window and navigate to ~/Library/Application Support/Developer/Shared/Xcode/ (note the ~)

2. Create a new directory in here called Project Templates/

3. Go into the newly created Project Templates/ directory and create a directory for the group your templates will appear in within the new project dialog in Xcode. In this example we will use MyApplication.

4. Open a new finder window and navigate to /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Application

5. Copy one of the project templates (the one that best meets your needs) from here to the MyApplication directory we just created.

6. Rename the copied project template directory to the name you want your template to be called.

7. Go into this directory and you’ll find an Xcode project called ___PROJECTNAME___.xcodeproj – Open this project like any normal project and edit it to how you want your newly created projects made from this template to be. You can use ___PROJECTNAME___ in files and directory names and in code and it will be replaced with the project name. ___PROJECTNAMEASIDENTIFIER___ can be used for code where you don’t want spaces or other characters.

8. After setting up your project template how you like, make sure it builds and then go and delete the build directory from the template directory because you don’t want it to create that in new projects. Inside the ___PROJECTNAME___.xcodeproj directory you should also delete the username.* files (where username is your username), these contain things like window state and open files information from the last time you edited the project. If you ever edit your template later on, you’ll need to delete these files again.

9. Finally, change the description of your template in the ___PROJECTNAME___.xcodeproj/TemplateInfo.plist file and optionally change the icons file ___PROJECTNAME___.xcodeproj/TemplateIcon.icns. Search the web for how to edit .icns files, that’s not covered here.

You can even add your project template to SVN and Xcode won’t copy the .svn directories when it creates a new project. This can make it easy to merge useful changes from projects back into your template.