2

I'm developing an app where I have integrated sky drive framework. But when I try to login my app crashes with:

uncaught exception 'NSInternalInconsistencyException

Reason:

Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/

Using the "LiveSDK/Library" it works fine but the library does not work with ARC. What am I doing wrong?

Here is my code:

(void)signInMethod { 
self.liveClient =
[[LiveConnectClient alloc] initWithClientId:APP_CLIENT_ID 
                                                     delegate:self 
                                                    userState:@"initialize"]; 
}

-(void)authCompleted:(LiveConnectSessionStatus) status 
          session:(LiveConnectSession *) session 
        userState:(id) userState { if ([userState isEqual:@"initialize"]) {
    [self.liveClient login:self 
                    scopes:[NSArray arrayWithObjects:@"wl.signin", nil] 
                  delegate:self 
                 userState:@"signin"];

} if ([userState isEqual:@"signin"]) {
    if (session != nil)
    {
        NSLog(@"signed in");      
    }
     } }

-(void)authFailed:(NSError *) error 
     userState:(id)userState { NSLog(@"%@",[NSString stringWithFormat:@"Error: %@", [error localizedDescription]]);  }
Thanh-Nhon Nguyen
  • 3,402
  • 3
  • 28
  • 41
Ronit
  • 81
  • 4

2 Answers2

3

The error message basically says that you have a ViewController that is trying to load a NIB file, but it cannot find it because it either is not included in the resources or it has a different name than expected.

The full error message should contain the name of the file - as you did not post it I can't know for sure, but LiveAuthDialog_iPador LiveAuthDialog_iPhone might be missing here, those are the only .xib files I've found used by the LiveSDK.

Remove the reference to the .xib file and re-add it to your project (if it exists), otherwise add it to your project. Then Clean and Build again.

(see also: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle)

Update (see comments):

In case the compiled library version ('LiveSDK.framework') is used (instead of importing the LiveSDK sources), the framework expects to be included in the app bundle's Resources folder, either by adding it to the Copy Bundle Resources build phase of the host project, or by adding it to a Copy Files Build Phase with the destination set to Resources.

The placement is important b/c the LiveSDK's -[LiveAuthRequest authorize] method will primarily try to load the NIB files for the authentication dialog from the framework bundle (using -[LiveAuthHelper getSDKBundle]), expecting the framework to be found inside the main bundle's resources:

+ (NSBundle *) getSDKBundle
{
    NSString *sdkPath = [[NSBundle mainBundle] pathForResource:@"LiveSDK"
                                                        ofType:@"framework"];
    return (sdkPath)? [NSBundle bundleWithPath:sdkPath] : [NSBundle mainBundle];
}
Community
  • 1
  • 1
mvanallen
  • 714
  • 5
  • 12
  • There is a file called LiveAuthDialog_iPhone.nib in LiveSDK.Framework/Resources. How can I make my application use it? In my application, the code that try to login is not ViewController, it is NSObject class, I'm using UINavigationController.visibleViewController for the login first parameter. – Ronit Jul 02 '14 at 11:24
  • 1
    Did you add the LiveSDK.framework to your project's "Copy Bundle Resources" build phase? – mvanallen Jul 02 '14 at 12:06
  • Great, happy to help! :) Please remember to mark the answer you found most helpful as accepted as that will also help others encountering the same problem. Cheers – mvanallen Jul 03 '14 at 18:22
  • mvanallen - can you add your comment as an answer instead of a comment? – Ryan Gregg Jul 08 '14 at 04:52
  • RGregg - you're right, I've updated the answer accordingly; thanks for the hint. – mvanallen Jul 08 '14 at 10:31
0

YOU NEED TO REGISTER YOUR NIB FILE IN ViewDidLoad. If its tableViewCell then use below code [self.tableView registerNib: withCellIndentifier];

You you are trying to load View nib then YourViewController *myview = [UIViewController alloc] initWithNib:];

If the nib file is itself missing then to to Target-> build phase-> Copy bundle resource and add your missing nib file

GameBegins
  • 580
  • 7
  • 12