Thursday 31 January 2013

Warning: directory not found for option issue

If you get an error like this when building , even after removing the files and references


ld: warning: directory not found for option '-L/Users/../../../Downloads/Google Analytics SDK/Library'

Go to build phases >> library search paths 

and delete the path.

File is universal (3 slices) issue


File is universal (3 slices) but does not contain a(n) armv7s slice error for static libraries on iOS


Project -> Build Settings -> remove the architecture from "valid architectures"
You can use this as a temporary solution until the library has been updated. You have to remove the architecture from your main project,not from the library.
Alternatively, you can set the flag for your debug configuration's "Build Active Architecture Only" to Yes. Leave the release configuration's "Build Active Architecture Only" to No, just so you'll get a reminder before releasing that you aught to upgrade any 3rd party libraries you're using.

Wednesday 30 January 2013

Sharing on Twitter iOS 5 and above



Just add the Twitter framework in build phases.


- (IBAction)twitterShare:(id)sender {
    
    NSLog(@"Twitter ");
    TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
    
    [twitter setInitialText:@"This is the message that will be tweeted!"];
    //[twitter addImage:[UIImage imageNamed:@"image_No.jpeg"]];
//    [twitter addImage:img.image];
    
    [self presentViewController:twitter animated:YES completion:nil];
    
    twitter.completionHandler = ^(TWTweetComposeViewControllerResult res) {
        
        if(res == TWTweetComposeViewControllerResultDone) {
            
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Success" message:@"The Tweet was posted successfully." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles: nil];
            
            [alert show];
            
        }
        if(res == TWTweetComposeViewControllerResultCancelled) {
            
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Cancelled" message:@"You Cancelled posting the Tweet." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles: nil];
            
            [alert show];
            
        }
        [self dismissModalViewControllerAnimated:YES];
        
    };

}

Facebook Sharing with Facebook SDK 3.0/3.1 iOS 6


Well I put up this code to share using Facebook SDK 3.0/3.1 for iOS 6 , couldn't find it anywhere and finding from the developers site is pretty tough, so hope this helps.

Add the Facebook Framework , and resources bundle , Social framework and Adsupport framework

- (IBAction)facebookShare:(id)sender {

BOOL displayedNativeDialog =
    [FBNativeDialogs
     presentShareDialogModallyFrom:self
     initialText:dealLabel.text
     image:[UIImage imageNamed:@"logo.png"]
     url:[NSURL URLWithString:@"http://www.buzzingaa.com.au"]
     handler:^(FBNativeDialogResult result, NSError *error) {
         if (error) {
             /* handle failure */
         } else {
             if (result == FBNativeDialogResultSucceeded) {
                 /* handle success */
             } else {
                 /* handle user cancel */
             }
         }
     }];
    if (!displayedNativeDialog) {
        /*
         Fallback to web-based Feed Dialog:
         */
    }
    }

And the delegate functions :

#pragma mark FaceBook Methods

- (void)sessionStateChanged:(FBSession *)session
                      state:(FBSessionState) stateFB
                      error:(NSError *)error
{
    [FBSettings setLoggingBehavior:[NSSet setWithObjects:
                                    FBLoggingBehaviorFBRequests, nil]];
    switch (stateFB) {
        case FBSessionStateOpen:
            if (!error) {
                // We have a valid session
//                [self LoggedIn];
            }
            break;
        case FBSessionStateClosed:
        case FBSessionStateClosedLoginFailed:
            [FBSession.activeSession closeAndClearTokenInformation];
            break;
        default:
            break;
    }
    
    //    [[NSNotificationCenter defaultCenter]
    //     postNotificationName:FBSessionStateChangedNotification
    //     object:session];
    
    if (error) {
        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"Error"
                                  message:error.localizedDescription
                                  delegate:nil
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
        [alertView show];
    }
    
}

/*
 * Opens a Facebook session and optionally shows the login UX.
 */
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
    return [FBSession openActiveSessionWithReadPermissions:nil
                                              allowLoginUI:allowLoginUI
                                         completionHandler:^(FBSession *session,
                                                             FBSessionState stateFB,
                                                             NSError *error) {
                                             [self sessionStateChanged:session
                                                                 state:stateFB
                                                                 error:error];
                                         }];
    
}
- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    // attempt to extract a token from the url
    return [FBSession.activeSession handleOpenURL:url];
}


- (void) closeSession {
    [FBSession.activeSession closeAndClearTokenInformation];
}

- (void)sessionStateChanged:(NSNotification*)notification {
    if (FBSession.activeSession.isOpen) {
        // [buttonFBLogin setTitle:@"Logout" forState:UIControlStateNormal];
        } else {
             // [buttonFBLogin setTitle:@"Login" forState:UIControlStateNormal];
            }
}

Friday 10 August 2012

iOS Development For Beginners

So , here you are, new to developing apps for iPhone and iPad,ie on iOS platform. So there may be quite a few ways to develop iOS apps, like the regular route through Xcode on a Mac machine, then some do through flash and some develop with HTML5, and there are more. Now I develop through Xcode on a Mac machine, well the tutorials or small guides that I put up will be based on my little knowledge of it.


So starting up, you have a Mac machine & you want to develop apps for iPhone and upload to the App Store. First, you need to download Xcode from the App Store on your Mac, its a free software. Once you're done, open Xcode. Select create a new project from the first screen.



 Then you get to a screen with quite a lot of templates, which you'll learn how to use each of them, as per your needs. For now, we'll just start off with "Single View Application". Note : We choose iOS on the left pane as we are developing apps for iOS platform and not for Mac OS X(as Xcode is used for developing Mac apps as well).


As shown above, each selection gives a little description about each of the templates below that selection pane. Then click Next button.


You give your project a name, the product name, which you usually want your app to be known as. Then the next important selection is the Devices: whether you want to develop an app for just iPhone, or just iPad or Universal,which is for both. We'll leave storyboard off for now and check ARC. And continue on.Next choose where you want the files to be saved and you're done.

You've created your very first project.Will continue with the next steps in the next tutorial.