Hi,
Currently I made of mistake that make my app crash on iOS7. Dues to no iOS7 simulator available now, so I met a big trouble to find the problem. Finally, I borrowed a iOS7's iPod touch from my friend to find the root cause.
The problem is I accident used a new API
- (BOOL)containsString:(NSString *)str NS_AVAILABLE(10_10, 8_0);
of NSString.
It only available after iOS8 but my min deploy platform is iOS7.
Fortunately I find the solution this time. But I really want to avoid this kind of error in future.
Does anybody know are there some way to check the API's available when compile the source to avoid such problem?
Any suggestion will be the great help...
Thank you~~
Eric
>> By the way I can't find any setting that call "TargetOS"? Did I miss something?
No, you didn't miss anything. When you create a "target" in Xcode, you have to choose whether to create an OS X, iOS, watchOS, tvOS target. Then the target's build settings have a "Base SDK" setting, which allows you choose which version of the platform API to write your code for. However, in recent versions of Xcode, there is usually only one possible Base SDK choice. (In the past, Xcode shipped with multiple SDK versions for each platform, but that doesn't happen any more.)
The "deployment target" is a "target" in a different sense. There is nothing that's called "TargetOS". Mr. Wrench is referring to the platform and/or the Base SDK.
To answer your original question, in Objective-C there's no good, built-in way of checking whether you're using API that's too new for your deployment target. (Again, Xcode used to ship with multiple SDK versions, so you used to be able to choose an older one, and then you'd get compile errors. But that doesn't happen any more.)
In Swift, this availability checking is built into the language, but for Obj-C your choices are:
— use an older version of Xcode that has the Base SDK version that matches your deployment target version
— use a 3rd-party utility such as Deploymate (deploymateapp[dot]com)
— or just be very, very careful 😉