Suppressing warnings in Xcode

External developers... This forum's for you!

Suppressing warnings in Xcode

Postby Dave_Higgins » Sun Aug 29, 2010 8:47 am

So I'm using a couple methods that are only available with 10.5 or 10.6, and knowing that, I'm testing against the current OS version and returning the appropriate response if the system version is too low (and it will be documented, as well)... Now I'm getting the yellow warnings in Xcode about how 'ClassName' may not respond to '-methodName:', and I'd like to let Xcode know that "Yes, I understand that. Stop barking about it."

I tried setting the Active SDK to 10.5, and it stopped the related 10.5-only warning, but I gained a bunch more, all complaining about "ABS" redefined in /Library/SuperCard/SuperWASTE_470.h

If that were stopped, I'd be OK with leaving it at 10.5 and requiring Leopard to run this external, but I'd still be getting the warning for any that are 10.6-only.

I searched around Google about suppressing warnings, and 99% of the message threads are full of people telling the user to fix the problem in the code. In this case I don't know if I "can" fix the problem in code without removing the methods that I'm running. Am I just stuck with them?
My two favorite teams are Detroit and whoever's playing Chicago.
User avatar
Dave_Higgins
 
Posts: 454
Joined: Mon Jul 07, 2008 9:50 am
Location: Dark Side Of The Moon

Re: Suppressing warnings in Xcode

Postby bmartin » Tue Oct 05, 2010 12:35 pm

The recommend that you test for functionality rather than looking for a version number. How does that work?

From Apple's site:
Code: Select all
if ([NSTextView instancesRespondToSelector:@selector(setDisplaysLinkToolTips:)])
    {
        [myTextView setDisplaysLinkToolTips:NO];
    }
    else
    {
        // Code to disable link tooltips with earlier technology
    }

https://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/cross_development/Using/using.html%23//apple_ref/doc/uid/20002000-1114537


And also:
If you were to build this code with different settings, you would see the following results:

If you select a Base SDK setting of Mac OS X 10.4:
The build would fail because setDisplaysLinkToolTips: is not defined in that system version.

With a Base SDK setting of Mac OS X 10.5, if you set the Deployment OS version to:
Mac OS X 10.5: The software would run only on v10.5 or later and fail to launch on earlier systems.
Mac OS X 10.4: The software would run on v10.5 and v10.4 but fail to launch on earlier systems.


So it's not so much setting the Base SDK but setting the Deployment OS.
Bruce Martin

Mac Os 10.6.3
2.8 Ghz Intel Core 2 Duo
4GB 1067 MHz DDR3
User avatar
bmartin
 
Posts: 149
Joined: Mon Jul 07, 2008 7:26 am
Location: Stroudsburg, PA

Re: Suppressing warnings in Xcode

Postby codegreen » Tue Oct 05, 2010 3:45 pm

Dave Higgins wrote:So I'm using a couple methods that are only available with 10.5 or 10.6, and knowing that, I'm testing against the current OS version and returning the appropriate response if the system version is too low (and it will be documented, as well)... Now I'm getting the yellow warnings in Xcode about how 'ClassName' may not respond to '-methodName:', and I'd like to let Xcode know that "Yes, I understand that. Stop barking about it."

There are a few techniques I know of for doing this, and they basically all are painfully inadequate as a general solution.

For some warnings you can use the (relatively new) gcc diagnostic pragmas (see http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html), which have pretty limited support in 4.0, and a bit less limited support in 4.2.

If the method selector takes an object as its param you can use respondsToSelector: and performSelectorWithObject:

If neither of those is applicable you can suppress the warning for the entire source file, or even the whole project using xcode's target settings.

If push came to shove you could also compile all the stuff for higher versions into a separate bundle and then load the functions in it via CFBundleGetFunctionPointerForName.

There might be other approaches, but these are the ones I'm aware of...

-Mark
codegreen
 
Posts: 1510
Joined: Mon Jul 14, 2008 11:03 pm


Return to Xcode and the Internals Toolbox

Who is online

Users browsing this forum: No registered users and 1 guest