Xcode 4 & Mac OSX 10.3? - cocoa

I'm new at programming on the Mac. I've got me a brand new copy of XCode 4.0. I've got people asking me what versions of MacOSX we'll be able to support but I'm not sure what to tell them.
I see options for selecting an "SDK" and other options for selecting a target version. It seems the lowest I can go is 10.4 though -- even though we'd like to support 10.3, if possible without a lot of pain.
My question is, could anyone give me a quick rundown of how sdk versions and target versions fit into this? As I'm coding, what kind of things do I need to watch out for to make sure I can still support the smallest version of MacOSX? Likewise, how do I figure the G4/G5 (PowerPC) versions of MacOSX into all this? For example, on Windows, if I write an app in c#, I know that all I need to do is make sure an appropriate version of .net framework is installed, regardless of the OS. Does something similar hold true for the MacOSX?
Thanks in advance.

I believe Apple has dropped PowerPC support completely, including Rosetta, in Mac OS X so 10.3 is out of the question.
If you want to support PowerPC, see this related question. It looks like a lot of work.
How can we restore ppc/ppc64 as well as full 10.4/10.5 SDK support to Xcode 4?
With the analogy to the .NET Framework, there isn't anything like that for Mac OS X built-in.

It is true for Mac OS X. If your program targets 10.3 SDK, it will be able to run on 10.3 or greater. I.e. the Base SDK project setting specifies minimum target OS version.
However, supporting 10.3 IS a lot of pain. Even 10.4 is not that easy, for example Objective-C 2.0 (most important, #property, garbage collection) is only available with 10.5 SDK or above.
The common solution in existing projects is to keep an old version of software available for 10.1-10.4 users, while the new versions will require 10.5 or greater (and also usually are Intel-only).
If you're starting a new project, you will probably want to distribute it via Mac AppStore, which only works on 10.6+, which means you can safely pick 10.6 SDK as the lowest target version.
Apple is way more harsh about upgrades than Microsoft. Mac users don't walk around with 10-years old systems on their laptops. The only reasons I can think of to still use 10.3 are using 10-year old mac, not having Internet connection and not knowing what “to update a software” means. So, I wouldn't care even about 10.4, not to say 10.3.

Related

Is There A Definitive Source for When Xcode Versions are No Longer Supported by Apple?

I'm writing up a slideshow on keeping Xcode versions up to date.
It's not difficult to find out when Xcode versions BEGIN support, but not when Apple officially ENDS support.
Maybe the correct answer is "when the next version comes out," but the Xcode version tends to continue working for quite some time after the next variant comes out, and I know some folks that insist on using the old variant until the wheels fall off.
Eventually, the old version will no longer work on the current OS, and we need to hold back the OS to continue running the Xcode variant.
I need to find that point. I call it "The eBay Threshold." That's when we can no longer run the defined variant of Xcode on a new Mac, and need to buy old used Macs to run it.
As you might guess, this is a point of frustration for me. I hates ISO9001, as practiced by some outfits...
Thanks!
As you note, Apple stops supporting a version when the next version comes out. "When will it stop working" cannot have a definitive source because there is no firm definition of "working" in the absence of regression testing, and Apple does not regression test old versions of Xcode against new OS X releases.
The requirements are of course contradictory (which I expect you know). It makes some sense to demand near-total reproducibility. In that case, you must never upgrade the OS beyond the point release that existed when the next version of Xcode came out. Upgrading the OS beyond that means running Xcode in an untested mode, using "well, it seems to run" as your only criteria. At the very least, you would need to regression test your own software.
Obviously VMs are the best way to achieve this for a build infrastructure. The VMs need to be very carefully protected from outside traffic since they cannot receive even security updates without breaking their reproducibility.
Of course few develop Mac software this way. (This answer only makes sense for Mac development, and even then assumes that you are not submitting to the App Store. MAS and iOS development must keep up with the latest version of Xcode by Apple policy.)

OSX Architecture related

I am developing an application for Mac 10.7 and above (10.7, 10.8, and 10.9 for now).
Based on my search on web -
OSX 10.8 and 10.9 only comes with 64bit flavour
OSX 10.7 supports both 32bit and 64bit Intel.
IN OSX 10.7 - If I develop for 64bit(x86_64) then application will work in 32bit as well.
https://discussions.apple.com/thread/3200553.
In this case, How ARC handled internally?
Can someone please validate and confirm my assumptions above?
Thanks
x86_64 is not emulated on 32 bit machines, so if you want your code to work on those, you'll have to build for it. The discussion you're linking to discusses kernel architecture, which is irrelevant for your purposes.
ARC does not work in 32 bit code, so if you want to support 32 bit machines, you cannot build with ARC (and yes, like many such tradeoffs, choosing to support the older alternative adds work and is potentially error prone).
Your best bet is to check the release notes. But if you try to compile for 32bit with a target SDK that doesn't support it Xcode will loudly tell you.
The last sold 32bit Macs were years ago. I'm but sure the hardware is even supported now.
You will benefit greatly from targeting 64bit only and the latest release possible. With the new strategy to make updates free, it keeps things simple.

Developing app for 10.8+ but using 10.9 SDK

Mavericks is coming out and for developers that's always a busy time with all these new features and APIs to know about and use. For me, I think it is the perfect time to ask a question that has been bugging me for a very long time.
Here's the thing, in context: I am developing an app that I want to be able to run on 10.8 (so the target system is 10.8+). Right now I am using the 10.8 SDK. However, with the release of 10.9 comes some pretty sweet APIs that I would like to use in my app. I use them in my code, but then, of course, I have to compile my app against the 10.9 SDK. If I do that, can I still run the app on 10.8?
Or, in a more general way, if I compile my app against one SDK, can I still run it on a 'lower' Mac OS? If yes, can you explain how does it work under the hood (what is the compiler doing)? This is a mistery for me.
Generally speaking, Xcode disassociates the issue of the SDK and the Deployment Target of the app.
The SDK is determined by Base SDK, and the deployment target is determined by OS X Deployment Target. These both show up in the Build Settings tab for each target in Xcode.
When programming with different SDK and Target, you are responsible for making sure that you don't call methods or functions on an OS that doesn't have them. This is often facilitated by weak linking (in the case of new frameworks) and/or using -respondsToSelector: in the case of new methods on existing classes and frameworks.
In Xcode, under build settings, there is an option for target OS where you can pick 10.8. 10.8 applications are generally compatible with 10.9 so the compiled application will work with both OSs.
Don't expect the new Apis to work when running on a lower version. It doesn't work that way.

Bundling a private JRE on Mac OS X

Starting with the next version of Mac OS X, Java will no longer be included in the system and I don't want to force my customers to install it themselves. So I would like to do what I do on Windows - bundle it with my app. It also gives me some hope that it could get included in the Mac App Store.
Where can I download a Mac OS X JRE that I could include with my application? Or can I just copy the one that's installed on my Mac?
Update (4/15/2013):
As Thorbjørn helpfully pointed out, Oracle now has a solution for this. See http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html. However, I'm keeping the original content for "historical purposes", and because it was a fun research project.
Previous version (with edits):
This is a great question. I was going to respond that you are simply ahead of your time -- as you pointed out, Java is not going to be removed until the Lion release. However, this article makes it clear that using Java today is not allowed:
Apps that use deprecated or optionally installed technologies (e.g., Java, [PowerPC code requiring] Rosetta) will be rejected.
At the same time, no one has announced a redistributable JRE for Mac OS X yet. I think your best bet, bearing in mind that you are forging new ground, is to check out the Mac OS X Port wiki page of the OpenJDK project. It does describe how to compile your own JDK, but it does not clearly state whether or not the resulting JDK can be "bundled" cleanly or not. I think you will have to try it and see :-(.
Also, it's not clear if the OpenJDK licensing allows this at all (IANAL). Hopefully someone else has already figured this out with regard to Linux/Windows, although of course the rules may be different for the Apple contributions.
Hope this helps. If nothing else, it's a starting point.
EDIT: I am going to throw out one additional suggestion. We now know that Mono apps can be packaged for the App Store. Furthermore, IKVM.NET is a complete implementation of Java that runs on top of Mono. You could try, in theory, to put these two pieces together and get a Java app, bundled for the App Store, that does not in fact require a JRE!
If you try this, I would love to hear how it works out :-).
EDIT 2: Unfortunately, the App Store and the GPL do not appear to be compatible (see http://www.zdnet.com/blog/open-source/no-gpl-apps-for-apples-app-store/8046). The OpenJDK license isn't exactly the same as the GPL, but it's pretty close (again, IANAL). Therefore, Mono & IKVM.NET may be your best bet. Good luck!
In the same web search that I found this question, I've found the these instructions from the OpenJDK project. Not having tried them myself, I cannot comment on how well they work.
Meanwhile, another, very detailled article was published by Marco Dinacci which also goes into signing and sandboxing.
Apple has joined the Sun/Oracle OpenJDK open source project last month, so Java on Apple is alive and kicking.
Just tell the user to download and install the OpenJDK JRE for Mac OSX (when it becomes available, right now it´s just source code).
And no. you cannot include "the folder that is in your mac" without permission as it is copyrighted code from Apple.
Finally, packaging a "private JRE" is a very bad practice, it will make your app bloated, andif the user ends up running several Java apps, he will end up running multiple Java VMs simultaneously which is a terrible waste of system resources.

Which version of OS X should my program target?

We're building an application for OS X, and we can't rely on our users all having upgraded to Snow Leopard, or whatever the latest version is. We want to make sure that as many people as possible can use our app, but we also don't want to throw away some improvements that were made in OS X version if only 1% of users are stuck using earlier versions.
Is there anywhere I can find information on the proportions of people that are using each version of the OS? Or is there some "common wisdom" on the issue that real mac developers know?
We don't need any superfancy graphics or 3d animation stuff, just plain old windowing APIs - but we've already run into one problem where "NSStreamDelegate" isn't supported prior to snow leopard.
Thanks!
Web stats from Quantcast, late February 2010.
North American stats, but might serve as a guideline.
Version %
10.6 27.3
10.5 52.1
10.4 17.2
Other 3.4
Omnigroup also provide some useful insight into updates to their installed base. You can click through to see breakdowns by major and minor versions on their site. For July 2010 they have:
Version %
10.6 53.3
10.5 21.0
10.4 25.6
Other 0.1
I think I'm one of the last holdouts with a still-functioning Powerbook G4. Its upgrade path ends with Tiger. On behalf of all those who won't get rid of computers that still work fine (if a bit slow by modern standards), please target 10.4 !
Of course by objective standards, you probably want to target 10.5. It adds nice programmability improvements, and really, I don't know a single person still using 10.4 other than me.
As for NSStreamDelegate, it has been available as an informal protocol (i.e. a category of NSObject) since 10.3. It is just that Apple decided to make it into a formal protocol, since Objective-C 2 has an #optional methods.
So, it's not that you're using new functionality only available on 10.6.

Resources