More info:

I have managed to reproduce the crash on my 10.9 machine, and can confirm that 
the crash is caused by attempting to access the symbol 
MLMediaSourcePhotosIdentifier. (It wasn’t crashing because I’d locally defined 
a string with this name to see if that fixed the probem - it did, but I’d 
forgotten about it. Unfortunately just locally defining it won’t be correct for 
a 10.10 system, though I wonder if that would work provided I used the exact 
same string as Apple? Seems hackish…)

Any reference to it causes EXC_BAD_ACCESS, even testing to see whether it’s nil 
or not. I need a smart way to determine whether an externally linked string 
really exists in a framework or not which won’t crash if the symbol doesn’t 
exist.

—Graham




> On 23 Apr 2015, at 3:15 pm, Graham Cox <graham....@bigpond.com> wrote:
> 
> I’m a bit confused/concerned about a problem I’m having using MLMediaLibrary.
> 
> On 10.10, my code works fine, and imports the media from Photos or iPhotos OK.
> 
> On 10.9, the same code crashes. At the moment it’s a bit unclear exactly 
> where it’s crashing - The app I built on 10.10 using XCode 6.3 crashes on 
> 10.9.1, but moving the project over to my 10.9 machine to find out why it was 
> crashing required a massively tedious set of updates to get a working 
> development system. In the end I have 10.9.5 with Xcode 6.1, but when I build 
> using that the same code no longer crashes. That means that I’m having a hard 
> time reproducing the problem I was seeing because I can’t build and debug on 
> the system that exhibits the problem.
> 
> What it appears to be is that the earlier 10.9 version of 
> MediaLibrary.framework did not export the string constant 
> MLMediaSourcePhotosIdentifier, even though it’s declared in the header. The 
> string is declared extern, and on a build using the 10.10 SDK, links fine. 
> When it finds itself running on 10.9.1, this linkage fails. I’m not sure what 
> happens when a string constant can’t be linked, presumably the address is 
> random or nil. This crashes my code which adds this string to the options 
> dictionary passed to  -[MLMediaLibrary initWithOptions:]
> 
> For my code, the MediaLibrary.framework is optional, and I detect whether 
> it’s available by testing whether NSClassFromString(@“MLMediaLibrary”) return 
> Nil or a valid Class. But that doesn’t help with the extern identifier string 
> - the framework exists but the string doesn’t in some versions. What is a 
> clean way to detect whether an externally linked string exists, and if it 
> does not, to supply it myself? Or maybe I don’t need to bother, since any 
> version of the OS that doesn’t export the string is not going to be able to 
> run Photos anyway, so that combo will never arise in practice.
> 
> Of course this might not be the reason for the crash, but it’s the best 
> theory I have at the moment.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to