深入研究之后AvailabilityInternal.h,我意识到部署目标上方的所有可用版本都被__AVAILABILITY_INTERNAL_WEAK_IMPORT宏标记。因此,我可以通过重新定义该宏来生成警告:#import <Availability.h>#undef __AVAILABILITY_INTERNAL_WEAK_IMPORT#define __AVAILABILITY_INTERNAL_WEAK_IMPORT \ __attribute__((weak_import,deprecated("API newer than Deployment Target.")))通过将此代码放置在项目的预编译头文件中,任何可能在受支持的最低iOS版本上导致崩溃的API用法现在都会产生警告。如果您正确地保护了呼叫,则可以专门针对该呼叫禁用警告(Apple SDK兼容性指南中的修改后的示例):#pragma GCC diagnostic ignored "-Wdeprecated-declarations" if ([UIPrintInteractionController class]) { // Create an instance of the class and use it. }#pragma GCC diagnostic warning "-Wdeprecated-declarations" else { // Alternate code path to follow when the // class is not available. }