tags:

views:

2392

answers:

7

With the latest Xcode and SDK 3.0 beta when you create a new iPhone project, Xcode creates an SDK 3.0 project. If I want to revert to SDK 2.2.1 after the project has been created, I need to change something in the generated source code files since some of the APIs have changed. Is there a simple way to specify at project creation time the SDK I want to use explicitly?

Thank you in advance

+2  A: 

Provided that you're not using any new features in the 3.0 API, you should be able to select the Active SDK from the dropdown menu on the upper left corner of your Xcode project window. Simply select "Device - 2.2.1" or "Simulator - 2.2.1"

qrunchmonkey
Note that this doesn't change the project setting, but only the active configuration. It's still a valid option for one-man shops, though.
Can Berk Güder
Yes, I know, but this does NOT solve the problem: once created, the generated files still contain the 3.0 APIs, that must be changed manually in order to build for 2.2.1
unforgiven
+1  A: 

Xcode defaults to the newest SDK installed, and I'm not aware of any method to change that behavior.

I made it a habit to set the base SDK to 2.0 in the project properties right after I create the project.

Can Berk Güder
So there is no hope: each time I create a project, I will ALWAYS (sigh) need to manually edit the generated source files to remove 3.0 only APIs in order to build for 2.2.1. This is very stupid , and I do not understand why Apple did not provide such an option.
unforgiven
Which generated files that contain 3.0 APIs are you referring to?
sigjuice
@unforgiven: AFAIK, the generated files don't contain SDK-version-specific code. You just need to change the project setting.
Can Berk Güder
A: 

There is not according to Apple. Comments to my posting from Can Berk Güder say otherwise. I would not suggest following his example - it's a lottery hoping Apple can't see what you are doing or that you do not fall foul of a 3.0 defect.

You can use Xcode to build for earlier versions of the OS but if you need to build with multiple SDKs you should install them. Xcode supports multiple installations on a single machine and the install instructions document how to do it.

If you want to use the 3.0 SDK you can't built for OS 2.2.1 and submit that application to the app store - according to Apple's guidelines. They say that you must also install the 2.2.1 SDK and build with that. You can build 2.2 compatible apps but you are using beta tools which might introduce bugs.

It's one of those things that you can do as an intellectual exerxcise but, it's just not worth the risk for a real app.

Roger Nolan
I do not want to use SDK 3.0 to build for OS 2.2.1: quite the opposite indeed. I want to use sdk 3.0 to build for OS 3.0, and SDK 2.2.1 to build for OS 2.2.1. And I'd like to do this using the same Xcode installation. That is what I meant in my question: so basically I need to install Xcode again
unforgiven
That is simply not true. I have the 3.0 SDK installed, and I just built and submitted a 2.0 App.
Can Berk Güder
See my blog entry on this subject: http://cbg.me/2009/03/some-clarifications-regarding-the-iphone-30-os-sdk/
Can Berk Güder
Can, you're right, I used must to mean what Apple say you should do. Obviously you can build a 2.2 app with the 3.0 SDK and hope Apple don't check this _and_ you don't ship a stinking bug ridden piece of crap but, I think shipping software is best built with a released SDK.
Roger Nolan
If you pick the 2.0 SDK in project settings, you build with the 2.0 SDK, not 3.0.
Can Berk Güder
Can, I realise that and believe I said it in my answer. What I'm trying to get across is that 3.0 is a BETA SDK so you shouldn't use it to buid your release app. It's certainly (even trivially) possible but not recommended - by Apple or anyone sensible.
Roger Nolan
I agree with Roger. I Will never release an application built using a pre-releale toolchain.
unforgiven
+3  A: 

I can't comment specifically on iPhone SDK 3.0 as it's covered under NDA; there's a forum for disclosed developers at devforums.apple.com. But Roger Nolan is half right and half wrong. He's half right in that when any SDK is updated, the examples and templates in that SDK are updated to exploit it. That is, the templates may specifically use the new APIs in that SDK, and the code might plain just not work with earlier SDKs.

That said, you can save project templates from earlier SDKs and install them in a local directory (like ~/Library/Application Support/Developer/Shared/Xcode/Project Templates) for use with later versions of Xcode. The project template format itself hasn't changed; templates should be forwards and backwards compatible, but the content of the templates is usually locked to the SDK version it ships with and later.

Mr. Nolan is half wrong about building against earlier OS versions with later SDKs. That's why the earlier SDK packages are provided with the later distributions (they're not there just to make the downloads take longer). You can deploy against older OS versions with a newer SDK by setting the Deployment Target build setting.

There is the minor detail in that you probably shouldn't deploy production applications produced by a pre-production toolchain. But once version N is officially released, you should be able to use its toolchain to build for N-1, N-2, etc.

cdespinosa
I checked the forum, since I am an official (paying) iPhone developer, but did not spot anything related. I know the story related to templates, but this is a hack: I was asking instead for an official solution, not a workaround.
unforgiven
The point is that you can *ask* questions about NDA versions of the iPhone SDK in the NDA forum and get them answered directly, instead of in generalities. The general answers are 1) use older templates; 2) edit the newer templates, or 3) change the Base SDK when creating a new project.
cdespinosa
3.0 sdk is now out. this answer is out of date.
Neo42
+1  A: 

When using a Beta toolchain, you should install it alongside the latest released toolchain, not in place of it. Create your projects in the production toolchain, then open them with the beta toolchain to to do compatibility testing.

You will need the released toolchain anyway in order to do distribution builds. You should not build for distribution with a beta toolchain.

Frank Szczerba
+1  A: 

Unforgiven, did you ever find a satisfactory answer to this? I am having the same problem, and reading the above responses I really don't believe that people understood your question.

The issue is, when you install the later version of the SDK, the default templates (i.e. when you do File -> New Project), are all tailored for the newest SDK (i.e. the code files in the template contain code that will only work with the newest SDK), a good example is the "Navigation Based Application" for iPhone.

Is there are a way of specifying at create time the SDK version you are targeting and have Xcode choose the relevant project template.

I'm still fairly new to Mac/iPhone programming and Xcode so rely on the templates to help me out.

Chris.

A: 

i have to devlop a apllication like navigation one control to next two control then next and so on . pls send me some source code about that i will always than ful to u

Arun Gairola