XCode 11 Wiki

My personal notes on

  1. Getting Started with XCode
  2. What’s new in XCode 11
  3. Debugging in Xcode 11

sessions from WWDC 2019.

New Features

Minimap

Minimap
  • Like Jump Bar, you can add a marker to the minimap.// MARK: UISceneSession Lifecycle. Additionally, // MARK: - adds a separation line similar to Jump Bar. See this SO answer for Jump Bar visualization.
  • While hovering over Minimap, press and hold Command and XCode will show all the types, instances, and declarations.
  • When text searching, Minimap also highlights the words and darkens the rest of the map.

Editor Focus

Focus Button

When multiple source editors are open a button will appear on right of close button. You can click on the focus button to focus on a single editor making it take up the whole editor screen.

Documentation

Documentation
  • Holding Command click on any kind of declaration and click Add Documentation to create documentation.
  • Additionally, holding Command click on a variable name and then Edit All in Scope which will sync the edit to both the scope and the documentation.

Swift Package Manager

SwiftPM was introduced in WWDC 20181 but the integration at least to me seemed too cumbersome. Similar to SwiftUI, declarative syntax is preferred. C, C++, and Objective-C can be compiled in SwiftPM as well but, mixing languages with Swift in a target is not supported2.

Recall WWDC 2018

Commands

  • swift build to build your package.
  • swift run to run its executable products.
  • swift test to execute tests. Use --parallel flag to execute tests in parallel.
  • swift package for various non-build operations on the package. For example init to create a library package and init --type executable for an executable package.

Swift Packages consists of products, dependencies, and targets. Package.swift manifest file is used to configure these parts.
Package.swift

  • Dependencies: Packages you can integrate in Package.swift file.
  • Targets: Describe how to build set of source files into either a module or a test suite.
  • Products: Executables or libraries, assembled from one or more targets.

Demo

Creating an executable package;

mkdir MyPackage && cd MyPackage
swift package init --type executable

The directory structure will be as the following;

├── Package.swift
├── README.md
├── Sources
│   └── MyPackage
│       └── Hello.swift
└── Tests
    ├── HelloTests
    │   └── MyPackageTests.swift
	    └── XCTestManifests.swift
    └── LinuxMain.swift

Now you can compile and run the executable template with swift run.

SwiftPM Integration

This year we have fully integrated SwiftPM with XCode. You can use packages to build apps for all of the platforms.

This announcement was what I was looking for in WWDC 2019. The potential was there but it was hard to make use of SwiftPM because of the limitations before.

To add a package, navigate to the project editor and simply use Swift Packages tab.

Add Package Gif

References


  1. Getting to Know SwiftPM in WWDC 2018 ↩︎

  2. SwiftPM Documentation on GitHub ↩︎