How do I create in Xcode an iPhone project specifying at project creation time the SDK version I want to use? - iphone

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

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.

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"

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.

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.

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.

Related

Older SDK disappeared after installing new Xcode version

Why are old SDKs beeing removed when installing a new version of xcode with new Iphone SDK ?
Now we have v4, what settings do I have to make in order that the apps still work with 3.x ?
Thanks
Set the Base SDK to 4.0 and Deployment Target to 3.x. Or, in modern conditions, the Base SDK to Latest and Deployment Target to whatever you need.
Although 'Zoul' has most succinctly answered the question, I shall make an attempt to elaborate on the 2 settings and point to some useful documents which will help others who are new to the situation.
Base SDK Version: This indicates the version of the SDK based on which the program has been compiled. This can be set from the "Build Settings" for the project or target. You can use API code from Apple in your code introduced up-to that version and compiler will know all the symbols and compile without any issues.
Deployment target: This is a declaration from your side about the minimum iOS version which should be installed on the user's device to run your code. This setting can be found under "Info" section for Project and "Summary" section for a particular target. Now, important thing to understand is that your code will not automatically run smoothly on devices with older versions of the iOS if you are using API code introduced in later version by Apple. These can be new classes/methods/frameworks introduced by Apple in later version. You have to ensure by writing necessary conditional code and provide alternate code path to gracefully degrade for older iOS version which does not have the newer API. It is up-to you to handle version incompatibilities.
Apple documentation on the subject can be found in "SDK Compatibility Guide".
To know about the changes with different versions of iOS refer "What's new in iOS".
This topic is also discussed in "iOS Development Guide" under section "Building and Running Application". Refer sub-section "Specifying the Runtime Environment".
If you have backups of your system from something like Time Machine (and you better!) you can copy the older SDKs from the backup located at /Developer/Platforms/iPhoneOS.platform/Developer/SDKs and /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs - then just restart XCode and you're ready to go.
If you still have the problem after you set Deployment target at least as low as your desired SDK, then you need to download that SDK. Luckily, Xcode helps us here also:
look after Simulator selector in top left of your Xcode and select More Simulators. It will open a page like the one below:
just select the SDK you need to test your app against.
3.2.3 last beta did remove all other SDK's cause to many people tried publish Apps developed with the beta SDK, which will not be accepted. I guess GM is doing still the same
If you want to develop for 4.0,3.2 and 3.0 (plus 3.0,3.1,3.1.2,3.1.3)
do the following
sudo /Developer/Library/uninstall-devtools –mode=all (This will uninstall the current XCode installation)
Then install first old XCode (3.2 final) in default folder (/Developer)
Then install the new XCode (3.2.3 GM) in other folder (/DeveloperBeta)
This way you will have both. And can launch xcode from either /Developer/Applications/Xcode.app or /DeveloperBeta/Applications/Xcode.app

If I install SDK 4.0 of the iPhone OS will I still be able to create a non 4.0 iPad app?

If I install SDK 4.0 of the iPhone OS will I still be able to create a non 4.0 iPad app?
I would ideally like to submit a iPad app in the next month but am also hoping to develop a 4.0 iPhone app is it possible to use the 4.0 SDK to create 3.0 iPad apps or am I going to need to computers?
You do not need two computers. You will have to install the two SDKs in two different directories. So far, it's always been the way that beta releases of the SDK were not meant (and not allowed) to generate apps for distribution.
But in the installer, just select another new directory and then install the second SDK there. That's all there is to it.
So far Apple has always provided a way to create Applications compatible to older versions of iPhone/iPad OS. The SDK installer will install the SDK in a version specific subdirectory. Additionally there is a "Current" directory hardlinking against the newest version. The old versions will still be available.
XCode will let you select an iPhone OS Version in the build settings and automatically figure out the correct SDK version/directory, so there's no need to fumble with paths or include directories.
Build against the latest SDK and set your "deployment target" to a lower version.
If you use new API calls (available in the SDK but not in the deployment version) check at runtime before calling them.

iTunes Connect rejects my binary because I used a pre-release version of the SDK, what should I do?

I downloaded a pre-release version of the iPhone SDK and tried to update one of my existing apps using a binary I built with it. Obviously you are not supposed to do this but I had forgotten about the warning when I installed the pre-release SDK. Anyway - I have two questions:
Can I simply set the base SDK to an earlier version in the build settings and get around this problem?
If not, then what should I do?
You need to download the release version of Xcode with the release iPhone SDK. You can't use the SDK downloaded from the iPad beta version for any release products.
Just go to http://developer.apple.com/iphone/index.action and click on iPhone SDK 3.1 and download it. Then build your app bundle with that and submit it to Apple.
Before you download a pre-release version of the SDK from developer.apple.com, there are several prominent warnings, one of which clearly states that pre-release versions of Xcode / iPhone SDK can NOT be used to build production binaries. So the answer to 1. is an emphatic no.
As far as I can tell, the only option to be able to build production binaries that iTunes Connect will accept is to delete the pre-release version of Xcode / iPhone SDK and re-install the older stable version.
If you upgraded using the beta download (as opposed to installing on a fresh box that has never seen SDK or Xcode), set the base SDK to a released version of the OS. Compile a Distribution build, submit to the app store. The old SDK is still there, so that will get used. All of the prominent warnings I have seen state the the SDK cannot be used, without mention of Xcode.
Before anyone scoffs, note that I submitted an app on March 13 using the version of Xcode (3.2.2) included in Beta 4, setting Base SDK to 3.1. It was approved on the 15th. I've also done this during the 3.0 beta for 2.x apps.
EDIT: on the other hand, acceptance apparently isn't always guaranteed (note that this person had also submitted an app that did get accepted): The binary you uploaded was invalid. A pre-release beta version of the SDK was used to build the application

How to get iPhone SDK 2.2.1 for Xcode 3.2?

After my upgrade to Snow Leopard and Xcode 3.2 (which I really regret a lot!!), Xcode lost all the SDK's. I'm one of those old-fashioned idiots who still want to develop for 2.2.1. But Apple does not offer me an old SDK download.
Now I was clever and made tons of time machine backups. But: What's the preferred way to get iPhone SDK 2.2.1 running with Xcode 3.2? Some guys said that's generally possible. I do hope so because I still don't believe in all those "faked" stats, and besided that, my app doesn't benefit from 3.x additional features so I would not want to constrain my market just for that lazyness.
Any idea?
Regardless of whether or not you're targeting iPhone OS 3.0 or not using any 3.0 specific features, you should always compile your app against the latest SDKs to benefit from bug fixes and performance improvements.
You can compile against the 3.0 SDK and set the iPhone OS Deployment Target to 2.2.1 and still cater for users who are using 2.2.1.
You may find that some methods have been deprecated, but that doesn't stop you from using them until you're ready to move on.
Get the 3.1 final sdk, it has the 2.2.1 sdk in it. On disk its usual location is:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk
Also included is 3.0 and 3.1.
XCode 3.2 should have the prior iPhone SDKs available, just make sure you are setting your project's Base SDK setting to "iPhone OS 2.2.1". (Right-click on your top-level project icon in the Groups & Files browser in XCode and choose "Get Info", then go to the Build tab.)
Raffaello and others are correct: you can use the latest SDK and still target (and test on) older SDKs. For example, I'm using iOS4.0 (xcode 3.2.3) and testing on my iPhone 3g running 3.1.3.
To clarify the procedure:
- go to project info > build tab
- set Architectures:Base SDK (most likely) the latest
- set Deployment:iPhone OS Deployment Target to what ever you want (I have the option to go as far back as 2.0).
Hope this helps someone.
Like I said on other threads, the SDK and Deployment Target are different.
You can still use the latest SDK to build for an older OS.
Just go to your Target settings and under the Deployment section set the iPhone OS Deployment Target to whatever you'd like.
Cheers,
Raffaello Colasante

Choosing iPhone SDK in latest Xcode: Only 3.0 SDKs are available, but I have 2.0 on disk

After I downloaded the latest Xcode with the 3.1.2 SDK, I can't build and test for 2.2.1 anymore. I have the 2.2.1 SDK in the proper directory of my Developer folder.
Is there a setting I have to change?
Yes, to choose an older SDK in the Active SDK popup you have to set either the Base SDK or the Deployment Target build setting of your target to a value equal to or less than 2.2.1.
The Base SDK expresses your intention of what API your code is written for.
The Deployment Target expresses your intention of the earliest iPhone OS you want your app to run on.
The Active SDK is your build-time choice of SDK to use, usually Device vs. Simulator. But you will fail if you try to build against an SDK that is older than what your code is written for. If you code is indeed written to compile against older SDKs and/or run on older OS versions, you must express this by setting the appropriate build settings in the Target. Otherwise the Active SDK popup will limit you to what it knows will work with your code.
Where are you trying to select it? As the base SDK?
You should always be linking against the newest SDK version (this is what an Apple engineer told me directly at an iphone dev event) and then set your Deployment Target back as far as you want. You should be able to set you iPhone OS Deployment Target back to the older SDK version.
This is because Xcode uses weak linking so it will leave out things from the newer SDK on older versions, you do need to do some conditional checking for specific API's/functions using things like respondsToSelector if you are using functionality that has changed across versions.