Mac OS X Lion required?


#1

Hello,

will there be any limitations when working through the book on Snow Leopard with Xcode 4.2?

Regards,
tajmahal


#2

I think you should be fine as long as you are on Xcode 4.2. (It has ARC for Snow Leopard.) Screenshots may look a little different from what you see. Please let me know if you have any troubles.


#3

Ok, I’ll let you know, but I don’t have the book yet. I already ordered it, but Amazon Germany lists availability as 1 to 2 months. I hope it doesn’t really take that long.


#4

According to Apple’s programming With ARC Release Notes:

"Can I develop applications for Mac OS X with ARC using Snow Leopard?

No. The Snow Leopard version of Xcode 4.2 doesn’t support ARC at all on Mac OS X, because it doesn’t
include the 10.7 SDK. Xcode 4.2 for Snow Leopard does support ARC for iOS though, and Xcode 4.2 for Lion supports both Mac OS X and iOS. This means you need a Lion system to build an ARC application that runs on Snow Leopard."

Sure enough, no option for Obj-C ARC under “Build Settings->Apple LLVM Compiler 3.0 - Language” for MAC OSX app. Whereas checkbox option for ARC is available for iOS Templates and also under Build Settings.

This is Xcode 4.2 on 10.6.8, snow leopard.

Chapter 19 worked okay after I moved the files into an iOS project. A little slower with the simulator starting up, but got me by.


#5

SBallmer, that’s interesting, as I thought ARC was purely a compiler thing. What is there that 10.6 would need to support in order to be able to run programs using ARC?

Does the book explain how to get by without ARC?

What’s more important: will the soon to be released 4th edition of the Cocoa book also work on 10.6, without ARC?


#6

The fourth edition of the Cocoa book assumes 10.7 and uses ARC throughout. It will be out in late November.


#7

tajmahal:

My understanding is that 10.6 can run code built with ARC, but it must be built on 10.7, as the compatibility code needed are provided with 10.7 SDK. Xcode 4.2 with 10.6 SDK doesn’t understand ARC at all. whereas iOS5 SDK are ARC aware built on either 10.6 and 10.7

Now that ARC is here, I believe all efforts are moving towards that, as that’s the future. Can’t expect any new books/training materials dwelling on the old mem mgmt for too long.


#8

For fun, try working through the book with OS X 10.5 and XCode 3.1.4 - I’m actually pretty surprised that Apple made changes to such basic objects - like NSDate. For example, the NSDate class method dateByAddingTImeInterval was only introduced in Snow Leopard? You can work around it by using addTimeInterval. The NSHost class function localizedName doesn’t seem to exist for pre-Snow Leopard either - you can use name and just pretend I guess.

I figured an intro programming book would deal with such basic functions that Apple couldn’t have possibly changed them since Leopard, but who knew? Apple apparently really is big into deprecating and removing functions?


#9

When one writes a book for programmers, one tends not to worry too much about people on older versions of the operating system. First, programmers tend to be running the latest and greatest. Second, in this book I’m working in a pretty small sandbox – there aren’t that many methods that are as beginner-friendly as dateByAddingTimeInterval: in the Foundation framework. Finally, Apple is innovating fast – my main concern is making sure the book is as future-proof as possible.

The case of dateByAddingTimeInterval: is actually prettying interesting. addTimeInterval: was around since the mid-90s, but at 10.6 they deprecated it to replace it with dateByAddingTimeInterval: which does the exact same thing. They just wanted to give it a name that was more descriptive. Apple (and NeXT before it) is not shy about deprecating things, which I think is a much better approach than being held captive by mistakes of the past.


#10

“my main concern is making sure the book is as future-proof as possible.”

And that certainly is the right focus. The book is definitely great - one of the better programming books I’ve read. It’s not your fault if Apple is a little aggressive about changing things - and hey, I guess they just want programmers on their platform not to slip into early Alzheimer’s by getting too comfortable or anything.

On the bright side I hunkered down and invested the ($29 x 2) for the upgrades and can report that Lion is definitely worth $58 more than Leopard, though Apple isn’t my main platform - though it’d be more tempting if they un-deprecated Java again.


#11

I have a problem here because I am running Snow Leopard but from what I understand, to complete the Objective-C book (and later the iOS book) I need Xcode 4.2 with Mac OS X Lion? The problem with this is I have some expensive software that reportedly isn’t compatible with Mac OS X Lion. So, is there a workaround here? Or do I HAVE to upgrade to Lion? Is there any way to run Xcode 4.2 on Snow Leopard?

I also must admit that I am new to the Mac…I bought a Macbook Pro just over a year ago (Christmas 2010) and already I need to purchase an OS upgrade, which is not compatible with software i just purchased in April 2011. Is this something common with Apple? Kind of frustrating in my opinion…and I thought my frustrations would be less with a Mac.

Thanks! Sorry for sounding like I’m complaining…it’s probably just something I don’t understand.


#12

It’s a mixed bag with Apple. They’re definitely not shy about cutting the cord on older technology, leading to compatibility issues, and particularly for development tools like Xcode they’re not at all concerned about users who can’t upgrade to the latest and greatest, since (interjecting my own thoughts) anyone who is making money from software development can presumably afford a Mac Mini for development purposes if they have to leave other machines behind on older system software.

On the other hand, they have a good track record with providing compatibility environments (fat binaries, Rosetta).

In this case, if there’s major software which is still not Lion-compatible nearly 9 months after release, that’s not really Apple’s fault. Developers had access to Lion for much longer than that.


#13

[quote=“macintux”]It’s a mixed bag with Apple. They’re definitely not shy about cutting the cord on older technology, leading to compatibility issues, and particularly for development tools like Xcode they’re not at all concerned about users who can’t upgrade to the latest and greatest, since (interjecting my own thoughts) anyone who is making money from software development can presumably afford a Mac Mini for development purposes if they have to leave other machines behind on older system software.

On the other hand, they have a good track record with providing compatibility environments (fat binaries, Rosetta).

In this case, if there’s major software which is still not Lion-compatible nearly 9 months after release, that’s not really Apple’s fault. Developers had access to Lion for much longer than that.[/quote]

Thanks for the reply. Regarding software compatibility with Lion, the software I’m talking about is Pro Tools, which does have a version compatible with Lion but of course you have to pay for the upgrade. So, it’s a Domino effect. If I want to use Xcode 4.2 I have to upgrade to Lion (which costs $$$), and if I upgrade to Lion my Pro Tools won’t work so I will have to buy the upgraded version (again more $$$). I’ve only had my Macbook pro for a little over a year…I’m just wondering if this will happen every year. Probably so.

But back to the main question…do I have to upgrade to Lion to get Xcode 4.2??? If I sign up for $99 a year Apple Developer program can I run Xcode 4.2 on Snow Leopard???

Thanks!


#14

Pretty sure you can download 4.2 for Snow Leopard from the developer site if you’re registered at all (no $99 required) but you can only use ARC for iOS projects, as I understand it.


#15

For us NOOBs who just want to get through chapter 19 while using ARC, but without upgrading to Lion. This worked for me.

Starting from chapter 17*, create an “iPhone application”. Do not use the Command Line Tool.
*note chapter 19 uses classes created in 17 and 18, therefore you should start from chapter 17. Also you will focus on sending NSLog statements to the console, you should ignore the simulator.

  1. Create an New Application > iOS Application > Empty Application. Check “Automatic Reference Counting” On.

  2. Name your Project (I named it BMITimer). Save it.

  3. Create a New File > iOS > CocoTouch> Objective-C …subclass from NSObject. I also named it BMITimer.

  4. In the BMITimer class, declare a -(void) Init; method (you can name it anything). This is just a hack…so I’m sure it’s not best practices.

@interface BMITimer : NSObject{
    
}
-(void)Init;
@end[/code]

5. In the implementation of BMITimer, Declare an @autoreleasepool{...} within the "Init". I think that is the ARC stuff we're learning about.. 
6.This class simulates your "main" entry that you would typically used in the Commad Line Tool. But you must add it to the AppDelegate before you can use it.
[code]@implementation BMITimer
-(void)Init{
    
    @autoreleasepool {
        //id person = [[Person alloc]init];
        
/* your project code here...
        Employee *person = [[Employee alloc]init];
        [person setWeightInKilos:96];
        [person setHeightInMeters:1.8];
        [person setEmployeeID:15];
                
        float bmi = [person bodyMassIndex];
        NSLog(@"\n\nEmployee %d has a BMI of %f\n\n",[person employeeID], bmi);
*/
        
            }
}
@end[/code]

3. In the AppDelegate.m import the BMItimer.h header, and add an instance of BMITimer [see relevant code]
 [code]#import "AppDelegate.h"
#import "BMITimer.h"
@implementation AppDelegate
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
    BMITimer *bmtTimer = [[BMITimer alloc]init];
    [bmtTimer Init];
    ...
    return YES;
}

Now you should be able to use the BMITimer.m as the main entry for you program. And discover how ARC makes memory management much easier.

FYI, I can not upgrade to Lion, yet.