I have a question regarding compiling against SDK's, which I thought I understood until yesterday.
I have an iPhone app, which the version compiled against SDK v3.2 and running on an iPhone emulator runnning version 4 works fine, but when I recompile the app against SDK 4 the interface starts to mess up.
I thought when you write an app against an SDK/Frameworks like iOS or the Android SDK's, the code you write gets compiles into an app (with any added libs), and then get excecuted on the system. The sdk being present on the dev machine for the purpose of the app being able to compile (and run compile time checks) but not actually compiled into the app code.
What I dont understand is that if this is the way it works, how can just compiling against a newer version of the SDK break the app (bearing in mind whatever version it is compiled against it is still running on iOS version 4) as how is it not still the same compiled app.
Obviously I am missing something here!
Thanks for any pointers
Any number of reasons; when you target a particular version of the OS, it can change the set of APIs that are available and it can change how the app is linked. At runtime, the system can do what are called "linked on or after" checks. If your app was linked with a target of an older OS, the newer OS might preserve some behavior or make sure a bug still exists. If targeted to the newest OS, you get the new behavior.
All of this is to say that you likely have some issue in your code where either you were relying on a bug in the 3.x versions or you are using an API whose behavior has changed between the two versions.
Related
I have written an app and its base SDK is set to 4.2, and at the moment it is in the app store with a deployment target set to 4.2, I'm sure you'll agree this is a bad idea because I am alienating all potential users who do not have the latest version of iOS installed.
So my question is, when deploying for an older version of iOS, how do I make sure it will run, i.e. how do I check whether I've used any modern API's that are not present in the deployment target iOS version?
The only sure-fire way to make sure your app will run is to test on a device running the older OS version you specify.
Even old versions of the iPhone Simulator (if you can find such) will not do a good job of checking for compatibility.
Most developers who want to support customers on iPhoneOS 3.x have access to an old test device, such as an used iPod Touch (hand-me-down, or purchased on eBay, etc.) running the OS version set in the app's Deployment Target. Otherwise, the developer is just guessing/gambling.
Check the documentation of the libraries or methods you are using. Test on the actually device installed with the version of the OS you wish to support.
Change the Base sdk version to 4.2, target sdk to 3.0 or any.
test the app in simulator as the target as simulator 3.0 r any.
But, when compared to 3.2 , 4.2 version has many new functionalities that do not work on 3.2 version devices.
So take respective steps to do for 3.2 r for 4.2.
The better idea is to find the version of the device , then give the accessibility based on the version.
Thanks,
Bharath
I just updated to iPhone SDK 4 and am trying to debug on my device with 3.1.3 installed. Before the update, I compiled with Base and Active SDK set to 3.1.3 and all was well. After the update, I'm limited to SDKs 4.0 and 3.2--setting the base to 4.0 and iPhone OS Deployment Target to iPhone OS 3.1.3, I'm able to build and install on my 3.1.3 device, but receive the following error:
Error from Debugger: mi_cmd_stack_list_frames: Not enough frames in stack
I'm not using anything specific to the newer SDK, as I haven't touched a bit of code, just updated the SDK/XCode. So what am I doing incorrectly? The application runs as expected on an iOS4-installed device. Are there changes to pre-existing API's that need to be weakly linked perhaps? Thanks for all help.
Have you tried removing the app completely from your dev device, doing a build -> clean all targets, and then build again to your device?
I found this answer on macforums. If it's correct, then you probably have a memory corruption problem in your app that is confusing the debugger. Perhaps over-releasing something somewhere.
This probably isn't related to the SDK you are compiling with. It's possible you had this problem in your app all along but it just didn't show up until things moved around with the new Xcode, SDK, etc.
EDIT - I just ran into this problem myself trying to update an older app of mine to 4.0. It would run fine in the simulator and would install and run on the device except it wouldn't run in the debugger on the device. Anyway, I finally decided it was the .xcodeproj file that was corrupt or bad in some way and created a new project, copied over my source files to the new project and now it all works again. It's a pain but it only took about 20 mins to duplicate all my settings and I spent a couple hours trying to get the debugger to work.
Myself (and probably many others) are concerned about "will I still be able to compile/install apps for v3.1.3 of the iPhone OS?"
And what version of xCode does it become IMPOSSIBLE to ever write v3.1.3 apps again?
(Without installing a second copy of an older version of xCode.)
I've read the mile-long document that Apple wrote on the subject... but it sure would be simpler to understand if they just LISTED the various versions of each... instead of writing long paragraphs.
If you have:
Mac OS version 10.x.x x
xCode version x.x.x
SDK version(s) x.x.x
you can produce apps for iPhone OS x.x.x through x.x.x?
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
I have been developing an iPhone app. and had the Base SDK set to "iPhone Device 3.0" and Deployment target set to "iPhone OS 3.0". Everything worked fine. I recently realised I actually needed to compile the project to run on devices using version 2.2.1 of the SDK, so I set the deployment target to "iPhone OS 2.2.1". Now when I hit compile I get 2079 errors all eventually pointing back to my header files saying "#endif without #if". My header files are surrounded by #ifndef/#endif clauses and I have checked every single one of them and all of these match up (since it compiles targeting 3.0 I'm assuming this isn't the problem anyway). I am using XCode 3.1.3. I have no idea what is going on and would appreciate any help with this. Thanks.
First thing to check is that you aren't using libraries that are only available in the 3.0 SDK. If you are using the MPMediaPlayer Framework, for example, you will probably get some compile warnings since those libraries don't exist prior to the 3.0 SDK.
My general advice for compile errors is to start with the first error and work your way one at a time. Generally, a single failure at the top will cascade and cause many more compile errors than actually exist in your code.
I found the answer, I had the target SDK set to the wrong version (2.2.1), when it should have been set to 3.0.
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.