Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Self-Destructing Message iPhone App Capturing Photo and Video Using UIImagePickerController Adding Recipients

NSLog Error: logging directory does not exist Xcode error says it can't find the file path

In the didFinishPickingMediaWithInfo:(NSDictionary *) method in the else section it is complaining about:

self.videoFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];

"Implicit conversion of C pointer type 'CGPathRef' (aka const struct CGPath *' to Objective C pointer type NSString * requires a bridge cast.

I've tried both suggestions and it still fails with the "logging directory does not exist".

a. Use __bridge to convert directly (no change in ownership)

b. Use CFBridgingRelease call to transfer ownership of a +1 'CGPathRef' (aka const struct CGPath *' into ARC

Help anyone! I've reviewed the videos 3 times and can't find the problem.

19 Answers

Hey Steve - I just found a similar post that said to reset the simulator.

// Try to reset the iOS Simulator settings it worked for me! // iOS Simulator -> Reset Content and Settings...

Now it works! Just throws the warning >>

2015-02-21 14:50:32.501 SnapChat[25371:1282426] Presenting view controllers on detached view controllers is discouraged <CameraViewController: 0x7fd4abf5e540>.

It is related to the issue that iOS 8 stores simulator devices locations differently from previous versions. /Users/apple/Library/Developer/CoreSimulator/Devices/

Thanks for your help! Just knowing that there is someone out there offering help takes a load off my shoulders. And working through the video again helped cement some concepts in my brain.

Thanks for you help Steve - you've been a big help! Still stuck for last 1.5 days, but I did manage to resolve the bridge issue.

Still not saving video/image and Xcode still shows debug logging errors. I will continue to plug away at it. If I find a solution, I'll post it.

Hi Sherrie,

Apologies, I've been away with work so I've not followed this up.

Where are you at now? Is there still an issue?

Happy to help, if so!

Steve.

Right. It is running on the simulator - are you using the standard one?

I have created me as a new user and added friends. I do have a warning about detached view controllers.

I did have the ability to choose a picture to send to my Friends but that is no longer an option. I don't have a PLLogging issue.

Talk me through how your error occurs and let me know what you're running the app on.

Steve.

I think you may have a persistence problem here too. I just signed out from my first ID (onlysteveh - my Twitter ID) then created a new ID (GenieTheDoberman). When I signed in to that, I still had friends persisting from my first ID. That's not being cleared from the local store when signing out.

The reason I created a new ID was to see if I was then allowed to send a photo. I'm not. So that's one send per-device. Again, this is a persistence issue, I'd guess.

I shall keep trying!!

Right, OK.

If I stop the app then start it again, I can manage friends and then, on clicking the camera, select an image to send to selected friends. That's as far as it gets - I'm guessing that's where you're up to.

I think your issue might be local so either a runtime issue at yours or a setup issue.

It all works OK from here.

Wow - that's a good 'un!

Can you show the whole method?

It is interesting that the error is about an NSLog - while the problem may not be there, that's a good starting point.

Paste your code in here and we can see what we can do with it!!

Cheers,

Steve.

It won't even run w/o the bridge cast, so this version contains the cast:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];

    if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
        // A photo was taken/selected!
        self.image = [info objectForKey:UIImagePickerControllerOriginalImage];
        if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
            // Save the image!
            UIImageWriteToSavedPhotosAlbum(self.image, nil, nil, nil);
        }
    } else {
        // A video was taken/selected!
        self.videoFilePath = (__bridge NSString *)([[info objectForKey:UIImagePickerControllerMediaURL] path]);
        if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
            // Save the video!
            if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(self.videoFilePath)) {
                UISaveVideoAtPathToSavedPhotosAlbum(self.videoFilePath, nil, nil, nil);
            }
        }
    }

    [self dismissViewControllerAnimated:YES completion:nil];
}

---------------------- Error Log -------------------------

2015-02-17 13:31:10.711 Ribbit[18270:1231333] Current User: Aspen 2015-02-17 13:31:22.824 Ribbit[18270:1231333] Presenting view controllers on detached view controllers is discouraged <CameraViewController: 0x7fcf20d35d70>. 2015-02-17 13:31:22.857 Ribbit[18270:1231333] [PLLogging] ***** Error: logging directory does not exist /Users/apple/Library/Developer/CoreSimulator/Devices/3AECDB62-12B1-4745-8F88-D3AE176953FE/data/Library/Logs/CrashReporter/DiagnosticLogs/

Have a look through this - it may help.

Let me know if it doesn't and I will dig a little deeper!

Steve.

http://stackoverflow.com/questions/26764363/error-logging-directory-does-not-exist-var-mobile-library-logs-crashreporter-d

I rebooted but error was still occurring. I changed the code from:

self.videoFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
to:
NSURL *imagePickerURL = [info objectForKey:UIImagePickerControllerMediaURL];
        self.videoFilePath = [imagePickerURL path];

and that seemed to help, but it is not saving the video and it still throws the errors.

2015-02-17 14:46:40.494 Ribbit[1822:41891] Presenting view controllers on detached view controllers is discouraged <CameraViewController: 0x7fc6d2d4c110>. 2015-02-17 14:46:40.528 Ribbit[1822:41891] [PLLogging] ***** Error: logging directory does not exist /Users/apple/Library/Developer/CoreSimulator/Devices/3AECDB62-12B1-4745-8F88-D3AE176953FE/data/Library/Logs/CrashReporter/DiagnosticLogs/

I'll edit that to make the code a little easier to read - have a look at the Markdown Cheatsheet!

This is still a logging issue - I really have no idea where to go. So, let's bring Ben Jakuben in on this ... Please help!

If you want to send me your code, I'll have a go at it at this end. Just create a Git repo and I'll try it out!

Hi Steve,

What timing! I completely reviewed my code against the video and vetted that it was correct. I could not resolve the issue. So, I started a new app and am at the Camera point where I just assigned the sourceType as PhotoLibrary, dropped a new image in Camera Roll on simulator.

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
        self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    } else {
        self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    }

Bam! Debug:
2015-02-21 14:32:15.512 SnapChat[24912:1268706] Presenting view controllers on detached view controllers is discouraged <CameraViewController: 0x7ff2e179f560>.

2015-02-21 14:32:15.532 SnapChat[24912:1268706] [PLLogging] ***** Error: logging directory does not exist /Users/apple/Library/Developer/CoreSimulator/Devices/

Looking around StackOverflow for that error message is interesting.

This could be a filename issue, potentially. Are you using the standard simulator?

I really have no idea where to start!

If you can update the Git repo, I can have a look if I can replicate the issue here.

Really sorry I can't answer the problem straight away!!

Steve

Here is the new project working after I reset the simulator.

https://github.com/sj24kt/SnapChat

Got it - bear with me.

I'm trying to get Xcode to talk to the repo - over a slow 3G connection, this may take time. I live miles from anywhere so there's very little mobile signal, the broadband is next to useless and the house blew all the electrics last night. Fun times!!

Can you send me a photo? Either onlysteveH or the dog's account, GenieTheDoberman! :-)

Sorry I haven't responded sooner. My sister fell on ice and destroyed her shoulder. Took her to Drs and surgery. Finished app up to last module and resolved all issues except the annoying one:

2015-02-23 09:43:37.089 SnapChat[38852:2743444] Presenting view controllers on detached view controllers is discouraged <CameraViewController: 0x7fb831444d60>.

Starting the last module today. Thanks for all your help and advice! It was tremendously appreciated!!!

I hope your sister is on the mend - sounds nasty.

I have no idea what the detached view controller thing is - but as it runs OK with it, let's leave that for now!!

Hope the rest of the module goes OK.

Steve.