Re: mobileCoreServices.framework on 2.2.1

31 views
Skip to first unread message
Message has been deleted
Message has been deleted

Andrew Pouliot

unread,
Apr 27, 2010, 4:05:05 PM4/27/10
to asihttp...@googlegroups.com
If I understand correctly, this is the method in question:


+ (NSString *)mimeTypeForFileAtPath:(NSString *)path
{
if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
return nil;
} else if ([ASIHTTPRequest isiPhoneOS2]) {
return @"application/octet-stream";
}
// Borrowed from
http://stackoverflow.com/questions/2439020/wheres-the-iphone-mime-type-database
CFStringRef UTI =
UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension,
(CFStringRef)[path pathExtension], NULL);
CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass (UTI,
kUTTagClassMIMEType);
CFRelease(UTI);
if (!MIMEType) {
return @"application/octet-stream";
}
return [(NSString *)MIMEType autorelease];
}


Looks like it already takes into consideration OS 2.x and doesn't call
the relevant functions. To get the app to link, you can follow the
advice here:

http://stackoverflow.com/questions/986589/how-do-you-optionally-use-iphone-os-3-0-features-in-a-2-0-compatible-app/1025580#1025580

—Andrew

On Tue, Apr 27, 2010 at 12:28 PM, Jesse Naugher <nau...@gmail.com> wrote:
>
> basically I think the question is...what version made
> mobilecoreservices.framework required? This way i can just use a
> version before that and avoid the issue?
>
> On Apr 27, 10:11 am, Jesse Naugher <naug...@gmail.com> wrote:
> > I see that it is required to add this framwork to get ASIHTTPRequest
> > to work, however the site says it is compatible with iPhone OS 2.2.1+.
> > How would one with 2.2.1 use it as the mobilecoreservices.framework is
> > not available in 2.2.1?
> >
> > I saw a post describing someone using a work around using old mime
> > file type file or something, but how is this done or is there another
> > way?
> >
> > Thanks for your help.
> >
> > --
> > You received this message because you are subscribed to the Google Groups "ASIHTTPRequest" group.
> > To post to this group, send email to asihttp...@googlegroups.com.
> > To unsubscribe from this group, send email to asihttpreques...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/asihttprequest?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "ASIHTTPRequest" group.
> To post to this group, send email to asihttp...@googlegroups.com.
> To unsubscribe from this group, send email to asihttpreques...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/asihttprequest?hl=en.
>

--
You received this message because you are subscribed to the Google Groups "ASIHTTPRequest" group.
To post to this group, send email to asihttp...@googlegroups.com.
To unsubscribe from this group, send email to asihttpreques...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/asihttprequest?hl=en.

Message has been deleted

Ben Copsey

unread,
Apr 28, 2010, 5:51:46 AM4/28/10
to asihttp...@googlegroups.com
Hi Jesse

> Yes but there should be another way to make the app link..by actually
> linking from the 2.2.1 OS (I dont have snow leopard and am using an
> old version of xcode with only OS 2.2.1 installed).


I'm afraid it's rather difficult for me to test this, as it doesn't appear to be possible to build with 2.2.1 base SDK (it comes up as 'missing' in the project settings) if you have the newest release dev tools.

I guess you could try something like this (__IPHONE_3_0 should be defined in ASIHTTPRequest.h if it isn't already):

+ (NSString *)mimeTypeForFileAtPath:(NSString *)path
{
#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_3_0
if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
return nil;
} else {
return @"application/octet-stream";
}
#else
if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
return nil;
} else if ([ASIHTTPRequest isiPhoneOS2]) {
return @"application/octet-stream";
}
// Borrowed from http://stackoverflow.com/questions/2439020/wheres-the-iphone-mime-type-database
CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (CFStringRef)[path pathExtension], NULL);
CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass (UTI, kUTTagClassMIMEType);
CFRelease(UTI);
if (!MIMEType) {
return @"application/octet-stream";
}
return [(NSString *)MIMEType autorelease];
#endif
}

As Andrew suggested, if you can set your deployment target to 2.2.1 and your base SDK to 3.0 or greater, and change MobileCoreServices.framework to 'weak' rather than 'required', I *think* you should be able to build for 2.2.1 without modifications. Again, I'm afraid I'm not able to test that this still works.

Best,

Ben
Message has been deleted

Ben Copsey

unread,
May 5, 2010, 6:12:03 AM5/5/10
to asihttp...@googlegroups.com
Hi Jesse

> Hey again, I updated to Xcode 3.2.2 (finally haha) and am now using
> ASIHTTPRequest and love it..but when i link
> mobilecoreservices.framework weakly and etc i still crash on a 2.2.1
> iphone but it works great on my 3.1.3 iphone.
>
> Even if i link weakly do i need to do the preprocessing #IF to check
> the version in that method? any thoughts?

If it's crashing when mimeTypeForFileAtPath is called, you could try changing it to use runtime version detection:

if ([ASIHTTPRequest isiPhoneOS2]) {
if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
return nil;
} else {
return @"application/octet-stream";
}
} else {
...etc

Failing that, just modify the method to just return @"application/octet-stream". A lot of the time, detecting the mime type isn't really that important.

Sorry I can't be more help, but I can't test this myself.

Best
Reply all
Reply to author
Forward
0 new messages