Thursday, December 22, 2011

How to validate the iOS device has FaceTime feature

We can test by device iOS version will support this feature or not. But, we can upgrade the iOS version to 3G devices also, it doesn't have Front camera. So, the simple way to test the application is given below, it help us to validate the feature.

BOOL val = [[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString: @"facetime://5555555555"]];

NSLog((val)?@"Yes":@"NO");

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:(val)?@"Yes":@"No" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];

[alert show];
[alert release];

if(val){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"facetime://5555555555"]];
}

Phone Contacts backup in MAC using BT

I was searching for the solution how to backup my phone contacts saved most of the contacts in the phone memory. When I google it gives only the paid solution. But, I want simple free approach.

Nothing, What I did is just exported my phone contacts as vcf (electonic business card file) to my system using BT (Bluetooth).

Even, if you created contacts in the mac machine contacts application. It can be exported as vcf and send back to mobile device to restore/add contact.

What else! That's all we are done with backing up with our mobile contacts.

Mobile Device Used: Samsung Star - s5233

Wednesday, December 21, 2011

Customizing the TabBar images in iOS



Here is the sample code for you how to customize the tabbar in iphone. It will do with four stripe of images.




- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
NSUInteger selectedIndex = tabBarController.selectedIndex;

NSString *selectedImage;

switch (selectedIndex) {
case 0:
selectedImage = @"menu_selected.png";
break;
case 1:
selectedImage = @"location_selected.png";
break;
case 2:
selectedImage = @"offers_selected.png";
break;
case 3:
selectedImage = @"reviews_selected.png";
break;
default:
break;
}


UIImage *image = [UIImage imageNamed:selectedImage];
UIImageView *imageView = [[ UIImageView alloc ] initWithFrame:CGRectMake(0,440,320,40) ];
imageView.image = image;
[self.tabBarController.view addSubview:imageView];

}

Added: Source will do SKTabBar usage

Source: download

Tuesday, December 20, 2011

Restoration of backup SVN repository



The below steps executed in Snow Leopord OS:

SVN repo restoration steps in the existing environment:

- Copy your project repo under main repositiory directory in path /usr/local/main_repo/your_repo
- add/copy user in etc/users file if not exists
- add/copy authz group or user for the repo project in etc/authz
- verify all the paths in path etc/apache2/extra/httpd-svn.conf

Related:
For the New SVN setup details refer here.

Friday, December 16, 2011

Custom ScrollableTabBar (UIButtons) for iOS


One of my Project I need to build scrollable buttons/tab bar in the page. So, idea comes with this solutions.

How to call the SKTabBar class:

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {

CGSize buttonSize = CGSizeMake(50,60);

SKTabBar *skTB =[[SKTabBar alloc]initWithFrame:CGRectMake(0,100,320,100)];
[skTB setBackgroundColor:[UIColor grayColor]];
[skTB setShowsVerticalScrollIndicator:NO];
[skTB setSkDelegate:self];
[skTB loadTabs:buttonSize numberOfTabs:36];
[self.view addSubview:skTB];

[super viewDidLoad];
}

-(void)getSelectedButtonTab:(id)sender{
UIButton *btn = (UIButton*)sender;
NSLog(@"%d",btn.tag);
}

Updated:

Added animations code snippets to show the zoomed view of selected button on selection.

Source: download

Wednesday, December 14, 2011

How to build Static Library project in iOS

Reference:

http://www.icodeblog.com/2011/04/07/creating-static-libraries-for-ios/

http://blog.carbonfive.com/2011/04/04/using-open-source-static-libraries-in-xcode-4/#namespace_classes_appropriately

Video:

http://www.youtube.com/watch?v=fFn2o0aEbRQ

Thursday, November 24, 2011

automatic reference counting

ARC occupies a middle ground between garbage collection and manual memory management. Like garbage collection, ARC frees the programmer from writing retain/release/autorelease calls........

To read more...

Credit:
http://www.mikeash.com/pyblog/friday-qa-2011-09-30-automatic-reference-counting.html

Tracking Crash Logs

To get the crash logs of the app from various OS:

Credit:
http://iphonedevelopertips.com/debugging/locating-crash-reports.html

http://aplus.rs/apple/how-to-find-crash-logs-for-iphone-applications-on-mac-vista-and-xp/

Installing multiple XCode in mac

How to configure two xCode in the single MAC.

Please follow the steps while Installing xcode other than what you have now.

- Go to Root folder there will be a Developer folder for the existing XCode tool, create new folder with name Developer2
- While installing/configuring new XCode tool, one of the installation page show info about the disk/folder going to install by default. Please change the folder to Developer2
- Just continue other steps.
- That's all, two XCode is ready for development.

Note: Unable to change the default XCode.

Happy Coding.

xcode code analyzer

Clang is the code analyzer, will direct you to fix the dirty code.

You can refer the below links to know better usage.

http://iphonedevelopertips.com/xcode/static-code-analysis-clang-and-xcode-3-2.html

http://clang-analyzer.llvm.org/xcode.html

http://blog.llvm.org/2010/04/amazing-feats-of-clang-error-recovery.html

As of now Clang complier is not available for Xcode 4 (available for Xcode 3.2), it has the default LLVM GCC 4.2 complier. We may get that in future release, to know the error code message better.

Additional:

You must build your code using this Analyzer to fix the potential memory leaks and other issues.

http://clang-analyzer.llvm.org/xcode.html

If you are using,
Xcode 3: Build > Build and Analyze
Xcode 4: Select Product > Analyze.

Building multiple iPhone targets in XCode

This is more helpful now for creating multiple version of same product by only skin change or even lighter change in functionality.

Other case, if we are going to release 'lite' and 'full' version of the same product. We can customize our targets with the required resource based on the release type.

Credit:
http://www.pacificspirit.com/blog/2009/01/27/building_for_multiple_iphone_targets_in_xcode

iOS App Store Package (.ipa) option got disabled after archive

This happens when your build produces more than a single target: say, an app and a library....

Credit:
http://stackoverflow.com/questions/5265292/xcode-4-create-ipa-file-instead-of-xcarchive

Related:
http://iphonedevelopertips.com/xcode/distribute-ad-hoc-applications-over-the-air-ota.html

Tuesday, November 22, 2011

setup svn in mac

Subversion, or “SVN” for short, is a development tool which is a versioned repository for your documents or code. It is allows you to maintain versions of files in an organized manner. Using SVN you can retrieve different versions of documents quite easily. Let’s take a look at how to set it up on Mac OS X Leopard.

  1. Let’s begin by installing SVN. There are a number of ways you can get and install SVN on your Leopard system. The easiest method, the one we will use here, is using XCode. XCode is a set of development tools that ship with your Mac. If you pop in the second DVD that came with your Leopard system, titled “everything else”. You will find the XCode 3 installer on this disk. Double click on it to install. In case you are unable to get your hands on the disc you can also download the XCode 3 installer from Apple’s website. You will, however, need to sign up for the Apple Development Connection program to be able to download XCode 3. The membership is free.
  2. Now let’s do a simple installation of SVN. Remember, this is a basic installation, without a lot of security. I’m assuming here that you are installing this on your machine for only you to use and will not open access to all. To do that you need to add a lot of security, which is beyond the scope of this article.

    Here are steps we are going to follow:

    1. create a local SVN repository
    2. configure the Apache web server to work with SVN
    3. configure Apache to use the repository we created
    4. setup basic authentication for SVN

    1. Let’s create an SVN repository at the location ‘/usr/local/repo’. Launch the Terminal and execute the following command:

      # sudo mkdir /usr/local/repo

      At this point you will be prompted to enter your password. Enter the password you use for the user you are logged in as. Now create a new project called ‘testproject’ in SVN and under the directory we created earlier.

      # sudo svnadmin create /usr/local/repo/testproject

      We need to make sure that the Apache web server can read and write to this repository. So run the following command in the Terminal:

      # sudo chown -R www /usr/local/repo

    2. We now need to configure the Apache web server to work with SVN. Follow the steps carefully, as we are going to be editing the configuration file used by Apache. If done wrong, this can break Apache. Open the Apache configuration file ‘httpd.conf’ in your favorite text editor, for example Vim:

      Scroll down the document till you reach a section where you see a lot of instances of “LoadModule”. Create a new line at the end of this section using the ‘o’ key in Vim, and enter the following:

      # sudo vim /etc/apache2/httpd.conf

      Scroll down the document till you reach a section where you see a lot of instances of “LoadModule”. Create a new line at the end of this section using the ‘o’ key in Vim, and enter the following:

      LoadModule dav_svn_module libexec/apache2/mod_dav_svn.so

    3. Now we will add a separate configuration file for SVN. Scroll down to the end of the document and ad the following line:

      Include /private/etc/apache2/extra/httpd-svn.conf

      Save and exit the file. If you are using Vim then you need to use the following key combination, “ESC + ‘:wq!’ + Enter” to do that. Now open this file using Vim and let’s configure it.

      # sudo vim /private/etc/apache2/extra/httpd-svn.conf

      Enter the following into the file:


      DAV svn
      SVNParentPath /usr/local/repo

      # user authentication
      AuthType Basic
      AuthName “Subversion repository”
      AuthUserFile /etc/users
      # only authenticated users may access the repository
      Require valid-user

    4. Now let’s setup a user for SVN. I’ll create the user calvin and assign him a password. This password protects our Subversion repository.

      # sudo htpasswd -cm /etc/users calvin
      New password:
      Re-type new password:
      Adding password for user calvin

      We’re done now. Hit the url “http://localhost/repo/testproject” in your web browser. You should be prompted for a password here. Enter the username and password you just set. you should be in. You can now create more projects like we created “testproject”.

    Credit: http://www.switchingtomac.com/tutorials/setup-a-subversion-server-on-leopard/

hudson integration for mac

Credits:
  • installing hudson : http://priyanka-tyagi.blogspot.com/2011/01/installing-hudson-on-mac-os-x-snow.html
  • configuring hudson : http://www.manicwave.com/blog/2010/03/01/that-feels-better-cocoa-hudson-and-running-green/
  • auto startup in mac (if req): http://jrenard.info/blog/a-quick-but-working-startup-item-for-hudson-for-mac-os-x.html
  • command line parameter for xcodebuild: http://www.manpagez.com/man/1/xcodebuild/

FTUtils animations

Make use of this FTUtils Animations.

Credit:

http://iphonedevelopertips.com/open-source/ios-open-source-ftutils-core-animation.html

internationalization and localization

Credit:

http://iphonedevelopertips.com/general/resources-for-internationalization-and-localization.html

iOS commenting style

Credit:

http://iphonedevelopertips.com/objective-c/objective-c-comment-styles.html

customize the button with badge in iOS

Credit:

http://www.spaulus.com/2011/04/custombadge-2-0-retina-ready-scalable-light-reflex/?lang=en

Print Preview / Report in iOS


Using libHaru (open source), we can dynamically generate the pdf file with multiple pages for the print report.

Even adding images, drawing lines, and inserting text , etc.

Reference:

https://github.com/bygreencn/iPhonePDF#readme

Any issues in setup libHaru:

http://kishorek.com/2011/05/iphone-libharu-pdf-project-setup-xcode-3-2/

Used in my POC, samples attached.


global ignores

We faced issues in MAC, while committing library.a files.

Here is the solution. We can commit any file or ignore unwanted file by configuring a file.

Follow the steps:

1. Right click finder icon > Goto Folder > type "~/.subversion" > Go
2. Edit the config file (Take backup before editing).
3. Search for this line: # global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.pyc *.pyo *.rej *.a *~ #*# .#* .*.swp .DS_Store *.zip
4. Remove the "*.a" and Save.
5. That's all, now you are ready to commit library files.




Credit:
http://stackoverflow.com/questions/2394363/svn-wont-import-a-library