How to make my iPhone app compatible with iOS 4? - iphone

My iphoneos 3.1 based application is not working on iOS 4 GM: the camera is not showing in full screen, it doesn't correctly detects compass information, the uiwebviews doesn't respond to touches (they don't scroll), and so on. It's completely broken! Now my question is: how can I develop an update using the latest xcode with support for ios 4? The latest iOS 4 xcode (3.2.3) doesn't provide any way to develop for iPhoneOS 3.x ("base sdk missing"). By the other side, xcode 3.2.2 would not allow me to debug it on a iOS 4 device, so I can't test it.

In Xcode, you can use a later base SDK while targeting an earlier version.
Go into your project settings and set iPhone OS Deployment Target to an earlier version, such as "iPhone OS 3.1".

I would create a second disk partition and install the 4.0 version of xcode on that. Keep the 3.2 version on your primary drive.
Its probably not necessary to create a second disk partition but it was simple to do.

Install the 4.0 sdk under a different folder and then re-install the 3.2 sdk and develop in that.

Related

Can I use Xcode 3.1 to develop app for iOS version 4.0, 4.3 and 5

I want to develop an iphone app, I only have OSX 10.5 so I can only install xcode 3.1, can I developer App for iOS version 4.0, 4.3, and 5 respectively? Or I must upgrade to OSX 10.7 Lion and install xcode 4.2?
More specifically, if I use xcode 3.1 and develop an app, will it runs on iphone 4 and 4S?
As far as I know you will not be able to develop for those iOS versions with XCode 3.1, looks like you will need to upgrade unfortunately.
You'll need to upgrade, at least to Snow Leopard (10.6) to be able to develop for iOS 5, as 10.5 is not longer supported
edit:
short answer yes, it will most likely be able to run, but you missed out on so many features added in iOS 4++, also, it's likely you won't be able to test your app on iPhone 4/4S, not sure about iPhone 4, but 4S surely won't get recognized by your XCode
if you make an app for iOS 4.0 it should work with iOS 4.3 and iOS5. But for Xcode 4.2 you don't need Lion, Snow Leopard is enough(I've heard that Lion isn't that good compared to Snow Leopard).
You cannot use Xcode 3.1 to develop apps the use SDK APIs or features new to iOS 4.3 or 5.x, or to debug apps running on devices with those later OS versions.
You can use Xcode 3.1 to develop apps that will run on devices with iOS 4.3 or 5.x by using Ad Hoc deployment and installing the apps via iTunes.
You can develop for newer ios on older XCodes. And, its a matter of managing PATHS nd VERSIONS
STEP 1.
What is known as XCode is more accurately a bundle of a IDE with a SDK. Nevertheless, the two are separate. I have 3.2 and 4.0 xcodes on the same machine. no hitch at all. I used the older 3.2 IDE until the 4.0 IDE became a bit more familiar.
One way is to organize your directory structure around the following schema.
/Developer_3.x.x
/Developer_4.x.x
Another method is to use only one /Developer and copy the SDK and platforms from one into another.
/Developer/SDKs
/Developer/Platforms
*The reason that is easy: those are the expected search PATHS
The cleaner and slightly more difficult route is setting the Project build settings under
Project | Build | Architecture
The two settings are the two top-most ones.
"Additional SDKs" sets the ADDITIONAL_SDK variable.
"Base SDK" sets the SDKROOT variable.
See "Cross-develop using target sdk"
And "Cross-Development Programming Guide"
As pointed out, a caveat is optimizing, mem-leaking and so forth.
STEP 2. (Pain in the *ss)
Then, you will have to start peppering your code with precompiler if statements.
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
if ( [[[ UIDevice currentDevice] systemVersiuon] floatValue] > = 4.0 ) {
...something available in 4.0
}
#endif
This precompiler braches should be in there to support multiple devices, no matter the XCode case.

How can I build an application for iPhone OS 3.1.2 using the current Xcode?

I have an iPhone running the 3.1.2 firmware and would like to build applications for it. However, I can't find Xcode 3.2.1 with the iPhone OS 3.1.2 SDK at Apple's developer site.
How can I build an application using the current SDK and Xcode versions that will run on this older OS version?
Use the current tools and SDK. Set the "Base SDK" build setting to "Latest iOS" and set the "iOS Deployment Target" to whatever version you want to target, such as iOS 3.1.2.
The only gotcha here is that the compiler won't warn you if you use something from the SDK that was introduced after iOS 3.1.2, and if you do your app will likely crash. So, you'll want to check the docs for each method you use that you don't already know for certain is available in 3.1.2, and you should test your app thoroughly.
Unless there is some unmentioned reason you need the older version, you can use the latest Xcode and just target the build for the old iOS.
If you are a member of the Apple Developer Program (which you need to be in order to download any version of the Xcode and iOS SDK), you can download Xcode 3.2.6 w/ iOS SDK from the main 4.3 from the iOS Dev Center home page. Under the section for Xcode 4, there's a small line saying "Looking for Xcode 3? Download", which takes you to this download page.
Of course, that still requires you to develop using the 4.3 SDK, so you have to be carefull when targeting 3.1.2 devices.
You can purchase Xcode using the Mac-App-Store or by subscribing to the iPhone Developer Program ($99 per year).
Get the latest one (XCode with iOS SDK 4.3) and select 3.1.2 for the deployment iOS Version (under build-settings).

Base-SDK of v4.0 means it won't install on 4.1 or 4.2 devices?

I was using xCode v3.2.3 and SDK 4.0 to write iPhone apps that worked on my iOS v3.1.3 device... as well as v4.0. (Deployment target set to 3.1.3. Base SDK set to v4.0)
Does that mean everyone that uses my app will need a minimum of iOS 3.1.3 and a maximum of v4.0? Or will they also run on v4.1 and v4.2?
Second part of my question:
I now upgrade my iOS v3.1.3 to v4.2.1.
Xcode now says my v4.2.1 device is now no longer provisioned.
Doesn't a Base-SDK setting of v4.0 mean apps will also run (or at least install) on v4.x?
No. Base SDK just means that your app will be built against the iOS 4.0 libraries. Any 4.x device will be able to run a release build of your app, but for debugging, Base SDK and the iOS version on your device must match. In the end, you need to build your app with the newest available Base SDK anyway, because Apple won't accept apps built for older SDKs into the App Store.
No, they will. iOS has Backward compatibility.
I agree with Irene. I found the solution:
The hint came from here: Can't make Xcode 4 run a barely empty project using SDK 4.2 (runs fine in 4.3)
And this is how i resolve: my xcode 4.0 my SDK 4.3 and my Ipod touch device is 4.2.1 - You see it is backward compatible. There are 2 things you must do in order to resolve. 1) In your xcode 4.0, You click on your project name under Target to ensure you change the target not the Project setting. Find the row >IOS deployment target to the version of your device in my case it was back to 4.2.1 ipodtouch so i set 4.2 (do not worry about basesdk it is for your application not the same as your application's target. 4.3 basesdk requires you provide codesign so you have to select code sign if do not have one apply for one looking up in Apple website or google)
After setting your target to compatible version with your device you now can go to "set the active scheme" that is where you select which device to install and run on including the simulator. So you will find you device there select it and you are good to go.
And if you still can not get it going. You can try to select your project under Project this time adn set the ios deployment target to your version mine was 4.2 ipodtouch ios. Then go select "set the active scheme" that is where you select which device to install and run on including the simulator. So you will find you device there select it and you are good to go.

Upgrading iOS SDK

I've XCode 3.2.3 with iOS SDK 4 installed in my iMac. I bought an iPhone 4 with OS version 4.0.2 and I would like to use that device for development. However the Organizer shows the message below when the device is connected.
The version of iPhone OS on “iPhone 4G” does not match any of the versions of iPhone OS supported for development with this installation of the iPhone SDK. Please restore the device to a version of the OS listed below, or update to the latest version of the iPhone SDK.
Currently my XCode supports Base SDK from 3.0 to 4.0.1.
So if I download the latest XCode 3.2.4 with iOS SDk 4.1, will I still have Base SDK support from 3.0 ?
Cheers
Jugs
No, XCode 3.2.4 does not come with SDK 3.0, it comes with SDK 3.2 and 4.1. But you don't need the 3.0 SDK to write apps that will run on 3.0.
There are two versions that are important to you as an iOS developer, and you need to understand them: first, there's SDK version that you link to, this is the Base SDK. It should normally be set to the newest SDK available.
And then, there's the Deployment Target. That is the earliest version your app needs to run on. This is the one you are actually caring about, this one ensures that your app will still run on earlier iOS devices.
To set that, go to "Project -> Edit Active Target". In the dialog, select the "Build" tab, make sure "Show" is set to "All Settings" and the type "deploy" in the search field. Scroll down to the "Deployment" section, the last entry should be "iOS Deployment Target". You need to set this to "iOS 3.0" or whatever suits you. You should now get warnings if you use methods or classes that are not available on 3.0.

Simulate iPhone 3.0 with SDK 4.0

i have xcode 3.1.3 and xcode 3.2.1 installed
For sure now I use 3.2.1 with Sdk 4 to develop new apps.
But what if I like to test a App compiled with sdk 4 on a
simulated iphone that would just have 3.0??
As BaseSDk i use 4.0 and as target 3.0
In xcode 3.1.3 i could select a simulator down to 2.x but with sdk 4.0
i only have the option 4.0 iphone or 3.2 ipad
Example> i know iAd is not supported before 4.0 so I set the
framework to weak. But just to be sure all works fine I really
would like to test my app in a simulator that simulates an iphone with 3.0
thx
chris
The new simulator does not seem to be able to run the old simulator OSs (3.2 being the oldest it'll run). I tried moving them over from old SDK installs and several variations and "no go".
You can check that you aren't using methods defined in the new SDK, when you set the base SDK to 4.0 but set the Deployment to to 3.1.3, for example. For a blog post on how to do this see this blog post, and note my comment on an easier way to do the last two steps (no need to edit the project file as a text file).
inside the iphone sdk dmg file, there should be a folder called packages. in it, you'll find packages like iPhoneSDK3_0 and iPhoneSimulator3_0. Install them to be able to use them in xcode.
Correct me if I'm wrong, but I think a device with 3.0 installed can't even run apps compiled with 3.2 or 4.0. Furthermore, Apple now only accepts iPhone apps (including updates of existing apps) linked against the 4.0 libraries, which won't run on OS version 3.0 devices.
So why do you want to test your app on a 3.0 device?
Try setting the architecture you want to build for in the Xcode project preferences and rebuilding.
If this doesn't work, completely uninstall Xcode and downgrade. You have to completely uninstall because your system must have updated the frameworks for 4.0.
Hope this helps