getSupportedOrientations() in juce_ios_UIViewComponentPeer.m

This methods gives compilation errors if you’re not compiling against iOS SDK 6.

static NSUInteger getSupportedOrientations()
{
    NSUInteger allowed = 0;
    Desktop& d = Desktop::getInstance();

    if (d.isOrientationEnabled (Desktop::upright))              allowed |= UIInterfaceOrientationMaskPortrait;
    if (d.isOrientationEnabled (Desktop::upsideDown))           allowed |= UIInterfaceOrientationMaskPortraitUpsideDown;
    if (d.isOrientationEnabled (Desktop::rotatedClockwise))     allowed |= UIInterfaceOrientationMaskLandscapeLeft;
    if (d.isOrientationEnabled (Desktop::rotatedAntiClockwise)) allowed |= UIInterfaceOrientationMaskLandscapeRight;

    return allowed;
}

It would be nice if it were ifdef-ed to work on iOS SDK 5 as well:

static NSUInteger getSupportedOrientations()
{
    NSUInteger allowed = 0;

    Desktop& d = Desktop::getInstance();

#ifdef __IPHONE_6_0
if (d.isOrientationEnabled (Desktop::upright)) allowed |= UIInterfaceOrientationMaskPortrait;
if (d.isOrientationEnabled (Desktop::upsideDown)) allowed |= UIInterfaceOrientationMaskPortraitUpsideDown;
if (d.isOrientationEnabled (Desktop::rotatedClockwise)) allowed |= UIInterfaceOrientationMaskLandscapeLeft;
if (d.isOrientationEnabled (Desktop::rotatedAntiClockwise)) allowed |= UIInterfaceOrientationMaskLandscapeRight;
#else
if (d.isOrientationEnabled (Desktop::upright)) allowed |= UIInterfaceOrientationPortrait;
if (d.isOrientationEnabled (Desktop::upsideDown)) allowed |= UIInterfaceOrientationPortraitUpsideDown;
if (d.isOrientationEnabled (Desktop::rotatedClockwise)) allowed |= UIInterfaceOrientationLandscapeLeft;
if (d.isOrientationEnabled (Desktop::rotatedAntiClockwise)) allowed |= UIInterfaceOrientationLandscapeRight;
#endif

    return allowed;
}

That’s not the correct way to detect the iOS version! You need to use all the __IPHONE_OS_VERSION_MAX_ALLOWED macros etc

I’ve just moved to a new machine and don’t even have a version of the 5.0 SDK any more… I know on OSX there are reasons to compile against the older SDKs, but surely on iOS the best practice is to use the latest one, and select an older deployment target?

Well, my reasoning has been if I compile against the oldest SDK I support I’ll know it works on that SDK and I know that Apple will have a team of people testing to make stuff compiled against the old SDK will work when loaded on an OS with the new SDK. If I compile against the newer SDKs, then the responsibility to ensure that it still works on the older SDK shifts to me, and then, I have to start being careful about ifdef-ing out functionality that’s only available in the new SDK and devoting time to explicitly testing this. Maybe, there are some advantages of your way of doing things that I’m not seeing though…

Also, and this is beside the point, but I have one machine I can’t upgrade past Snow Leopard for a few reasons including the fact that the current release of Pace’s tools need PPC support and the newer releases of Xcode can’t be installed on Snow Leopard…

Incidentally, I was just trying to build on Snow Leopard with Juce head, and juce_mac_Windowing.mm seems to be using a macro (or enum) only available in Lion. I added the following ifdef to PMAssertion:

struct PMAssertion
{
    PMAssertion()  : assertionID (kIOPMNullAssertionID)
    {
        // kIOPMAssertionTypePreventUserIdleDisplaySleep is first available in OS 10.7
        #if __MAC_OS_X_VERSION_MAX_ALLOWED > 1070
        IOReturn res = IOPMAssertionCreateWithName (kIOPMAssertionTypePreventUserIdleDisplaySleep,
                                                    kIOPMAssertionLevelOn,
                                                    CFSTR ("JUCE Playback"),
                                                    &assertionID);
        jassert (res == kIOReturnSuccess); (void) res;
        #endif
    }

Didn’t I already fix that IO assertion thing?

I just got the following error with the Juce tip:

‘kIOPMAssertionTypePreventUserIdleDisplaySleep’ was not declared in this scope

Trying to build a plugin in Snow Leopard, using the 10.4 SDK.

I just got the following error with the Juce tip:

‘kIOPMAssertionTypePreventUserIdleDisplaySleep’ was not declared in this scope

Trying to build a plugin in Snow Leopard, using the 10.4 SDK.[/quote]

Hard to believe that, since that bit of code is only enabled if you’re building for 10.7 or above. Something sounds a bit screwy in your build…