Builds, Runs but crashes immediately (P. 565 "Build and


#1

Builds…runs…but crashes immediately (P.565. "Finally, we can test our work. Build and run NerdFeed on a device.

Using IPad2 Model MC916C
OS. 5.1.1 (9B206)

Built on Xcode 4.3.2
OSX Lion 10.7.3


//
// main.m
// NerdFeed
//
// Created by Michel McMahon on 12-05-06.
// Copyright © 2012 MyCompanyName. All rights reserved.
//

#import <UIKit/UIKit.h>

#import “NerdFeedAppDelegate.h”

int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([NerdFeedAppDelegate class])); // Thread 1: signal SIGABRT
}
}


Logged…


2012-05-12 14:47:32.879 NerdFeed[2509:707] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: NSPersistentStoreUbiquitousContentURLKey)’
*** First throw call stack:
(0x3198c88f 0x317d7259 0x3198c789 0x3198c7ab 0x318f968b 0x80dc3 0x80c01 0x7d603 0x7de63 0x7d0bd 0x31bf1cab 0x31beb7dd 0x31bb9ac3 0x31bb9567 0x31bb8f3b 0x32dbc22b 0x31960523 0x319604c5 0x3195f313 0x318e24a5 0x318e236d 0x31bea86b 0x31be7cd5 0x7cfaf 0x7cf54)
terminate called throwing an exception(lldb)



#2

It sounds like this line is coming back as nil:

NSURL *ubContainer = [fm URLForUbiquityContainerIdentifier:nil];

Are you on the device? Have you provisioned the app for iCloud? Do you have an internet connection?


#3

I will go through the steps again to be sure.


#4

I went to the Entitlements section in the Summary for the app and noticed that it has become unchecked (at Entitlements [ ] Enable Entitlements). I attempted to re-check it but it doesn’t seem to be letting me do so. The check mark appears for a fraction of second and disappears leaving me unable to enter the required information in the section.

Any idea?


#5

Huh. Perhaps the provisioning setup was incorrect? Can you verify that you have the appropriate provisioning profile and it has been marked for iCloud use?


#6

I was dealing with the same error. I noticed the iCloud Containers section on the target summary screen was blank. I hit + and added the bundle identifier and that seemed to solve my problem. Or maybe it was coincidence, I don’t really know. :slight_smile:


#7

That is the issue. We actually caught this issue a bit too late in the process, where if the entire provisioning process didn’t go thru perfectly, you’d get this crash. In reality, there should be a check to see if the ubContainer was non-nil, and if it was nil, it should say something like “Couldn’t create teh container, check your provisioning and project settings.”


#8

So we should add bundle identifier to save it, right?


click me


#9

Same thing happened to me, what a sloppy finish to the book :stuck_out_tongue: But at least we’re done!

So yeah, adding the bundle to the iClound containers on the summary tab fixed it up nice and good. Is that supposed to happen automatically when you add the provisioning profile?

Props to BNR for a great book! I should have been making iOS apps years ago but this book finally guided me through the woods. Just in time for iOS 6! :smiley:


#10

Also found another reason why this might crash and burn with the nil ubContainer.

For some reason, in my settings for iCloud -> “Documents and Data” it was set to “off”, changing that setting to on did the trick. So, just a setting thing. Not certain how it got to off, but if it helps someone else to find the same issue…


#11

As lwkipp said, make sure your your phone is actually logged into iCloud. Whoops. That was an hour of debugging over a stupid issue.

On your phone/ipad, go to your Settings -> iCloud. My account wasn’t logged in and I was getting the nil ubContainer issue, with correct provisioning profile setup.

Thanks BNR & Mr. Conway, great work on the book.


#12

[quote=“lwkipp”]Also found another reason why this might crash and burn with the nil ubContainer.

For some reason, in my settings for iCloud -> “Documents and Data” it was set to “off”, changing that setting to on did the trick. So, just a setting thing. Not certain how it got to off, but if it helps someone else to find the same issue…[/quote]
Thanks so much for this! I have two devices, side by side, both connected to my Mac, same provisioning profiles, everything except this setting. One worked, the other didn’t. Turning on “Documents and Data” fixed it.

My, my, that was obscure!


#13

The following works to me:

There is two possible reasons to get an error:

To solve the issue you just have to go to Project -> Targets -> Summary:
Check: iCloud -> Enable iCloud
Ubiquity container: Click on ‘+’ to add com.bignerdranch.Nerdfeed
</First one>

On you iCloud setting outside on the application make sure that: "Documents and Data" is set to 'on'

Clean, Build and Run.

It should solve your issues.

Hope it’ll help

Best regards,
P. AROUETTE


#14

patrickarouette,
Thank you, helpful.