4

I inherited an iOS project that targets iOS6+. A few weeks ago I moved it to Xcode 6 and cleaned up all of the warnings. One such warning was:

'UITextAttributeTextShadowColor' is deprecated: first deprecated in iOS 7.0 - Use NSShadowAttributeName with an NSShadow instance as the value

My fix to this used NSShadowAttributeName, but I did it improperly and it caused the app to crash at a certain point during execution. When I discovered this weeks later, I reverted to the old code temporarily. However, when I reverted to the old code, the deprecation warnings did not come back. I have been unable to figure out why and would like to remedy this - it alarms me that warnings aren't being shown.

For what it is worth, in certain sections of code I needed to silence deprecation warnings as a result of needing to maintain support for iOS 6. In those instances, there is separate code for iOS 6 and iOS 7+ devices and the iOS 6 code is surrounded with:

SILENCE_IOS7_DEPRECATION(

// iOS 6 code here

);

(see https://stackoverflow.com/a/26564750/3352624) This uses:

#define SILENCE_DEPRECATION(expr)                                   \
do {                                                                \
_Pragma("clang diagnostic push")                                    \
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")   \
expr;                                                               \
_Pragma("clang diagnostic pop")                                     \
} while(0)

#define SILENCE_IOS7_DEPRECATION(expr) SILENCE_DEPRECATION(expr)
#define SILENCE_IOS8_DEPRECATION(expr) SILENCE_DEPRECATION(expr)

I opted against adjusting Xcode settings and turning off warnings for large amounts of code.

So I'm confused why the deprecation warnings no longer show when I revert the code back to what it was before.

Here's what I've tried:

  1. Removed all references to the SILENCE_DEPRECATION macro from my code
  2. Verified Deprecated Functions is on under Build Settings for the target
  3. Verified my Base SDK is set to Latest iOS (8.1) and my iOS Deployment Target is set to iOS 6.0
  4. Added the -Weverything to Other Warnings Flags under Build Settings for the Target
  5. Checked out an old version of my workspace from git which was before any of my changes
  6. Quit and restarted Xcode 6
  7. Tried Xcode 5
  8. Restarted my computer, then started Xcode

None of these things caused the deprecation warnings to come back. Any ideas what should I try next?

Community
  • 1
  • 1
davew
  • 1,255
  • 15
  • 27
  • What about for the project itself? – Chase Feb 24 '15 at 22:13
  • You can change the warning settings for both the target and the project. Verify both are enabled. – Chase Feb 24 '15 at 22:16
  • @Chase thanks, I just checked. `Deprecated Functions` is set to Yes for both Target and Project. Putting `Build Settings` in `Levels` mode shows it Resolved to Yes as well. – davew Feb 25 '15 at 00:50

1 Answers1

7

I realize this is a pretty old thread, but I thought I'd post an answer in case others find this thread.

It also depends on the Deployment Target setting of the Target (i.e., under "TARGETS", click the app and choose "General" at the top, look in the "Deployment Info" section for "Deployment Target"). For example, if I have the Deployment Target at 7.1 and use functions that were deprecated in iOS 8, I won't get warnings. However, if I set the Deployment Target to 8.x or 9.0, I will get warnings for those functions.

neowinston
  • 7,584
  • 10
  • 52
  • 83
guywithmazda
  • 757
  • 7
  • 10
  • 2
    Thank you @guywithmazda, I just went back and tested this. You are correct, if I adjust the Deployment Target from 6.0 to 8.0, the deprecation warnings show up again. I'm still a bit confused however why I was seeing the iOS 7 deprecation warnings before since the project always had a Deployment Target of 6.0. Are you aware of any changes to Xcode that would impact this? – davew Jul 08 '15 at 15:12
  • Sorry, I don't know. It is possible that this is newer behavior in newer versions of Xcode, but that is just speculation. – guywithmazda Jul 09 '15 at 16:03