Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction_to_Swift_for_iOS_.pdf

Jamf
November 13, 2019
12

 Introduction_to_Swift_for_iOS_.pdf

Jamf

November 13, 2019
Tweet

Transcript

  1. © JAMF Software, LLC Introduction to Swift for iOS Agenda:

    What are we going to do? What do we need to do it? Let’s code!
  2. © JAMF Software, LLC What are we going to do?

    Create single view app Use app configuration to pass data to the app
  3. © JAMF Software, LLC What do we need to do

    it? Xcode Apple Developer Account (paid) Jamf Server - to distribute the app iOS device - to test the app
  4. © JAMF Software, LLC Let’s code! Download starter project. -

    https://github.com/BIG-RAT/JNUC2019 Click userAssignStarter.zip
  5. © JAMF Software, LLC Let’s code! Unzip the download and

    Launch Xcode - Add developer account, if available Click the Download button.
  6. © JAMF Software, LLC Two ways to link the user

    interface to the code. Control, click and drag.
  7. © JAMF Software, LLC Provide a name for the object.

    And code to color the background. class ViewController: UIViewController { @IBOutlet var main_UIView: UIView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. main_UIView.backgroundColor = UIColor(red: 0x5C/255.0, green: 0x78/255.0, blue: 0x94/255.0, alpha: 1.0) } }
  8. © JAMF Software, LLC Things to remember when adding objects:

    ⇧+⌘+L - to bring up the object library (and select one item). ⌥+⇧+⌘+L - to bring up the object library (must be manually dismissed).
  9. © JAMF Software, LLC Inspectors useful when working with objects:

    Show/Hide Inspectors Attributes inspector Size inspector Connections inspector (what code is connected to the object)
  10. © JAMF Software, LLC Position constraints when working with objects.

    Alignment / centering Positioning / dimensions
  11. © JAMF Software, LLC Add content to the user interface.

    To add a label, click and drag from the objects library.
  12. © JAMF Software, LLC Position content on the user interface.

    Set top margin Fixed height / width Center horizontally
  13. © JAMF Software, LLC Add a Text Field and Button,

    adjust to taste. Suggestions: Text Field: Fixed top margin Variable Width - fixed right and left margins Centered Button: Constraints similar to the Label White Text Color
  14. © JAMF Software, LLC Add an action to the Submit

    button. Control click and drag
  15. © JAMF Software, LLC And the action (function). @IBAction func

    submit_Button(_ sender: Any) { name_TextField.text = "Hello JNUC 2019!" }
  16. © JAMF Software, LLC Take a breath… If need be,

    download the updated project: https://github.com/BIG-RAT/JNUC2019/blob/master/helloJNUC.zip Grab code to further update the project: https://github.com/BIG-RAT/JNUC2019/blob/master/ViewController.swift.zip
  17. © JAMF Software, LLC Note changes to submit_Button function: Defined

    xml needed to update the device record. Defined endpoint and credentials for the update. Added code for API operation. Note changes to viewDidLoad function: Check for and parse app configuration data if present. Provide test data when app configuration is not present.
  18. © JAMF Software, LLC We need an account on the

    Jamf Server with at least the following permissions:
  19. © JAMF Software, LLC Before uploading to the server, let’s

    get things set up with Apple. Log into the developer portal and click Certificates, IDs & Profiles
  20. © JAMF Software, LLC Build the app for distribution. Add

    developer account to the app for signing.
  21. © JAMF Software, LLC Set the target device to Generic

    iOS Device, click Product, then Archive.
  22. © JAMF Software, LLC Add the app to the Jamf

    Server. Use the jamfsoftware database for hosting. Click Upload App and select the ipa file from the recent Archive.
  23. © JAMF Software, LLC Scope the app as desired, then

    add the app configuration and deploy.
  24. © JAMF Software, LLC Download the final project and find

    what was added: https://github.com/BIG-RAT/JNUC2019/blob/master/deployed_final.zip
  25. © JAMF Software, LLC Resources - in no particular order

    HexColor - Mac App Store https://www.hackingwithswift.com https://www.raywenderlich.com https://stackoverflow.com
  26. © JAMF Software, LLC Thank you for listening! Give us

    feedback by completing the 2-question session survey in the JNUC 2019 app. UP NEXT Network Monitoring Smorgasbord 1:30 PM