Please clarify for me what I need to use Swift

Discussion in 'Mac Programming' started by tillsbury, Jun 2, 2014.

  1. tillsbury macrumors 65816

    Joined:
    Dec 24, 2007
    #1
    Hi, new boy to Mac programming here (but not programming). I'm debating what language to play with alongside my son for him to learn programming. Swift looks like a great possibility, much less cluttered than Objective-C and will still let him create standalone programs that run on his Mac and his iPad.

    What exactly do I need to get in order to start playing with and learning Swift? A $99 developer licence for a year? Will that let me use it on both my and my son's macs? Or will we need two of these? Or is there any way we can play with it without paying this? Or if we wait a few months will it be available for free (i.e. is it only the beta that requires the developer fee?).

    I appreciate it's beta at the moment, but that's not a concern if it's going to end up more-or-less polished towards the end of the year.
     
  2. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #2
    I just did a quick test with my non-paid developer account. Got the following;

    Membership Required

    To access iOS 8 beta, you must be a member of the iOS Developer Program or the iOS Developer Enterprise Program.

    You can install a paid developer account on multiple computers. It's a bit of a hassle.

    You'll need to running at least OS X 10.9.3 or newer and Xcode 6 to use Swift.

    When Apple releases a new major OS X version they have released the new developer tools with it. I believe they currently have a vague release date for 10.10 of fall of this year.

    To place iOS apps onto iPhones and iPads, you must pay the $99 membership. This is not the same rule for compiling apps for OS X.

    To place apps in the store, you require a paid account.
     
  3. tillsbury thread starter macrumors 65816

    Joined:
    Dec 24, 2007
    #3
    Ok, I think I see. It's not iOS8 beta I'm looking for, just Swift on Mac.

    So, in October (or whenever Yosimite is released) I will be able to download Xcode and play Swift for free on multiple computers, and compile programs to run on Macs.

    I will need at least one $99 developer account to make a program run on an ipad -- I was aware of that one.

    The same $99 developer account could give me access to Swift before 10.10 is released. I need to work out whether that's worthwhile in this instance...
     
  4. Dekard macrumors 6502

    Dekard

    Joined:
    Sep 7, 2011
    Location:
    Dallas, Texas
    #4
    You'll need access to the beta of Xcode6 to work with Swift. Which currently you can only get with an active developer subscription.
     
  5. ArtOfWarfare macrumors G3

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #5
    Okay, so to start playing with Swift we need the beta of Xcode 6, and to get the beta of Xcode 6, we need to be a paying developer.

    Which programs qualify?

    iOS Enterprise?
    iOS Individual?
    OS X Enterprise?
    OS X Individual?

    Any others that I've forgotten about?
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    I've confirmed that the free developer account does not have access to Xcode 6.
     
  7. iSee macrumors 68040

    iSee

    Joined:
    Oct 25, 2004
    #7
    I have the iOS Individual and was able to download the Xcode 6 beta and play with Swift.
    I believe they mentioned that Swift was for Mac apps too so there OS X account must work too. Surely it's the same beta for Enterprise accounts, right?

    So I'd guess any would work.

    BTW the Playground would be great for learning programming
     
  8. Dekard macrumors 6502

    Dekard

    Joined:
    Sep 7, 2011
    Location:
    Dallas, Texas
    #8
    I have iOS Individual and was able to download it.
     
  9. Nermal Moderator

    Nermal

    Staff Member

    Joined:
    Dec 7, 2002
    Location:
    New Zealand
    #9
    As a Mac programming newbie myself (but a Windows dev for my day job), I should point out that although the actual Swift language documentation is available, I haven't seen any documentation on how to actually use Swift in an application (unless it's behind the paywall).

    For example, I haven't seen anything about how to hook a Swift method up to a button's performClick event. If that's available somewhere then let me know :)

    (Of course, having a copy of Xcode to play along with would help too, but one thing at a time :p)
     
  10. Blakeasd macrumors 6502a

    Joined:
    Dec 29, 2009
    #10
    I haven't seen it in any documentation either, but if you wanted to run code on the click of a button, it would look something like this:

    Code:
     @IBAction func clickButton(sender : NSButton) {
       
        //logic here
    }
    
     
  11. CylonGlitch macrumors 68030

    CylonGlitch

    Joined:
    Jul 7, 2009
    Location:
    SoCal
    #11
    FYI, XCode6 is available online if you look for it.
     
  12. Amazing Iceman macrumors 68040

    Amazing Iceman

    Joined:
    Nov 8, 2008
    Location:
    Florida, U.S.A.
    #12
    Yep, a good search query will find it for you.
     
  13. Nermal, Jun 4, 2014
    Last edited: Jun 5, 2014

    Nermal Moderator

    Nermal

    Staff Member

    Joined:
    Dec 7, 2002
    Location:
    New Zealand
    #13
    Thanks, after doing a bit more research it looks like that'll work (with clickButton being the name of the button, not a verb... that threw me at first!). It also appears that Xcode will create that method stub for you if you control-drag a button into the code window and select to make an Action. It's not as easy as double-clicking on the button in Visual Studio (I use C# at work), but it doesn't look like it'll be too hard.

    For anyone following along, a lot of the old Xcode tutorials use "setStringValue" to set the text of a textfield. That's apparently gone now, and you should use something like this:

    Code:
    labelName.stringValue = "Hello World"
    Once again, correct me if I'm wrong :)

    The good news is that the new syntax seems to be a lot closer to C# so it should be easier for me to pick it up. I tried Obj-C a couple of times and it did my head in.

    Edit: It looks like labelName.text works too; that's the same syntax used by C# so that's even easier for me :)
     
  14. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #14
    And in Obj-C it would be:

    Code:
    labelName.stringValue = @"Hello World";
    I count a huge 2 character difference there. :p
     
  15. Nermal Moderator

    Nermal

    Staff Member

    Joined:
    Dec 7, 2002
    Location:
    New Zealand
    #15
    Interesting; the examples I'd found online used something like [self.labelName setStringValue:"Hello World"]; so I wonder why none of the tutorials I found showed the other syntax.
     
  16. mrxak macrumors 68000

    Joined:
    Apr 16, 2004
    Location:
    Drifting through space in a broken escape pod
    #16
    I've heard that Xcode 6 beta is still really quite buggy. Personally I'm waiting for at least another version or two to pop up before I actually start writing any Swift code.

    In the meantime I'm still going to watch all the Swift videos Apple puts up on the dev site and read through the eBook, and think about what kind of projects I have written in other languages that I might want to try porting over as an exercise once Xcode 6 is more stable. I'm already mentally re-writing whole sections of code in my mind.
     
  17. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #17
    They are both valid syntax. The property-style syntax I showed is equivalent "syntactic sugar" for the more verbose version. You can do it either way.
     
  18. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #18
    What examples and online tutorials are you using? Can you provide us some URLs?
     
  19. whooleytoo macrumors 604

    whooleytoo

    Joined:
    Aug 2, 2002
    Location:
    Cork, Ireland.
    #19
    As stated above, properties were a 'new' feature that was added to Objective-C, as a convenience. You could do myObject.myProperty = 123, and still have the benefit of a setter method being called, without having to write a setter (or getter) method.

    Swift just takes that a step further. I like too, the didSet and willSet methods in Swift, handy feature.
     
  20. Nermal Moderator

    Nermal

    Staff Member

    Joined:
    Dec 7, 2002
    Location:
    New Zealand
    #20
    I can't find the stuff in my history; I'm not sure which computer I was on. They weren't on apple.com though so it wouldn't surprise me if I picked up some outdated syntax.
     
  21. ArtOfWarfare macrumors G3

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #21
    I find it kind of hard to find pre-Obj-C 2.0 material... it's been around almost since the start of iOS development, and very few people cared about Obj-C at all prior to iOS.
     
  22. jtara macrumors 65816

    Joined:
    Mar 23, 2009
    #22
    There is a separate, $99/year Mac Developer Program. This will get you the beta Xcode with Swift as well.

    https://developer.apple.com/programs/mac/

    The only free developer program I know of is the Safari Developer Program - you just have to sign-up. (It gives you access to forums where nobody ever answers a question...)
     
  23. hpe macrumors member

    Joined:
    Aug 9, 2013
    Location:
    Switzerland
    #23
    I you want to learn

    http://www.youtube.com/user/AppleProgramming
    is the best place to start in my opinion. On top of that Lucas Derraugh is a great kid. http://appleprog.com/

    All the developer programs you referred to will get you the Beta now. If you wait until it is out of beta you can use it on any number of Macs.

    If you want to put your results on a physical iPhone or iPad, you need one of the IOS programs (any of them will do). 99$ for any number of Macs (your macs that is) and the added benefit that you can sell the result on the AppStore.

    You can program and build apps for both OS X and IOS without paying. But if you pay the fee you get access to Beta software (dev tools ans OS:s) and the resell channel that is the App Store. Also, if you take the free route, your IOS apps stay in the simulator. If you want to put them on your device, you need a developer subscription.

    The only difference between "Enterprise" and "Individual" is the legal structure of who is the reseller on the App Store. Unless you need to to some tax-planning (if you are lucky enough to sell enough to justify such things), just go with an individual account.

    Early on, the individual program was a bit more restricted to how many test units you could use and if a corporate needs to produce apps for them only, they need the enterprise too.


    Good luck
     
  24. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #24
    Incorrect. You're thinking of "Company" vs. "Individual". The Enterprise Program is a whole different animal with no access to the App Store, a higher fee, etc.
     
  25. hpe macrumors member

    Joined:
    Aug 9, 2013
    Location:
    Switzerland
    #25
    I stand corrected, I had them confused. The thread starter can still ignore the "Enterprise" versions...

    /hpe
     

Share This Page