Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
716 views
in Technique[技术] by (71.8m points)

iphone - Why is the Xcode compiler not warning me about invalid methods for my Deployment Target?

I have an Xcode (4.3.2) project with the latest SDK which I would like iOS 4.0 users to be able to run. So in project settings I have set the Deployment Target value to iOS 4.0. It is the same in the Targets settings.

However, I just realized my code is using an iOS 5+ API call. This one:

[self.tabController.tabBar setBackgroundImage:tabBackground];      //Invalid in iOS 4.x ???

The compiler is not giving me any warnings. Shouldn't it??? What will this do when executed on an iOS 4.0 device? Sadly, I don't have one to test on currently. This makes me extremely worried that there are other places where the same thing is happening and my program is now hopelessly tied to iOS 5.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The compiler will not warn you about those things unless you explicitly set the "base sdk" setting of your project to a lower iOS version.

Unfortunately the latest Xcode version does not seem to include any iOS SDKs prior to version 5.1, so you can't select 4.0 there. I would suggest keeping a second install of Xcode 3.x that comes with the iOS 4.0 SDK, and use that to make sure you aren't using methods from newer SDK versions. Finally, if you are really serious about iOS development and supporting 4.0 is a must for you (why?), you should test on a device that hasn't been upgraded to iOS 5.0 yet (e.g. older iPod touch off ebay..).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...