Xcode and Swift CS 4720 – Mobile Application Development CS 4720
Why Java for Android? • Let’s first recap: why do you think Android uses Java? CS 4720 2
Why Java for Android? • Some good reasons: – You can’t find a CS major that doesn’t know Java – Java’s relatively easy to pick up – Code runs in a VM, which means you don’t have to recompile for every different phone platform – Tons of tools and support – Java manages pointers and garbage collection automatically, so less likely to get in trouble – Java ME already a thing for mobile CS 4720 3
History of Apple Development • To appreciate where iOS development came from, we need to look back at how developing for Apple platforms became what it is • And that story begins with Smalltalk CS 4720 4
Smalltalk • Created in the 1970s at Xerox PARC • Originally built for educational purposes • Smalltalk is basically THE ancestor for object- oriented development • Many of the OO patterns we know (like MVC) started with Smalltalk • Major influence in Agile, GUIs, and IDEs CS 4720 5
Smalltalk • Yes, at the heart of Smalltalk is objects (everything is an object) • But the real take away is messaging • Method calls are effectively messages with answers CS 4720 6
Smalltalk 42 factorial 2 raisedTo: 4 ‘hello world’ indexOf: $o startingAt: 6 Rectangle width: 100 height: 200 3 + 4 3 > 4 CS 4720 7
Objective-C • In the 1980s, work on Objective-C began at a telecom company, ITT • The thought was OO was the future (and Smalltalk was the blueprint) but backwards compatibility with C legacy systems was important • The main description of Objective-C was published in 1986 CS 4720 8
Objective-C • In 1988, NeXT licensed Objective-C and began work to extend the GCC compiler • NeXT built foundational tools for building good user interfaces • NeXT computers never really took off… • … but basically everyone thought the toolsets were really great • So, NeXT started focusing on software CS 4720 9
NeXTSTEP CS 4720 10
Objective-C • Oh, by the way… • NeXT was founded by Steve Jobs after he was forced out of Apple in the late 1980s… • NeXT was purchased in full by Apple in 1997 • Jobs took over as CEO of the combined company at the same time • Jobs canned several smaller projects (like the Newton) CS 4720 11
Objective-C • However, one major project had stalled out • The creation of the “next generation” Mac OS • With the purchase of NeXT… • … and the Unix underpinnings of NeXTSTEP… • … built using Objective-C… • Cocoa and OS X were born! CS 4720 12
Cocoa • Cocoa is the native OO API for OS X • Built using Objective-C • Cocoa apps were created using Project Builder and Interface Builder – Tools originally created for the NeXTSTEP system • Cocoa is important in that it “forces” applications to adhere to Apple UI guidelines • Project Builder + Interface Builder = Xcode CS 4720 13
Cocoa Touch • With the creation of iOS, came Cocoa Touch • Still Objective-C • Still MVC • Still Unix-based underneath it all • So, Objective-C became the default language for building for iOS • Until… CS 4720 14
Swift • Introduced at WWDC 2014 as “Objective-C without the C” • Meant to address memory and type safety issues present in Objective-C • Switches the message-passing syntax of Objective-C for the more common dot notation found in Java, etc. • Builds in many of the old standard Apple data types (like NSString ) CS 4720 15
Swift • The language itself looks much more “Java- like” with many keywords carried over • Semicolons not required though • In general, shouldn’t take too long for a Java programmer to pick up • Uses Objective-C runtime, so it can import any Objective-C libraries • Swift 2.0 released September 16, 2015 • Open sourced on December 3, 2015 CS 4720 16
Where does this leave us? • You don’t HAVE to develop iOS apps using Objective-C or Swift • However, that is the way to do native development (yes, you can KINDA do this with some third party tools…) • As of now, to build iOS apps using Objective-C or Swift, you need to use Xcode • To use Xcode, you need a Mac… CS 4720 17
Developing with Xcode • If you don’t own a Mac • Mac Minis in Rice 340 • Unix logins should work • Check to see if you can swipe in • Another option is http://www.macincloud.com/ CS 4720 18
Xcode and Swift • Things to cover: – Simulators vs. Emulators – How to hook up to Github – Using the Interface Builder to connect code to UI objects CS 4720 19
Recommend
More recommend