Sei sulla pagina 1di 61

Xcode 9 beta 2 Release Notes

Developer
Xcode 9 beta 2 Relea
About Xcode 9 beta 2
Supported Configurations

Xcode 9 beta 2 requires a Mac running macOS 10.12.4 or later.

Xcode 9 beta 2 includes SDKs for iOS 11, watchOS 4, macOS 10.13, and tvOS 11.

Installation

Xcode 9 beta 2 can coexist with previous versions of Xcode.

Prerelease versions of Xcode are made available from developer.apple.com, packaged in a


compressed XIP file. To install Xcode during the beta period, download the XIP file, double-click the
file to expand it in place, then drag Xcode-beta.app to the Applications folder.

Upon final release, Xcode is installed via the Mac App Store.

Accessing Additional Developer Tools

To launch additional developer tools, such as Instruments and FileMerge, launch Xcode-beta and
select Xcode > Open Developer Tool. You can keep these additional tools in your Dock for direct
access when Xcode isnt running.

Technical Support and Learning Resources

Apple provides the following web resources to support your development with Xcode:

Apple Developer Forums. Participate in discussions about developing for Apple platforms and
using developer tools.
Bug Reporter. Report issues, enhancement requests, and feedback to Apple. Provide detailed
information, including the system and developer tools version information, and any relevant
crash logs or console messages.
Apple Developer website. Get the latest development information as well as technical
documentation for Xcode.
Xcode homepage. Get high-level information about the latest release of Xcode. Download
current and beta Xcode releases.
For help with using Xcode, use the built-in help by choosing Help > Xcode Help.

Copyright 2017 Apple Inc. All rights reserved. Page 2 of 61


Xcode 9 beta 2 Relea
Deprecations and Removal Notices

iOS 11 no longer supports armv7 or armv7s (32-bit). If an iOS target has an iOS Deployment
Target of 11, then it will not build for 32-bit. iOS targets with an iOS Deployment Target earlier
than 11 will still build for 32-bit by default. (32163517)

Xcode Server no longer includes the capacity to host Git repositories. To continue using
repositories that were set up in macOS Server, configure a new remote and push your code to
that remote. After upgrading to Xcode 9, any existing repositories will be archived in
/Library/Developer/XcodeServer/HostedRepositories. (31243129)

Copyright 2017 Apple Inc. All rights reserved. Page 3 of 61


Xcode 9 beta 2 Relea
New in Xcode 9 beta 2 IDE
Signing and Distribution

Core NFC can now be enabled via the Capabilities tab in Xcode. (32520707)

Simulator

Simulator now supports redirecting most keyboard shortcuts to a simulated device. Choose
Hardware > Keyboard > Send Menu Keyboard Shortcuts to Device to turn on and off sending
keyboard shortcuts to the device. A checkmark indicates that keyboard shortcuts are being
redirected to the frontmost simulated device. Each device can have a different setting for this
option. In addition, Simulator menus dont display shortcuts while shortcuts are redirected.

Simulated devices now distinguish between the left and right modifier keys such as Shift,
Command, Control, and Option.

System-level shortcuts such as Command-Option-D are not redirected.

Note: Pressing both the Left-Command and the Right-Command keys also turns off sending
keyboard shortcuts to a device. (31990219)

The iOS 11, tvOS 11, and watchOS 4, Simulator runtimes now treat the filesystem as case
sensitive to better simulate physical device behavior. (18609452)

Launching Simulator checks if an older version of Simulator is already running. If so, the older
version of Simulator hands off any running simulated devices to the newer version and then
quits. This functionality works only in Xcode 9.0 beta 2 and later.

Note: The version of Simulator in Xcode 9.0 beta 1 does hand off running devices but does not quit
and may result in two windows for the the same simulated device. Closing the window for a device in
either of the running versions of Simulator shuts the simulated device down resulting in it
disappearing in both running Simulator applications. (32384840)

Workaround: Quit the older version of Simulator without shutting down the running simulated
devices by pressing Command-Control-Q in Simulator, and then selecting Keep Running in the
dialog that appears.

Copyright 2017 Apple Inc. All rights reserved. Page 4 of 61


Xcode 9 beta 2 Relea
Resolved in Xcode 9 beta 2 IDE
General

On macOS 10.13 beta, Instruments Help and Simulator Help show a help window with help
content for those applications. (31977479)

Source Editor

An Xcode Source Editor Extension that attempts to remove elements from the
XCSourceTextBuffer.lines property will see those lines removed in Xcode. (32392945)

Playgrounds

On Retina displays, the live view of iOS and tvOS playgrounds will display the entire view and
not appear distorted. (32382262)

Testing

Testing works with wirelessly paired devices. (32409406)

The UI testing API, typeText(), when used with an XCUIApplication element, works on iOS
10.3 and older. (32380712)

Swift Migration

Migrating with the Minimize Inference option and then later changing the Swift 3 @objc
inference build setting to Default, does not cause compiler to produce errors about @objc
inference. (32431838)

The Swift 4 migrator does not return an error when a closure is using an implicit return and the
migration process adds additional statements to the end of the closure. (32433206)

After Swift 4 migration, calls to Array.append(contentsOf:) do not lose the contentsOf:


label if the parameter is a nested call to a Standard Library function that accepts a closure with
mismatched argument types (passing multiple arguments but the function is expecting a single
tuple argument). (32477119)

Copyright 2017 Apple Inc. All rights reserved. Page 5 of 61


Xcode 9 beta 2 Relea
Build System

In the new build system, targets which produce static libraries now correctly process the Link
Binary With Libraries build phase so that static libraries can embed other static libraries.
(32288202, 32676857)

The new build system now properly handles targets with files having the same basename which
differed only by its capitalization. (32576539)

The new build system no longer crashes when running some unit tests against a simulator run
destination. (32576837)

Xcode no longer crashes when using the new build system with Analyze While Building and
the build fails. (32641295)

The new build system now passes recursive search paths to the linker correctly. (32720104)

Core Data

The Xcode data model editor supports creating fetch indexes from attributes, expressions, and
relationships. (32407895)

Localization

The System Language and System Region entries in the scheme Application Language and
Application Region pop-up menus now work reliably. (32560300)

Copyright 2017 Apple Inc. All rights reserved. Page 6 of 61


Xcode 9 beta 2 Relea
Refactoring

References to declarations in the default values for template parameters are renamed.
(32323724)

Renaming explicit (i.e. declared using @property(class)) class properties rename their uses
and can be initiated at the point of use. (32376363)

References to declarations that are in a default argument value in a function definition are
renamed when that declaration is renamed. (32323315)

Renaming namespace declarations will rename their uses in using namespace declarations
that are in a function. (32323190)

Renaming local declarations, such as those declared in a function, rename their uses in macro
arguments. (32165031)

When extracting an expression or statement into a function, references to super are captured
by the extracted function. (32294638)

Renames of typenames declared using NS_ENUM and similar macros succeed when initiated at
the point of reference to the typedef. (32310204)

The Rename function can be initiated from within a macro argument. (32236691)

Renaming Objective-C classes rename references to them in class property expressions.


(32248847)

When extracting a standalone property expression into a function or method, the extracted
function or method captures variables used in that expression. (32210657)

Deleted (= delete) functions, constructors and destructors and references to declarations that
are specified in their type signature are renamed. (32323386)

Renaming the struct, class, union, typealias (using <name> = <type>), typedef, enum, or
enumerator declarations that are declared in a class template will rename their uses whose
qualifier includes an implicit template instantiations. (32325459)

The Extract Function and Extract Method refactoring operations can be initiated from within
a macro argument. (32379522)

Signing and Distribution

When you build and run and encounter a provisioning issue, Xcode wont prompt you to register
a device, revoke a certificate, or download a provisioning profile if these repairs are necessary.
(32366863)

Copyright 2017 Apple Inc. All rights reserved. Page 7 of 61


Xcode 9 beta 2 Relea
Server

Xcode Server will not report integrations as being successful if they fail to generate the archive.
(31957210)

Simulator

Simulator.app menu keyboard shortcuts no longer get delivered to the device. (32094433)

Accessibility elements in Simulator runtimes are not flipped vertically. (31948245)

Simulator.app properly saves the location of windows between launches. (32303682)

Clicking buttons in the Apple TV Remote in Simulator will not cause the window to move
upward. (32314303)

Booting simulators in Virtual Machines with less than 4G of memory will not result in an error
dialog box. (31871122)

Simulator will not fail in OpenCL when running on pre2013 Mac hardware or Virtual Machines.
(32293108)

log collect can be executed in Simulator as a standard user. (32531154)

UI Testing works in tvOS 11.0. (32371700)

App launch will not time out in simulated watchOS 4.0 devices. (32314337)

The launchctl command is available in Simulator. (32445544)

/usr/bin/defaults is available in Simulator. (32628360)

Activating Siri in a simulated tvOS device will not cause the device to restart. (32284246)

Documentation Viewer

Downloading sample code in the documentation viewer once again works in Xcode 9 beta.
(32538902)

Copyright 2017 Apple Inc. All rights reserved. Page 8 of 61


Xcode 9 beta 2 Relea
Known Issues in Xcode 9 beta 2 IDE
General

Deleting a project file from your disk while that project is open in Xcode will cause a crash.
(31849539)

Application installation can fail with Failed to acquire termination assertion when installing
placeholder for BUNDLE-IDENTIFIER (32339359)

Workaround: Exit the application and try again. This should only occur if the app is being
installed while it is active.

Accounts using a phone number as the Apple ID cannot sign in to Xcode. (32917618)

Source Editor

The source editor in this beta version of Xcode 9.0 doesnt support yank.. (30083567)

When recording UI tests in the Xcode source editor, tokens may not correctly resolve to source
code that can compile. (29391589)

Xcode 9s new source editor does not yet support code folding. (29396003)

Xcode 9s new source editor does not yet support discontiguous or columnar selection.
(30738532)

Xcode 9s new source editor does not yet support printing. (30852651)

Xcode 9s new source editor does not yet support displaying and navigating to issue notes.
(31491175)

Xcode 9s new source editor does not yet render invisible characters. (7612691)

Scroll position is not preserved in the Source Editor when switching to or from the Version Editor
modes (Comparison, Blame, or Log). (30400751)

Editing a multi-line string in Swift may cause lines within the string and later in the file to lose
syntax coloring until the string is valid and the affected lines are modified. (32148117)

Copyright 2017 Apple Inc. All rights reserved. Page 9 of 61


Xcode 9 beta 2 Relea
Interface Builder

Using a Swift image literal within prepareForInterfaceBuilder() causes the


IBDesignablesAgentCocoaTouch to crash, because live views are compiled in a different
bundle. (28676479)

Workaround: Use UIImage(named:inBundle:compatibleWithTraitCollection:) for all


image lookups, and specify the bundle for the calling class.

Simulated Metrics overrides other than Freeform size have no effect on the canvas. (28806592)

Opening a tvOS storyboard can have a severe impact on system performance due to excessive
memory use by the IBAppleTVTool. (32542011)

Workaround: Open a terminal and run the command: defaults write com.apple.dt.Xcode
IBLaunchPlatformToolsWithLimitedLaunchdJobs -bool NO, and then relaunch Xcode.

In tvOS Interface Builder documents, the canvas always renders in light mode, even when
switching to dark mode. (32543311)

The default autolayout margins for tvOS are incorrect. (32393914)

Asset Catalog

Jpeg assets in asset catalogs are not found on iOS 10 or earlier for apps built with Xcode 9. API
calls for accessing the image such as UIImage.imageNamed: return nil. (32524123)

Workaround: Use png resources or limit app testing to devices running iOS 11 or later.

Debugging

You may see two entries for the same Apple TV devices in the Run Destinations list or the
Devices window. (32118508)

Workaround: On the Apple TV, press the Menu button to leave the Remote App and Devices
settings screen.

You may experience connection issues with wireless development immediately after detaching
your device from USB. (31966846)

Workaround: Enable airplane mode on your device for 10 seconds and then disable airplane
mode to re-establish your connection.

Entering the wrong pin in the Devices Window when wirelessly pairing Apple TV will continue to
request a new pin. (32408330)

Workaround: Click on the pin code and press the delete key.

Copyright 2017 Apple Inc. All rights reserved. Page 10 of 61


Xcode 9 beta 2 Relea
Symbols may not be downloaded from devices paired over the network. (31304833)

Workaround: Before enabling wireless development, plug in the device and wait for it to finish
preparing debugger support.

The value of members of an NSMutableSet arent shown when the variable is turned down in
the Xcode Variables View, as they are for an NSSet. This occurs when debugging on macOS
10.13, iOS 11, tvOS 11, and watchOS 4. (32307219)

Workaround: Control-click the variable in the Variables View to and choose Print Description
of to print the NSMutableSet in the Xcode Debug Console, or use the po command at the
debugger prompt.

No standard out content is printed to Xcodes console for a process whose launch was waited
for prior to being attached by the debugger. (10275573)

Debugged processes may hang on launch if the Use Terminal console option is used.
(31707955)

Workaround: Select Use Xcode in the scheme options.

Watch development may not work when using wireless development. (32341381)

Workaround: Attach the paired iPhone via USB.

The first time you run a Complication from Xcode in Simulator it may continually exit the first
time you configure that Complication. (29858029)

Workaround: Re-run the scheme in Xcode.

Sometimes when debugging a Messages Extension on a device, Messages doesnt


automatically start a new conversation and start using the extension. (31096267)

Workaround: Manually start a new conversation and select the extension.

After building and running a Watch app from Xcode your app might not install, launch, and
attach. (32180669)

Workaround: Reboot Apple Watch and iPhone, then reconnect your iPhone to your Mac to
show the trust dialog on Apple Watch. It may take a few minutes for the trust dialog to appear
after rebooting the device and connecting it to the Mac.

If a project uses any frameworks that have code written in Go, it will not be possible to run or
debug the app. (31451900)

Workaround: Use Xcode 8.2 or remove the dependency on such frameworks.

Copyright 2017 Apple Inc. All rights reserved. Page 11 of 61


Xcode 9 beta 2 Relea
When debugging processes that use Swift, the Xcode Memory Debugger, the Leaks
instruments, and leaks command may report incorrect (false-positive) leaks of small malloc
blocks, and may confuse strong versus weak references. (29780048)

GPU performance counters are disabled on Nvidia GPUs. (32497239)

In the GPU Frame Debugger, Frame captures using nested argument buffers (such as argument
buffers encoded to another argument buffer) are not supported. (31245702)

In the GPU Debugger, Argument buffers dont have the correct formatting in the buffer viewer.
(31254766)

In the GPU Frame Debugger, the filters will always filter for ANY when there multiple filter terms,
regardless of what is selected. (32455262)

In the GPU Frame Debugger, Argument encoders created before the start of a frame capture will
crash the app while capturing. (32415645)

Workaround: Create argument encoders within the captured workload or release them before
capturing.

Changes to a breakpoints options (conditions, ignore count) will not have any effect if they are
made after the breakpoint has been disabled. (32384113)

Workaround: After changing breakpoint options, toggle the breakpoint to have the conditions
take effect.

Copyright 2017 Apple Inc. All rights reserved. Page 12 of 61


Xcode 9 beta 2 Relea
Playgrounds

Live views for iOS and tvOS playgrounds may appear distorted on macOS 10.13. (32386253)

The liveTouchBar property of PlaygroundSupport is not supported. (31073754)

The live view of iOS and tvOS playgrounds may fail to display when the playground is first run.
(32358116)

Workaround: Stop playground execution and rerun.

Xcode 9s new source editor does not yet support resizing the playgrounds results area.
(32358302)

Dragging and dropping auxiliary resources into the Sources or Resources folders of a
playground inside the structure navigator will fail if the directory does not exist on disk.
(32359267)

Workaround: Manually create a Sources or Resources directory inside the playground prior
to dragging and dropping resources into the auxiliary folders.

macOS playground execution may hang in the Running state with no results produced. This is
more prevalent when changing pages. (32429211)

Workaround: Stop playground execution and rerun. If issue persists, close and reopen Xcode.

The New playground page contextual menu item does not create a new page. (32164810)

Testing

xcodebuild test can intermitently fail with Error Domain=IDEPseudoTerminalDomain Code=5


(null). (32358724)

Workaround: Try the test again.

xcodebuild test can intermitently fail with Error Domain=FBSOpenApplicationErrorDomain


Code=6 Application failed preflight checks (32446986)

Workaround: Try the test again.

xcodebuild test can intermittently fail with Error Domain=DTServiceHubClient Code=11


unable to contact local DTServiceHub to bless simulator connection. (32354498)

Workaround: Try the test again.

xcodebuild test can intermittently fail with Test runner for (null) will finish with error: Could
not obtain the bundle identifier for . (32658562)

Copyright 2017 Apple Inc. All rights reserved. Page 13 of 61


Xcode 9 beta 2 Relea
Workaround: Try the test again.

xcodebuild test can intermittently fail with DTXProxyChannel error 1. (29500302)

Workaround: Try the test again.

xcodebuild test can intermittently fail with Domain=XCTestManagerErrorDomain Code=12


Failed to get main window after 30 retries. (29122169)

Workaround: Try the test again.

xcodebuild test can intermittently fail with Assertion failed: (staticHeader.header_magic ==


DTX_MESSAGE_MAGIC). (32670023)

Workaround: Try the test again.

xcodebuild test can intermittently fail with Test operation failure: Lost connection to
testmanagerd. (32445523)

Workaround: Try the test again or reduce the number of devices being used to test in parallel.

When using the new build system, performance testing baselines are treated as if missing which
may result in spurious test failures. (31328476)

Workaround: Use the legacy build system when running performance tests.

UI tests that target the Touch Bar will not function on macOS 10.13. (32417038)

cdtool is not found when running Xcode 8 after installing Simulator Runtime DLC from newer
versions of Xcode. (32683150)

Workaround: Move aside the corresponding simruntime from


/Library/Developer/CoreSimulator/Profiles/Runtimes and then restart CodeSimulatorService and
other Xcode apps:

sudo mkdir /Library/Developer/CoreSimulator/Profiles/Runtimes/Backup

sudo mv /Library/Developer/CoreSimulator/Profiles/Runtimes/{,Backup/}iOS
10.3.simruntime

sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService

Then restart Xcode, Simulator, Instruments, etc.

UI Testing in tvOS 11.0 often fails with Assertion Failure: App accessibility isnt loaded
(32684493)

Workaround: Run the test again.

Copyright 2017 Apple Inc. All rights reserved. Page 14 of 61


Xcode 9 beta 2 Relea
xcodebuild test can intermittently fail with Error Domain=FBSOpenApplicationErrorDomain
Code=6 Application failed preflight checks. (27258971)

Workaround: Try the test again.

Devices

The Apple Watch button may be missing in Devices and Simulators windows debug console.
(32365458)

Workaround: Disconnect and reconnect the device and toggle the Show/Hide button to get the
button to show up.

Refactoring

Some complex protocols may not be completely inserted when applying the fix for Do you
want to add protocol stubs? For example, with Swift.Collection, where multiple associated
types and requirements are inherited from parent protocols, may not work properly. (31078629)

Workaround: Use the Fix button or manually add any additional missing protocol stubs.

Constructors for locally defined types, such as a struct defined inside a function body, cannot
be refactored. (31695776)

When extracting a code snippet that uses locally defined types, for instance, an enum defined in
a function body, the extracted function may use that type as a parameter, leading to
uncompilable code. (32288968)

References to declarations in static_assert statements are not renamed. (32323618)

Renaming does not affect symbols found inside macro expansions. (31989492)

Renaming Swift enum cases with associated values will not rename their argument labels.
(32126363)

Renaming a Swift class or protocol exported to Objective-C will not rename any references that
use a forward @class declaration and do not include the generated MODULE-Swift.h header.
(32275117)

Workaround: #include the generated MODULE-Swift.h header in your .m file.

Renaming a type that has the same name as the Objective-C header file it is declared in will
rename all the #imports of that header except any that are inside the bridging header.
(32305693)

Workaround: Rename the #import in the bridging header manually.

Copyright 2017 Apple Inc. All rights reserved. Page 15 of 61


Xcode 9 beta 2 Relea
Rename will not update references to an Objective-C ivar inside Interface Builder documents.
(32314491)

Renaming an Objective-C class property will not update the getter or setter class methods.
Instance properties are not affected. (32376404)

Workaround: Rename the getter and/or setter method separately.

Renaming a call or reference to a memberwise initializer does not rename the corresponding
member properties. (32383812)

Workaround: Manually rename member properties from their definition or references.

The extracted function or method might be placed between a comment that precedes the
source function and a token that precedes the comment and that is on the same line as that
comment. (32219809)

When renaming files, Xcode sometimes shows an error alert saying that the file has been saved
by another application. (31968242)

Workaround: Click the alerts Save Anyway button to correctly save the renamed file.

Renaming the Objective-C setter for a property causes a crash. (32313554)

Workaround: Rename from the property declaration or a reference to it, the getter, or
associated instance variable.

Renaming Swift IBActions sometimes incorrectly renames occurrences in Interface Builder files.
(32316577)

Workaround: Rename any incorrect occurrences from the editor.

Undo does not work while renaming. (32429491)

Workaround: Manually edit the new name, or use Cancel.

Swift Migration

References to the AVCaptureDevice.defaultDevice(withMediaType:) function are not


renamed to AVCaptureDevice.default(for:). After migration, the compiler will error with:

error: type 'AVCaptureDevice' has no member 'defaultDevice'

(32431567)

Workaround: Manually rename the function.

Copyright 2017 Apple Inc. All rights reserved. Page 16 of 61


Xcode 9 beta 2 Relea
Some APIs have changed to accept [NSAttributeKey: Any] dictionaries instead of [String:
Any], such as NSString.size(withAttributes:) and NSString.draw(at:,
withAttributes:). These changes may produce errors after migration is completed.
(32431618)

Workaround: Change the type to match the expected parameters in the variable declaration.

After migration, invalid references to notification names such as


.NSTableView.selectionDidChangeNotification or
NSNotification.Name.NSTableView.selectionDidChangeNotification may result in
errors such as:

error: type 'NSNotification.Name' has no member 'NSTableView'

(32466196)

Workaround: To fix the error, remove the leading dot or leading NSNotification.Name.
prefix.

After migration, the compiler may error with:

error: value of type 'Substring' has no member 'rangeOfCharacter'

(32431949)

Workaround: Wrap the value, on which rangeOfCharacter is called, with String().

Some APIs that previously accepted a String parameter have changed to accept an enum type
of a raw String type in Swift 4. In some situations, the migrator does not add code to properly
wrap the String value. (32431165)

Workaround: Wrap the string value with the expected enum type, such as:

TheEnumType(rawValue: <string value>)

The migration may not properly convert APIs which changed from an optional String to an
enum, producing errors such as:

error: cannot convert value of type 'String?' to specified type


'<SomeEnumType>'

(32431736)

Workaround: Add code to wrap the String value with:

SomeEnumType(rawValue: ..)

Copyright 2017 Apple Inc. All rights reserved. Page 17 of 61


Xcode 9 beta 2 Relea
The migrator does not properly distinquish between single-tuple and multiple-argument
function types as described in SE0110, causing additional mismatched type errors with the
closure types that are passed to Standard Library functions expecting tuple objects.
(32431899)

Workaround: Manually fix the closure types to accept values of tuples instead of separate
argument values.

When using a String to index a Dictionary that has NSAttributedStringKey as key, the
compiler may return an error of the form:

error: ambiguous reference to member 'subscript'

(32432013)

Workaround: Manually wrap the key object with NSAttributedStringKey(rawValue: ..)

The migrator does not properly handle cases where an API changes nullability and the right side
of an if let statement becomes non-optional. This will produce errors such as:

error: initializer for conditional binding must have Optional type, not
'<TYPE>'

(32476453)

Workaround: Change the if let statement to make it an assignment with let instead.

When using $0 and $1 in a closure that is passed to a function expecting a closure with a single
tuple argument, the compiler may error after migration with:

error: closure tuple parameter '(TYPE, TYPE)' does not support


destructuring with implicit parameters

(32489893)

Workaround: Change $0 and $1 references to $0.0 and $0.1 respectively.

After migration, the compiler may return an error of the form:

error: 'Integer' is unavailable

(32432481)

Workaround: Replace Integer with BinaryInteger.

When passing a closure with a single underscore argument ({ _ in }) to a function expecting


multiple arguments, after migration the compiler may return an error of the form:

Copyright 2017 Apple Inc. All rights reserved. Page 18 of 61


Xcode 9 beta 2 Relea
error: cannot convert value of type '(_) -> ()' to expected argument
type

(32301091)

Workaround: To fix the error, change the single argument to the correct number of arguments
such as { (_,_) in }

When passing a closure to map with two function arguments, after migration the compiler may
return an error of the form:

error: 'map' produces '[T]', not the expected contextual result type
'<TYPE>'

(32432752)

Workaround: Change the closure signature to accept a tuple argument of two elements when
using map.

When comparing a String to a string_enum type, the migrator may not properly adjust code to
account for SDK changes. The compiler may return an error of the form:

error: binary operator '==' cannot be applied to operands of type


'NSToolbarItem.Identifier' and 'String'

(32432253)

Workaround: Change the side of the comparison with the enum value to add .rawValue, so
that the comparison works with strings on both sides.

Project Navigator

Dragging the files into a project from the Finder may move or copy the underlying file.
(31042020)

Workaround: Hold down Command-Option while dragging to only create a reference, and
leave the filesystem as is.

Creating a Group from Selection may not associate the correct directory with the new group.
(31684063)

Workaround: Re-associate the group in the file inspector.

Copyright 2017 Apple Inc. All rights reserved. Page 19 of 61


Xcode 9 beta 2 Relea
Source Control

When configuring or viewing your GitHub account, Xcode may present a keychain prompt for an
SSH key passphrase. Click Allow or Always Allow to resolve this issue. (32017088)

Changing a remote name in SCM inspector may crash Xcode. (32260828)

Editing the address of a GitHub enterprise account has no effect. (32300885)

The new SCM history may load with no content. (32335760)

Workaround: Force a reload of the view by clicking away and clicking back, or press
Command-Control-W to reload.

If an SSH key is configured in Xcode for a GitHub or GitHub Enterprise account, and that key is
removed from the file system, Xcode will not notice. (32355529)

Xcode may not always prompt to trust the fingerprint of an SSH host(32444878)

Workaround: Clone a repository from the same host over SSH using Git command-line tool

Build System

The new build system may not define all of the environment variables that the standard build
system defines when launching shell scripts. If the new build system is not supplying an
environment variable which your scripts use, please file a bug with the name of the environment
variable, the expected value you saw under the old build system, and a brief explanation about
your usage of the variable. (24541618)

The new build system does not yet support building MLKit documents. (30177607)

When using the new build system and using DWARF with dSYM File debugging information,
the build may do unnecessary work to extract the dSYM on each build iteration, degrading build
performance. (30668974)

Workaround: Only enable DWARF with dSYM File for the Release configuration.

With the new build system, switching between building the Debug and Release
configuration of a project may result in unnecessary content rebuilding. (30924058)

The new build system does not yet support any of the Product > Perform Action > Compile,
Analyze, Preprocess, or Assemble operations for single-files. (31072405)

Interface Builder live views do not yet build using the new build system, and instead will use the
old build system. (31433718)

Copyright 2017 Apple Inc. All rights reserved. Page 20 of 61


Xcode 9 beta 2 Relea
The new build system does not yet support building projects with Message Pack or Sticker Pack
targets in them. (31508349)

The new build system does not yet support projects which have on-demand resources enabled.
(31508570)

When using the new build system, the total number of build tasks reported in the activity area
may not be computed correctly, and will continue to increase during the build. (31855141)

When using the new build system, some CopyPNG build steps may fail to build if there are no
command line developer tools selected. (32386162)

Workaround: Ennsure there are active tools by going to Xcode > Preferences > Locations >
Command Line Tools and selecting a valid tool installation.

When using the new build system, it is not possible to use the clean action in the IDE in a project
or workspace that uses the legacy or custom build locations. (32296417)

XIB and Storyboard files which use platform-specific naming conventions (e.g.
MyView~ipad.xib) may cause the new build system to emit an unable to build node error.
(32409101)

Autocreated schemes are no longer available to xcodebuild until theyve been marked as
shared, or edited in any way, in Xcode. (9659122)

The new build system does not yet support any of the Edit > Convert > To Current Swift
Syntax, To Modern Objective-C Syntax, or To Objective-C ARC operations. (32464746)

The new build system does not yet remove files, such as headers, produced by prior builds
which are no longer produced by the current project configuration. (30961839)

The new build system does not yet support use of Custom Paths in build settings or shell
script environment variables. (32615100)

The new build system only copies the first localized resource in some situations. (32618863)

Signing and Distribution

When exporting an ad-hoc or enterprise IPA, Swift symbol stripping will not be performed if you
do not enable app thinning or recompile from bitcode. (31737836)

Workaround: Enable app thinning or recompile from bitcode while exporting your app.

Automatic provisioning may not work if you have joined multiple teams on your server, and you
may be presented with an error about team credentials being incorrect. This will be resolved in
an upcoming beta. (32426399)

Copyright 2017 Apple Inc. All rights reserved. Page 21 of 61


Xcode 9 beta 2 Relea
SceneKit

SceneKit particles do not render in the SceneKit Editor when running on macOS 10.12 or earlier.
(32352255)

Server

Attempting to edit an Xcode Server bot may incorrectly display an error: <Scheme> does not
match this workspace even though it does. (31957021)

Workaround: Click Cancel to dismiss the dialog.

Xcode Server will sometimes report Failed to build workspace with scheme . as an integration
issue on the integration summary tab. (31957360)

Workaround: Check the integrations build logs for the actual error.

Removing Server.app after configuring Xcode Server with Xcode 9 will stop the Xcode Server
service. (31820819)

Workaround: Do not remove Server.app, or after removing manually start Xcode Server again
from the Server & Bots preference pane or using the xcscontrol command-line tool.

Bots created in an earlier version of Xcode may appear to be configured to test in parallel but
actually run tests sequentially. (32365638)

Workaround: Edit the bot to toggle testing in parallel on and off again, and run a new
integration.

Simulator

Installation failures in Simulator may be reported incorrectly as IPC failures: (ipc/mig) server
died. (31646737)

Workaround: Open Console.app to read through the devices system log for more information
on the root cause. The relevant error message should be logged by installd.

IOSurface.framework is not yet present in the iOS Simulator SDK. (32160941)

ATTR_CMNEXT_LINKID is not available when running Simulator on macOS 10.12.5 or earlier.


(32181698)

Though volume and mute button events are sent to the simulated device, the volume is not
adjusted. (32118558, 32117708)

When running several simulators simultaneously you may exceed the maximum number of
processes or maximum open file limits. If this happens attempts to start new processes or open

Copyright 2017 Apple Inc. All rights reserved. Page 22 of 61


Xcode 9 beta 2 Relea
more files will fail. You can recover by shutting down some simulators or closing open programs.

macOS 10.13 automatically scales these limits based on available system memory. On earlier
releases these limits are fixed values.

These limits can be increased by using launchctl. For more information, choose Help >
Simulator Help and navigate to Troubleshoot Simulator > Insufficient resources. (31179087)

Booting many simulator devices in rapid succession can exhaust system resources without
warning, preventing new processes from spawning. (31723508)

Workaround: Close simulator windows or quit Simulator.app to shutdown devices for


immediate recovery. Do not Force Quit Simulator.app as that will not shutdown the devices. For
more information, choose Help > Simulator Help and navigate to Troubleshoot Simulator >
Insufficient resources.

Use of ATTR_CMNEXT_LINKID with the getattrlist(2) family of functions in the iOS, tvOS, and
watchOS simulators requires macOS 10.12.6 Beta 2 or newer. (32226044)

Some simulator devices may remain booted after running xcodebuild test. (32187594)

Workaround: Run xcrun simctl shutdown booted after running xcodebuild test.

Installing Xcode 9 on macOS 10.12.5 or earlier can cause Xcode 8s Simulator, Interface Builder,
and Playgrounds to stop functioning after launching Console.app. (31641958)

Workaround: Update to macOS 10.12.6.

Simulator windows fail to minimize when running on macOS 10.13 Beta. (32319153)

Resizing a Simulator window will sometimes produce visible jitter or a flash to black.
(32330985)

Workaround: Disabling Debug > Optimize Rendering for Window Scale should alleviate some
of this problem, but it will cost more CPU usage.

Simulator will crash on launch on older (circa 2010) Mac hardware, and may fail on some pre
2013 Macs and on Virtual Machines. (32227092, 32293108)

Workaround: You can force the use of OpenGL instea of OpenCL by setting the following
defaults option:

defaults write com.apple.CoreSimulator.IndigoFramebufferServices


FramebufferRendererHint 3

Trying to uninstall an app in Simulator using xcrun simctl uninstall will fail and hang.
(30586964)

Copyright 2017 Apple Inc. All rights reserved. Page 23 of 61


Xcode 9 beta 2 Relea
Workaround: Use xcrun simctl erase to completely reset the device to its initial state, or
delete the app from the devices home screen in Simulator.app

Interacting with the ringer switch in a simulated iOS device does not show a response in the UI.
(32398343)

Simulator devices will show as all black on some hardware. (32436030)

Workaround: Try defaults write


com.apple.CoreSimulator.IndigoFramebufferServices FramebufferRendererHint 1
to force use of Metal. If that doesnt work, try 2 (force use of OpenCL). You can remove this
workaround once the issue is fixed by running defaults delete
com.apple.CoreSimulator.IndigoFramebufferServices

App installation can fail if a file in the app bundle is read-only. (32589563)

Workaround: Use chmod u+w to add write permission to the file that is tripping up installation.

Xcode 9s Simulator.app may take 10 seconds to quit after launching Xcode 8. (32586683)

Workaround: Quit Xcode 9 and all of its related apps before switching to Xcode 8.

CoreNFC is not testable in Simulator. (32619896)

Copyright 2017 Apple Inc. All rights reserved. Page 24 of 61


Xcode 9 beta 2 Relea
Resolved in Xcode 9 beta 2 Apple LLVM and
Swift Compilers
Swift Compiler

In Swift 4, closures that are invoked immediately are no longer type-checked as escaping
closures. (SR4735) (31910280)

Copyright 2017 Apple Inc. All rights reserved. Page 25 of 61


Xcode 9 beta 2 Relea
Known Issues in Xcode 9 beta 2 Apple LLVM
and Swift Compilers
Swift Compiler

The Swift compiler diagnoses attempts to use NSCoding with a class that doesnt have a simple
Objective-C runtime name. The names of these classes are fragile and may be affected by
unrelated changes. For example, the runtime name of a private class depends on the name of
the containing source file.(32314195)

Workaround: Use the @objc attribute to explicitly specify a runtime name instead. If you
archive the class under its current mangled name, the compiler will provide a fix-it to use it.

Attempting to use the Accelerate framework from Swift may generate linker errors about
missing simd symbols such as:

error: Couldn't lookup symbols: __T04simd6float4VN").

(32457742)

Workaround: Manually add import simd to the Swift file.

The Foundation protocol NSItemProviderReading introduces a new required initializer on


NSString and other common Foundation types:

required init(itemProviderData data: Data, typeIdentifier: String)

This new requirement on subclasses of these types in Swift is temporary and will be removed in
a future seed. (32302018)

The Swift compiler will crash in Swift 4.0 mode if a targets bridging header contains an
Objective-C class with generic parameters. This also applies to the debugger, which always
runs in Swift 4.0 mode. (32463543)

The Swift compiler will crash if a key path literal is written with a protocol type as its root type.
(SR4917) (32254554)

Image literals result in an immediate run-time exit when used outside the main application
target. (26873717)

Workaround: Continue using NSImage or UIImage APIs to create images in non-application


targets.

When an NSDictionary is bridged into Swift as a Dictionary with AnyHashable keys, then
using Swift integer values to index the dictionary may fail to find objects inside the dictionary.

Copyright 2017 Apple Inc. All rights reserved. Page 26 of 61


Xcode 9 beta 2 Relea
For example:

// Objective-C
NSDictionary *makeDict() {
return @{@(NSOrderedAscending): @"ascending"};
}

// Swift
let dict = makeDict()
// Fails to find key in dictionary
dict[NSComparisonResult.orderedAscending.rawValue]

(29026017)

Workaround: Explicitly construct an NSNumber instance for the lookup key to the dictionary.

// Swift
dict[NSNumber(value: NSComparisonResult.orderedAscending.rawValue)]

The Swift compiler may crash during the Merge MyApp.swiftmodule build step.(30851899)

Workaround: Disable the Precompile Bridging Header build setting for this target.

Some exclusive access to memory enforcement conflicts may not be diagnosed when one of
the accesses is performed in a non-escaping closure. (32020710)

Dynamic checks for exclusivity enforcement are not enabled by default and are not supported in
optimized builds. They can be enabled in unoptimized builds by changing the Build Setting
Exclusive Access to Memory to Full Enforcement. (32273018)

Constraining an associated type B to be a subtype of another associated type A (as in the code
sample below) results in a compiler crash. In Swift 3.1 this code was accepted, but failed to
constrain B in any way; however, the Swift 3.1 compiler would crash if a type conforming to the
protocol used different types for A and B.

protocol Base {
associatedtype A: AnyObject
}
protocol Sub: Base {
associatedtype B: A
}

(SR4981) (32409449)

Workaround: Use the new feature explicitly requiring the two associated types to be the same
(associatedtype B where B == A), or drop the requirement on B for compatibility with Swift
3.1.

Copyright 2017 Apple Inc. All rights reserved. Page 27 of 61


Xcode 9 beta 2 Relea
Key path literals do not work when referring to computed properties of generic types. This
includes generic properties declared by protocols and non-final class properties. (31768590)

Non-object types marked with __attribute__((swift_wrapper(enum))), imported into


Swift, then subsequently passed to an Objective-C or C function will be mangled. This also
applies to NS_STRING_ENUM.

For example, in a C header:

typedef const char * MyEnumeration __attribute__((swift_wrapper(enum)));

extern const MyEnumeration MyEnumerationValue1;


extern const MyEnumeration MyEnumerationValue2;

void myFunction(MyEnumeration input);

And then called from Swift:

myFunction(.value1)

(32407790)

Workaround: Avoid marking non-object types with this attribute.

Typing a string interpolation segment such as (foo) outside of a string literal may cause the
Swift compiler to crash. (32315365)

Swift code that uses key paths may trigger pointer not aligned at address linker warnings.
These are harmless and can be ignored. (32318829)

Copyright 2017 Apple Inc. All rights reserved. Page 28 of 61


Xcode 9 beta 2 Relea
Swift Standard Library

Support for the PartialKeyPath<Root> type is not fully implemented. Attempting to look up a
PartialKeyPath on a value of its root type, as in foo[keyPath: partialKeyPath], will give an
incorrect has no subscript members error. (32237567)

Sequences of labelled key/value pairs cannot be used with the Dictionary.merge method.
The most prominent of these is Dictionary itself. (SR4969) (32352586)

Workaround: Map your labelled sequence to an unlabeled one:

d1.merging(d2.lazy.map { ($0.key,$0.value) }) { $1 }

Not every method available on String is available on the Substring type such as
precomposedStringWithCanonicalMapping. (32382183)

Workaround: Wrap a String constructor around the Substring. For example:

String(substr.precomposedStringWithCanonicalMapping)

In some cases there are extra String copies being made when using the Substring type which
may slightly impact performance. (32469150)

Copyright 2017 Apple Inc. All rights reserved. Page 29 of 61


Xcode 9 beta 2 Relea
New in Xcode Xcode 9 beta IDE
General

Xcode 9.0 supports running multiple concurrent versions of the Xcode app and of any
associated tools such as Simulator. Xcode 9.0 can not be run at the same time as earlier
versions. (23140937)

-runFirstLaunch, a new flag in xcodebuild interactively checks the status of the license
agreement and install any packages required for launching Xcode. (23529342)

A file with a base name of FooTest or FooTests is now considered a counterpart of a file with a
base name of Foo for navigation and the Assistant Editor. (28981734)

Source Editor

When text is selected, typing a opening delimiter adds a matching closing delimiter at the end of
the selection. Auto-matched delimiters include " ", ( ), [ ], { }. (29164633)

You can now increase and decrease the source editor font using Command-plus and
Command-minus. (21423189)

Added a picker to the Fonts & Colors pane in Preferences to modify the source editor line
spacing. (30571596)

You can now choose from 3 cursors to use in the source editor. (31813260)

Copyright 2017 Apple Inc. All rights reserved. Page 30 of 61


Xcode 9 beta 2 Relea
Interface Builder

UIView layout margins now have an option in the Size inspector to enable leading and trailing
margins to respect RTL languages at runtime. (30086042)

Interface Builder supports the vertical baseline-to-baseline constraints added in iOS 11 that
update spacing based on changes in the Dynamic Type size. (30086144)

Interface Builder now renders navigation bars, tab bars, and toolbars on the canvas in the same
way they appear at runtime. (30983209)

To use the new usesAutomaticRowHeights property of NSTableView in Interface Builder,


choose Automatic (Auto Layout) from the Size inspector and set the Row Height value. The
value is used as part of the auto layout calculation. (29511510)

Interface Builder now warns when a views constraints can cause localization problems, such as
truncation and clipping. (32141216)

Interface Builder no longer compiles for iOS 6. Documents with older deployment targets can
still be read, and their frames can be transitioned to iOS 7 and later. (28726486)

Interface Builder uses UIView.safeAreaLayoutGuide as a replacement for the deprecated


Top and Bottom layout guides in UIViewController. To use the new safe area, select Safe
Area Layout Guides in the File inspector for the view controller, and then add constraints
between your content and the new safe area anchors. This prevents your content from being
obscured by top and bottom bars, and by the overscan region on tvOS. Constraints to the safe
area are converted to Top and Bottom when deploying to earlier versions of iOS. (29323293)

Interface Builder supports setting textContentType on classes conforming to the


UITextInputTraits protocol. This improves the ability of AutoFill to populate with appropriate
data, including Username and Password on iOS 11. (25019432)

When a constraint is selected, the inspector now allows choosing a different first or second item
to anchor it to. Depending on the constraint type, siblings and containers are available.
Constraint constants are automatically updated to preserve current positioning. (17535216)

Asset Catalog

Asset catalogs now support named colors, which can be referenced in Interface Builder
documents. (28900538)

Asset catalogs now support high-efficiency image formats, including .avci, .heic, and .heif file
extensions. (29959599)

Copyright 2017 Apple Inc. All rights reserved. Page 31 of 61


Xcode 9 beta 2 Relea
Main Thread Checker

Main Thread Checker is a new runtime tool that finds calls to APIs in AppKit, UIKit, and WebKit
that must be made from the main thread, but are made on other threads. These calls are
reported as runtime issues. Main Thread Checker is automatically enabled during debugging
and can be disabled in the Diagnostics tab of the Scheme editor. (29951764)

Undefined Behavior Sanitizer

Undefined Behavior Sanitizer is a new runtime tool that finds several types of undefined
behavior in C languages, including integer overflows, invalid casts, and alignment violations. It
has low overhead and can be enabled in the Diagnostics tab of the Scheme editor. Undefined
Behavior Sanitizer is compatible with all other sanitizers. (15425728)

Undefined Behavior Sanitizer can optionally detect nullability annotation violations at runtime.
Go to Build Settings then set Enable Nullability Annotation Checks to Yes in the Undefined
Behavior Sanitizer section. (30619298)

Address Sanitizer

Address Sanitizer has been extended to check for cases when the scope of a variable has
ended, but the underlying memory is used. It also has a new optional check that detects cases
where memory backing a local variable is used after the function has returned. This check, for
the use of stack memory after return, can be enabled in the Diagnostics tab of the Scheme
editor. (32308829)

Address Sanitizer is now compatible with Malloc Scribble. (32359908)

Thread Sanitizer

Thread Sanitizer has been extended to catch higher-level races on Objective-C and Swift
collections, such as writing to a mutable array from different threads without using proper
synchronization. (26798589)

Thread Sanitizer has been extended to catch when multiple threads call mutating methods on
the same struct without synchronization. It will also catch many cross-thread violations of
Swifts rule requiring exclusive access to memory. (30455576)

Copyright 2017 Apple Inc. All rights reserved. Page 32 of 61


Xcode 9 beta 2 Relea
Debugging

iOS devices and Apple TV can now be debugged over the network. For more information, see
the topics in Xcode Help > Run and debug > Network debugging. (10968305)

Memory graph files exported by Xcode or generated by the leaks command line tool will now
save allocation backtraces if malloc stack logging is enabled. This makes the backtraces
available for all the tools that support memgraph files (leaks, vmmap, Xcode). (25399716)

The View Debugger now supports visual debugging of SpriteKit and SceneKit scenes. SpriteKit
nodes are shown in the view hierarchy. For SceneKit scenes, select the SCNScene in the debug
navigator to open the snapshot in the SceneKit editor. Changes in the SceneKit editor when it is
in runtime debugging mode can be saved and do not change your app. (29169315)

Choosing an action in the breakpoint editor sets it as the default action. (14560556)

Xcode shows a visual indicator in the icon for a breakpoint that has a condition, an ignore count,
one or more actions, or automatic continue enabled. (9023163)

Added Quick Look support for variables of type PDFDocument. (30108359)

Added variables Quick Look support for CIContext on 10.13 and later. (30390167)

Added Quick Look support for variables of type CIRenderTask on macOS 10.13 and later.
(30911954)

Added Quick Look support for variables of type NSImageRep. (13257754)

Adds Quick Look support for variables of type CALayer. (31161558)

Enhanced Quick Look support for variables of type CIImage on macOS 10.13 and later.
(30390177)

The View Debugger now includes view controllers in the heirarchy and includes debugging
information in the inspector. (16261359)

Copyright 2017 Apple Inc. All rights reserved. Page 33 of 61


Xcode 9 beta 2 Relea
Project Navigator

Groups in the Project Navigator are now more closely associated with directories in the file
system:

Dragging files between groups in the Project Navigator now moves the files in the
filesystem, and updates any associated SCM working copies.

Creating, renaming, and deleting groups now performs the corresponding changes in the
connected directory in the filesystem, if one is defined.

Removing a groups connection to a directory in the filesystem can now be done in the file
inspector by clicking on the clear (X) button.

Changing an association to a file or group can be now be done quickly by dragging and
dropping the file or folder onto the Location section of the file inspector.

(28612132)

Copyright 2017 Apple Inc. All rights reserved. Page 34 of 61


Xcode 9 beta 2 Relea
Source Control

Xcode 9 includes a brand new Source Control navigator where you can easily see the working
copies for your project or workspace. Each working copy lists branches, tags and remotes, and
you can quickly see the currently checked out branch and push/pull counts for those branches.
The gear and contextual menus allow you to create branches and tags, configure remotes, and
perform tasks like checking out a revision or branch and merging changes between branches.
New history and review files editors are displayed when clicking on a branch or tag in the
Source Control navigator. Youll see a full history for your branch or tag, including avatars,
author and commit information and each commit is annotated with the branches and tags that
correspond to that commit. A new SCM inspector allows you to see more details on a commit
and double clicking a commit reveals the Review Files Editor (which shows all the files that were
modified as part of a commit and the changes that were made). (29054970)

Xcode 9 integrates with GitHub. You can easily manage your account from the Xcode
preferences window, including support for two-factor authentication, and configure an SSH key
to be used when performing Source Control operations against GitHub. (28775680)

Xcode 9 includes support for one-click clone from GitHub.com in Xcode when viewing
repositories in your Web Browser. (32294826)

Xcode 9 will no longer show repositories that you have cloned source code from in the past in
the Preferences/Accounts window. Instead, you can manage your GitHub and GitHub Enterprise
accounts. (30191709)

Xcode 9 includes a brand new Clone window that integrates directly with GitHub to show you
favorite, private/personal and organizational repositories for all of your accounts. For each
repository, youll see metadata and be able to view the project Readme, and clone with one-
click. (30960520)

Xcode 9 will now automatically fetch from remote tracking branches and mark files that have
been updated in the project navigator, and show push/pull counts in the Source Control
navigator. (31839384)

The Source Control pane in Preferences includes configuring Git and SVN ignore file lists, and
for configuring your Git author information. (10544339)

Build System

New Build System

Xcode 9 includes a new build system written from scratch in Swift. It is designed for higher
reliability, and it catches project configuration problems which the standard build system does
not. The performance of the build system (not including compilers, linkers, and other build tools)

Copyright 2017 Apple Inc. All rights reserved. Page 35 of 61


Xcode 9 beta 2 Relea
has been dramatically improved. This new build system is built on top of the Swift open source
llbuild project.

In Xcode 9.0, the new build system is disabled by default, but it can be enabled for a project or
workspace in the settings accessed with the Workspace Settings or Project Settings
menu item in the File menu. Passing the -UseNewBuildSystem=YES flag to xcodebuild will
also force it to use the new build system for a command-line build. The new build system will
become the default build system in a future version of Xcode. (19209225)

While the new build system is highly compatible with existing projects, some projects may
require changes when adopting it. Expected changes are due to the following:

The new build system is more strict about detecting and producing an error if a cycle is
detected between elements in the build, as cycles can cause unnecessary rebuilds,
degrading build performance. To resolve this issue, ensure that all files are produced earlier
in the build than when they are used. For example, if a target both produces an output and
depends on other targets which use that output, move the production of the output into its
own target which can be run earlier in the build.

It is an error for any individual file in the build to be produced by more than one build
command. For example, you may not declare the same output file from two shell script
phases in separate targets, if they are both built at once (since the build system has no way
to decide which to use). To resolve this, factor out any such tasks into a single target that
can be depended upon by anyone requiring it.

If an output file which is generated by a shell script is used as an input elsewhere in the
build (for example, to another shell script), then that output must be declared as an explicit
output by the script which generates it; otherwise the build system may attempt to search
for the file before it has been generated, causing the build to fail.

The traditional header map which was generated when the Always Search User Paths
(ALWAYS_SEARCH_USER_PATHS) setting was YES is not supported by the new build system.
Instead, projects should set ALWAYS_SEARCH_USER_PATHS to NO and should migrate to
using modern header include syntax:

Add any needed header files which are in the project repository to the Xcode project, to
ensure they are available for use in #include (via the project wide header map).

Use quote-style include ("foo.h") for project headers, and reserve angle-bracket
include (<foo.h>) for system headers.

The new build system will pass undefined_arch as the value for the ARCH environment
variable when running shell script build phases. The value was previously not well defined.
Any shell scripts which were depending on this value should instead be written to behave
correctly for all defined architectures being built, available via the ARCHS environment
variable.

Copyright 2017 Apple Inc. All rights reserved. Page 36 of 61


Xcode 9 beta 2 Relea
The new build system does not support the standard clean behavior, instead supporting
clean build folder.

The module.modulemap file that Xcode generates for a target containing Swift and defining a
module now includes requires objc so it can be used by languages other than Objective-C
(such as C++). (28650820)

Autocreated schemes are no longer saved to disk unless theyve been edited. This helps
prevent the accumulation of schemes for targets which are deleted, or are added to other
schemes. (30266825)

Xcodes project modernization workflow will recommend enabling the build setting Implicit
Objective-C Literal Conversions (CLANG_WARN_OBJC_LITERAL_CONVERSION) to warn about
implicit conversions from Objective-C literals to values of incompatible type. (32150034)

Xcodes project modernization workflow will recommend enabling the build setting Implicit
Non-Literal Null Conversions (CLANG_WARN_NON_LITERAL_NULL_CONVERSION) to warn about
non-literal expressions that evaluate to zero being treated as a null pointer. (32169031)

The new Strip Swift Symbols (STRIP_SWIFT_SYMBOLS) build setting, which is enabled by
default, adjusts the level of symbol stripping so that when the linked product of the build is
stripped, all Swift symbols are removed. This significantly reduces the size of Swift frameworks.
If the lack of Swift symbols causes problems, such as when using dladdr(), this setting can be
disabled. To view the exported symbols from file that has been stripped, use xcrun dyldinfo -
export instead of nm. (31306055)

The build setting Separate Strip (SEPARATE_STRIP) is no longer displayed in the build settings
editor, and it is no longer supported. Xcode always strips binaries in a separate task and no
longer instructs the linker to perform the strip. (31584192)

A new build setting for the swift compiler, Precompile Bridging Header
(SWIFT_PRECOMPILE_BRIDGING_HEADER), has been added. This is enabled by default, and
adds a new step in mixed-source builds called PrecompileSwiftBridgingHeader, that improves
overall build time. If unexpected errors occur during this step, disabling the build setting will
omit this step. (31851450)

There is a new build setting Swift 3 @objc Inference [SWIFT_SWIFT3_OBJC_INFERENCE]


which controls how the Swift compiler infers @objc for declarations. By default it will use the
declared Swift version in the target to perform this inference, but this setting can be used to
explicitly direct the Swift compiler to use either Swift 3 to Swift 4 inference rules. (32121595)

When a project is opened, Xcode will detect if any build files in targets in the project represent
file references which are not present in that projects group tree. Any such references will be
added to a file group named Recovered References, which will be created if necessary. These
references should be manually reorganized in the project as appropriate. (22924751)

Copyright 2017 Apple Inc. All rights reserved. Page 37 of 61


Xcode 9 beta 2 Relea
The name of the build Intermediates folder in a build location is now Intermediates.noindex,
which prevents Spotlight from indexing the contents of this folder. This change improves Xcode
build times. (29336306)

Localization

Export and import of localizations via XLIFF now supports stringsdict files, including support for
using the correct plural variants per language. (16785521)

A template for stringsdict files is now included in Xcode. (15483459)

Core Data

The data model editor presents a unified interface for Core Datas new fetch indexes feature as
well as its existing property index and entity compound index features. Older data models are
translated into fetch index form for editing, and saved to the old file format when necessary.
Compiling a data model with a Deployment Target lower than iOS 11, watchOS 4, macOS 10.13,
or tvOS 11 continues to generate a compatible compiled form. (30843153)

The data model editor supports the new URI attribute type. (31205307)

The data model editor supports the new UUID attribute type. (31205342)

An attribute in a data model can now be marked as preserved after deletion, to support the Core
Data persistent history tracking feature. (31204966)

An entity can have its Core Spotlight display name expression specified directly in the data
model. (31619747)

When generating code for Swift 4, data model code generation has been updated to use Swift
structs when possible. Code generation for Swift 3 is unchanged. (27512827)

Signing and Distribution

The distribution workflow has been enhanced to support manual signing. Manual signing allows
you to specify the precise set of distribution signing certificates and provisioning profiles that
you want to use when distributing your app. xcodebuild -exportArchive also supports
manual signing, with new additions to the ExportOptions plist format for specifying a
signingStyle, a signingCertificate, and a provisioningProfiles dictionary. See xcodebuild -help
for the full list of supported ExportOptions keys.

When automatically signing for distribution, Xcode will now create and use only Xcode-
managed distribution provisioning profiles. This behavior is functionally analogous to automatic
signing for development, and means that Xcode will no longer create or modify any of your
manually created distribution provisioning profiles. Xcode-managed distribution provisioning
profiles are supported for all distribution methods except for Developer ID distribution.

Copyright 2017 Apple Inc. All rights reserved. Page 38 of 61


Xcode 9 beta 2 Relea
xcodebuild -exportArchive now fully supports automatic signing, including creating and
updating signing assets, if you pass the -allowProvisioningUpdates flag.

In addition, when Xcode detects that you must create a new distribution signing certificate, it
will now prompt you for permission to create one and provide you with a convenient means to
export the signing certificate for safekeeping or for sharing with other team members. Revoking
distribution signing certificates is no longer supported within the distribution workflow. The
distribution workflow also no longer requires you to specify a team if your app was signed when
you built your archive.

Finally, the distribution workflow now outputs several additional files alongside your exported
app: a DistributionSummary plist, a Packaging log, and an ExportOptions plist. The
DistributionSummary plist describes the content of your exported app, including information
about its signature; whether it includes symbols and bitcode; and its embedded content. The
Packaging log is akin to a build log, and contains all of the commands used to transform the
archived application into a packaged app for distribution. The ExportOptions.plist encapsulates
all of the choices you made throughout the distribution workflow. It can be passed to
xcodebuild -exportArchive to automate distribution of your app for continuous integration.
(29054761)

xcodebuild can now communicate with the Apple developer website to create and update
provisioning profiles, signing certificates, and app IDs for targets that use automatic signing. To
enable this behavior, first add your Apple ID in Xcodes Accounts preferences window, and then
pass the -allowProvisioningUpdates flag to xcodebuild when building. (27572834)

Xcode supports a new build setting, CODE_SIGN_STYLE, which can be used to override a
targets signing style to Automatic or Manual when using xcodebuild. (28077832)

When exporting a Swift app for a platform that supports App Thinning, the distribution workflow
shows a new option Strip Swift Symbols that controls whether Swift symbols should be
stripped out of the Swift standard libraries. This significantly reduces the size of the Swift
libraries. If the lack of Swift symbols causes problems, such as when using dladdr(), this setting
can be disabled. (31669406)

Testing

Xcode Server and xcodebuild now support running tests in parallel on multiple devices and
simulators. Bots can be configured to enable or disable parallel testing on devices, and by
default bots will prefer to test in parallel. The output produced by xcodebuild when testing in
parallel has been updated (any automated tooling relying on this output may need to be
updated). (14254639)

When running tests, xcodebuild will no longer launch Simulator. (27385435)

Copyright 2017 Apple Inc. All rights reserved. Page 39 of 61


Xcode 9 beta 2 Relea
XCTest includes a new teardown block API for cleaning up test state after your test completes.
(28097197)

XCTest includes a new API that can be used to wait on an XCUIElement existing before
proceeding. (28483267)

XCTest now includes support for targeting multiple applications in a single UI test, including
monitoring application state and making a backgrounded application the frontmost application.
(28948745)

XCTest types that are closely associated with a particular class such as XCUIElement.Type are
available as nested types in Swift 4. (29000570)

Schemes with Code Coverage enabled (in the Test action) will now always build with Code
Coverage, including for the Run and Launch actions. This reduces the need to build multiple
versions of the application. Users who require code coverage to be off for their non-test actions
can explicitly use a separate scheme with coverage disabled. (31848014)

XCTest includes XCTActivity, a new API for grouping UI test activity together in test reports
and logging. (30401267)

XCTest includes XCTAttachment, a new API for bundling diagnostic test resources such as rich
logging along with your test results. (30478677)

XCTest now includes new scheme-level configuration options for disabling automatic
screenshots, and new API for capturing screenshots of partial, individual or multiple displays.
(21327915)

UI testing now supports targeting LSUIElements-based applications. (21344280)

Xcode 9 includes significant improvements to UI testing around performance when targeting


applications built and installed by Xcode. XCTest now includes firstMatch for restricting query
execution in UI tests. (22980005, 29544176)

Tests can now be configured to run tests in a specific language and region using a scheme
setting in Xcode. (28897796)

By default, xcodebuild tests on multiple destinations simultaneously. To disable this feature,


provide the -disable-concurrent-testing command line argument. (31964004)

When Code Coverage is enabled in the Test action of a scheme, Xcode will no longer place the
build intermediates and products from the Test action into a separate build location, and will
instead use the same location as the Run action. Enabling Code Coverage for the Test action
now also enables it for the build performed by the Run action. This causes a build for the Run
action to take approximately 3% longer, but allows the Test and Run actions to share build
products and intermediates, reducing overall build times when alternating between these
actions. (32079317)

Copyright 2017 Apple Inc. All rights reserved. Page 40 of 61


Xcode 9 beta 2 Relea
When viewing coverage results for a test action invocation in Xcode, you will now see a
numerical value for the coverage percentage too. (21531774)

Crashes Organizer

The Crashes Organizer will symbolicate unsymbolicated logs when selected using local .dSYMs
indexed by Spotlight. (22550064)

Templates

In Xcode 9, the template macro expansion subsystem has been reworked. Improvements
include:

A new standard macro named FILEHEADER has been added that is the content for the
standard file header comment.

Macros can now be defined in terms of other macros. For example the new FILEHEADER
macro is defined in terms of macros like FILENAME and COPYRIGHT. COPYRIGHT, in turn is
defined in terms of ORGANIZATIONNAME and YEAR.

Macro expansions can apply modifiers. This was faked in the old implementation by setting
special macros that were made by turning other macros into identifiers or xml-safe variants,
but now these modifiers can be used with any macro. The syntax is
___MACRONAME:modifier___. Multiple modifiers can be chained like
___MACRONAME:modifier1,modifier2___

Custom macro definitions and overrides can now be supplied.

For more information, choose Help > Xcode Help and see the topics in Appendixes > Text
Macros.

(5775785)

Copyright 2017 Apple Inc. All rights reserved. Page 41 of 61


Xcode 9 beta 2 Relea
Server

Xcode Server now supports automatic and manual provisioning configurations for your project.
For schemes that contain targets that use the automatic signing style, an agent or admin of the
developer team can add your server to your team from the updated bot editor. If your scheme
requires manually specified certificates or profiles, they can be easily shared with the server
from the new Signing tab in the bot editor. (15437174)

Xcode Server now supports configuring additional arguments that will be passed to
xcodebuild when integrations run. (23578597)

Xcode Server now supports sending an all clear email notification when all issues being
tracked by a bot have been resolved. (26179348)

Xcode Server no longer requires the macOS Server app. Configure your server and bots using
the Server & Bots tab in Xcodes Preferences. (28211693)

For additional information, see Xcode Server and Continuous Integration Guide.

Bots can now be configured to run tests in a specific language and region. (30382604)

Bots now support configuration of an Export Options Plist that will be used when exporting an
installable product from an archive. (31895193)

Copyright 2017 Apple Inc. All rights reserved. Page 42 of 61


Xcode 9 beta 2 Relea
Simulator

Simulator shows a device bezel with buttons that send send the appropriate event to the device.
(14020158)

Simulator now supports face-up and face-down orientations on supported devices. (11393667)

Simulator now sets a touch radius on simulated touch input. (22561885)

Simulator.app now respects the system screenshot directory instead of always saving
screenshots to the desktop. (26127809)

Simulator.app can now attach to simulators started from the command line and detach from
simulators without shutting them down. To detach when closing a device window or quitting the
app, hold down Control. You will be asked whether to shutdown or detach. A checkbox is
provided to make whichever behavior you choose the default. To change the default, repeat the
same procedure. (31004084)

Simulator now provides a Share Extension. Photos and videos are imported into the device
photo library. Locations or pins from Maps.app set the devices simulated location. App bundles
are installed. URLs are opened in Safari. Choose All Simulators to install to multiple simulators
simultaneously. (31150602)

Simulator now supports edge swipe gestures when the device bezel is visible. Begin your
gesture just outside the screen region. (31558767)

Simulator.app now supports running multiple devices simultaneously. As a result the separate
Simulator (Watch).app has been removed. (5687722)

To simulate moving the Apple Watch digital crown when the bezel is shown, move the pointer
over the crown and use the macOS vertical scroll gesture. (31990733)

Copyright 2017 Apple Inc. All rights reserved. Page 43 of 61


Xcode 9 beta 2 Relea
Resolved in Xcode Xcode 9 beta IDE
General

A bug where code completion would not work in a new source file, or in a source file which had
been renamed or moved, has been fixed. (29615992)

Interface Builder

Fixed an issue where Objective-C annotations like NS_REFINED_FOR_SWIFT caused


IBInspectable to not be recognized on a property. (30509152)

Interface Builder now shows correct bar heights (status bar, top bar, bottom bar) when picking
landscape for a device in the device configuration bar. (6799670)

Debugging

Fixed an issue causing Quick Look of Swift URL variables to fail. (26549268)

Fixed an issue causing Quick Look of Swift Data variables to fail. (26549284)

Fixed an issue causing Quick Look of Swift CGImage variables to fail. (29001240)

Testing

Many common errors impacting the reliability and reproducibility of testing with Simulator
devices have been addressed. (32018540)

XCTest APIs using NSUInteger are imported into Swift 4 as Int rather than UInt, bringing it
into alignment with other system frameworks. (29589664)

XCTest will now always capture a screenshot at the time of a test assertion when running a UI
test. (28853076)

Crashes Organizer

A number of stability, reliability, presentation, performance, and correctness fixes have been
made to the Crashes Organizer. (29500046)

Source Control

Xcode will no longer produce or update unwanted .xcscmblueprint files for your project or
working copy. (31137015)

Xcode 9 will now correctly show files as renamed in the commit sheet. (32049321)

Copyright 2017 Apple Inc. All rights reserved. Page 44 of 61


Xcode 9 beta 2 Relea
Build System

The TEMP_FILES_DIR build setting is properly exported to shell script build phases. (6652373)

Localization

Xcode now uses \n and \t instead of literal newlines and tabs to represent newline and tab
characters in generated strings files. (22981479)

Xcode localization import/export now handles strings files with line endings other than the
standard linefeed character. (30552675)

Xcode no longer produces an error when exporting for localization when a localized resource is
a member of more than one target. Instead, Xcode assumes that the resource should just be
exported once, and that any imported translations will be shared among targets it is a member
of as well. (19059103)

Xcode now supports XLIFF export for source files that use encodings other than UTF8.
(18944510)

Server

Copy/paste and cmd+F now works as expected from the logs tab of an integration report.
(14140192)

You can now copy and paste when working with the Xcode Server logs. (26605066)

Xcode Server now supports two-factor authentication when joining your server to your
development team, and no longer requires use of an app-specific password. (27002415)

A frequent hang in Xcode when connecting to Xcode Server has been resolved. (30338854)

When an upgrade integration runs after installing a new version of Xcode, Xcode Server will now
correctly indicate any changes in SDK versions. (30983641)

Copyright 2017 Apple Inc. All rights reserved. Page 45 of 61


Xcode 9 beta 2 Relea
New in Xcode Xcode 9 beta Apple LLVM and
Swift Compilers
Apple LLVM Compiler

Incremental Link-Time Optimization (LTO) is 1.5x faster with the default debug information level
in large projects, and is 3x faster at incremental builds. (22867330)

Warnings for incomplete umbrella headers in module maps now trigger even when the umbrella
header is part of a submodule. (22623686)

Redefinition errors caused by repeated includes of non-modular headers now show the include
stack that lead to the repeated include. (24116019)

The new compiler flag -Wunguarded-availability warns for unguarded uses of Objective-C
APIs that were introduced in a system whose version is newer than the deployment target
version. A new Objective-C expression @available has been introduced to perform system
version checking at runtime. An if statement with an @available condition can be used to
guard uses of newer APIs:

if (@available(macOS 10.13, iOS 11, *)) {


// The compiler will not warn about uses of APIs from macOS 10.13
// or iOS 11 here
}

C or C++ code can use the new __builtin_available builtin whose semantics are equivalent
to @available.

The -Wunguarded-availability flag is off by default to prevent unexpected warnings in


existing projects. Its less strict sibling -Wunguarded-availability-new is on by default, and
warns about unguarded uses of APIs only when they were introduced in or after macOS 10.13,
iOS 11, tvOS 11 or watchOS 4. (7184689)

When using code-completion for setters of block properties that use a typedef instead of
specifying the block type directly, the placeholder for the block parameter will expand to the
correct block declaration. (21981862)

Xcode provides code-completion results for missing C++11 constructs and keywords.

The following constructs are included in the code-completion results:

static_assert
alignas

The following keywords / special identifiers are included in the code-completion results:

Copyright 2017 Apple Inc. All rights reserved. Page 46 of 61


Xcode 9 beta 2 Relea
constexpr
final
noexcept
override
thread_local

The __auto_type keyword is included in code-completion results for code that uses C or
Objective-C. (29219185)

Xcode provides code-completion results for members from dependent classes. For example:

template<typename T>
void appendIfTrue(std::vector<T> &dest, const T &value) {
dest. // Xcode will now show relevant completion results after '.'
}

Note that code-completion results wont be provided when the member expression includes a
dependent base. For example:

template<typename T>
void appendIfTrue(std::vector<std::vector<T>> &dest, const T &value) {
dest.at(0). // Xcode *will not* have the relevant completion results
// for the members of std::vector here
}

(29818301)

The compiler will warn about performSelector calls which have a selector which could refer to
a method returning a structure, union, or vector type. (12056271)

The compiler warning -Wstrict-prototypes can be used to report warnings about non-
prototype functions, block declarations, and types in C and Objective-C. (15060615)

The description for the expected identifier error includes the uses of C++ keywords in
Objective-C++ code that would have been accepted in plain Objective-C code. An example of
one such error is shown below:

error: expected identifier; 'new' is a keyword in Objective-C++


@protocol new
^

(20626062)

The command-line option -iframeworkwithsysroot has been added which allows one to
specify a framework include path that will be prefixed with the system root path (-isysroot).
(21316352)

Copyright 2017 Apple Inc. All rights reserved. Page 47 of 61


Xcode 9 beta 2 Relea
The compiler will reject Objective-C methods with a vector parameter or return value when
compiling code for the i386 target for releases prior to macOS 10.11 or iOS 9. (21662309)

The compiler includes the state of the #pragma pack directive when including a pre-compiled
header. (21359084)

Swift Language

Archival and serialization API is built in to Swift, with a focus on type-safe conversions from
external formats directly into native Swift types, and interoperability with common formats like
JSON and plist.

The Encodable and Decodable protocols (along with Codable, which implies both), allow types
to participate in encoding and decoding mechanisms.

public struct Person : Codable {


let name: String
let email: String
}

(SE0166)

Encoders and Decoders allow for type-safe conversion to and from the JSON and property list
formats. Combined with the default Codable implementation, many types can natively convert
to and from these formats, with no additional encoding or decoding work. For example:

import Foundation
let johnny = Person(name: "Johnny Appleseed",
email: "johnny_appleseed@apple.com")

let encoder = JSONEncoder()


let data = try encoder.encode(johnny)
// => {"name": "Johnny Appleseed",
// "email": "johnny_appleseed@apple.com"}

let decoder = JSONDecoder()


let person = try decoder.decode(Person.self, from: data)
print(person.name) // => Johnny Appleseed

(SE0167)

Swift 4 brings support for new type safe key path literals. They are formed via syntax that looks
like this: \BaseType.propertyName. The backslash is very important as it disambiguates
between executing a property, and simply referencing it. When the BaseType can be inferred it
can be elided producing expressions that look like: \.propertyName. Key path expressions
produce instances from the hierarchy of KeyPath types (where BaseType is the dynamic type
of the base, and PropertyType the type of named property):

Copyright 2017 Apple Inc. All rights reserved. Page 48 of 61


Xcode 9 beta 2 Relea
KeyPath<BaseType, PropertyType> readonly key path WritableKeyPath<BaseType,
PropertyType> read/write key path that can mutate a value type directly (similar to
inout/mutating) ReferenceWritablePath<BaseType, PropertyType> read/write key path
that can mutate reference types

These new KeyPaths exist alongside the existing string #keyPath expressions introduced last
year. #keyPath remains available for use with legacy String-based API. (SE0161)

Xcode 9 supports both Swift 3.2 and Swift 4.0, as controlled by the Swift Language Version
build setting. These two language modes are implemented using the same compiler and
standard library, which allows you to link together targets using Swift 3 with targets using Swift
4. This means that in most cases migration from Swift 3.2 to Swift 4 can be done on a target-
by-target basis.

While Swift 3.2 and Swift 4.0 are intended to be compatible, the differences in how they view
Cocoa and Cocoa Touch APIs can lead to inconsistencies, which may limit how a library built
with Swift 3.2 can be used by a client target built with Swift 4.0 (or vice versa). This most
commonly occurs as members being absent from a type; in certain situations the client may be
forbidden from subclassing certain classes or adopting certain protocols.

Neither Swift 3.2 nor Swift 4.0 support linking with targets compiled with any earlier versions of
Swift, including Swift 3.1 (shipped with Xcode 8.3).

As usual, if the compiler or SourceKit crashes, please file a bug report with your project and
sources attached. If you are mixing Swift 3 and Swift 4 in your project please mention that in the
description of the issue. (31104045)

A new Substring type has been introduced. In Swift 4, slicing a String returns a Substring.

In Swift 3.2, slicing a String continues to return a String, but the Substring operation can
still be called through type context i.e. myString[i.] as Substring.

Substring presents an almost-identical API as that of String. A new protocol,


StringProtocol, is available to write generic code that applies to either String or Substring.
(32260315)

String now conforms to BidirectionalCollection and RangeReplaceableCollection.


(32360041)

You can now write multi-line string literals. A """ followed by a new line starts the literal, and a
""" on a new line ends it. Every line after the initial quote must start with the same whitespace
as the closing quote, which will be stripped out on compilation. (SE0168)

A dictionary can be created from a sequence of keys and values, and can merge keys and
values into an existing dictionary. For example:

Copyright 2017 Apple Inc. All rights reserved. Page 49 of 61


Xcode 9 beta 2 Relea
let asciiTable = Dictionary(uniqueKeysWithValues:
zip("abcdefghijklmnopqrstuvwxyz", 97))
// ["w": 119, "n": 110, "u": 117, "v": 118, "x": 120, "q": 113, ]

let vegetables = ["tomato", "carrot", "onion", "onion", "carrot",


"onion"]
var vegetableCounts = Dictionary(zip(vegetables, repeatElement(1,
count: Int.max)),
uniquingKeysWith: +)
vegetableCounts.merge([("tomato", 1)], uniquingKeysWith: +)
// ["tomato": 2, "carrot": 2, "onion": 3]

(SE0165)

Filtering a set of a dictionary produces a result with the same type as the receiver. To transform
the values of a dictionary, keeping the same keys, use the mapValues(_:) method. For
example:

let vowels: Set<Character> = ["a", "e", "i", "o", "u"]


let asciiVowels = asciiTable.filter({ vowels.contains($0.key) })
asciiVowels["a"] // 97
asciiVowels["b"] // nil

let asciiHexTable = asciiTable.mapValues({ "0x" +


String($0, radix: 16) })
// ["w": "0x77", "n": "0x6e", "u": "0x75", "v": "0x76",
// "x": "0x78", ]

(SE0165)

When using a key as a dictionary subscript, a default value to be returned can be supplied if the
key is not present in the dictionary. For example:

for veg in ["tomato", "cauliflower"] {


vegetableCounts[veg, default: 0] += 1
}
// ["tomato": 3, "carrot": 2, "onion": 3, "cauliflower": 1]

(SE0165)

Use the init(grouping:by:) initializer to convert an array or other sequence into a dictionary,
grouped by a particular trait.

let buttons = // an array of button instances


let buttonsByStatus = Dictionary(grouping: buttons, by:
{ $0.isEnabled })
// How many enabled buttons?
print("Enabled:", buttonsByStatus[true]?.count ?? 0)

Copyright 2017 Apple Inc. All rights reserved. Page 50 of 61


Xcode 9 beta 2 Relea
(SE0165)

Dictionaries and Sets have a visible capacity property and a reserveCapacity(_:) method
similar to Array, and a Dictionarys keys and values properties are represented by specialized
collections. (SE0165)

It is now an error to perform a second access to a variable while it is being modified. Such
accesses lead to code that is harder both for programmers and the compiler to understand.

For example, the following code attempts to read from the variable array while the sort
method is mutating it. This is now illegal:

var array: [Int] =


array.sort { $0 < array[0] }

This rule is enforced by a combination of compile-time and run-time checks.

Static checks are used for most local variables, constants, and parameters. In Swift 4 mode,
static failures are errors and will block code from successfully compiling. In general, developers
will need to rearrange their code (for example, by adding a local copy) to prevent these
conflicting accesses. In Swift 3 mode, static failures are merely a warning, but this will be
strengthened to an error in a future release of Swift, so developers should take action to fix any
of these warnings they find.

Dynamic checks are used for global variables, static type properties, class instance properties,
and local variables that have been captured in an @escaping closure. In Swift 4 mode, failing a
dynamic check will cause a trap, much like integer overflow does. In Swift 3 mode, failing a
dynamic check merely causes a warning to be printed to stderr.

The compile-time and run-time checks enforce the rule for accesses that occur within the same
thread. Thread Sanitizer will be able to catch most (but not all) violations that occur from
different threads.

The common idiom of exchanging two elements of a collection using swap violates this rule. To
support this pattern, there is now a swapAt method on all mutable collections. (SE0176)

In Swift 4.0, extensions to the same type that are in the same file share an access control scope.
If the type that they extend is also in the same file, they share its access control scope. This
means that private members declared in the types declaration can be accessed from
extensions, and private members declared in one extension can be accessed from other
extensions and from the types declaration. (SE0169)

More generic algorithms are made possible by a new family of integer protocols:
Numeric, containing arithmetic operators
BinaryInteger, representing any number-like things
FixedWidthInteger, the most concrete of them all, adding the concept of overflow to

Copyright 2017 Apple Inc. All rights reserved. Page 51 of 61


Xcode 9 beta 2 Relea
arithmetic operations

Heterogeneous comparisons are now allowed, eliminating the need for numericCast in
comparisons. For example, (42 as UInt) > (0 as Int) just works.

With the introduction of smart shifts, it is possible to shift a value by a negative amount,
numericCasts are also not necessary. The result type is the type of the shifted value.

toIntMax() and init(_:IntMax) have been deprecated numericCast converts directly


between different integer types without going through the maximum width integer. (SE0104)

Subscript declarations can now be defined to have generic parameter lists. Example:

extension MyContainer {
subscript<T : MyKeyConvertible>(key: T) { }
}

(SE0148)

SQLite APIs can now be imported into Swift under the module name SQLite3. (18640410)

Sequence has an associated type Element that is equivalent to Iterator.Element. The value
of this associated type can be inferred from existing Sequence conformance. Code that already
declares a type of Element may need to be altered to resolve conflicts. (32186094)

Slicing a raw buffer no longer results in the same raw buffer type. Specifically,
Unsafe[Mutable]BufferPointer.SubSequence now has type
[Mutable]RandomAccessSlice<Unsafe[Mutable]RawBufferPointer>. Therefore, indexing
into a raw buffer slice is no longer zero-based. This is required for raw buffers to fully conform to
generic Collection. Changing the slice type resulted in the following behavioral changes:

Passing a region within a buffer to another function that takes a buffer can no longer be done
via subscript:

Incorrect: takesRawBuffer(buffer[i..<j])

This now requires explicit initialization, using a rebasing: initializer, which converts from a slice
to a zero-based Unsafe[Mutable]RawBufferPointer:

Correct: takesRawBuffer(UnsafeRawBufferPointer(rebasing: buffer[i..<j]))

Subscript assignment directly from a buffer no longer compiles:

Incorrect: buffer[n..<m] = smaller_buffer

This now requires creation of a slice from the complete source buffer:

Correct: buffer[n..<m] = smaller_buffer.suffix(from: 0)

Copyright 2017 Apple Inc. All rights reserved. Page 52 of 61


Xcode 9 beta 2 Relea
UnsafeRawBufferPointers slice type no longer has a nonmutating subscript setter. So
assigning into a mutable let buffer no longer compiles:

Incorrect:

let slice = buffer[n..<m]


slice[i..<j] = buffer[k..<l]

The assigned buffer slice now needs to be a var.

Correct:

var slice = buffer[n..<m]


slice[i..<j] = buffer[k..<l]

(SE0138 Addendum)

All Core Foundation types implicitly conform to the Equatable and Hashable protocols.

This change applies in both Swift 3.2 and Swift 4.0. If you were previously adding these
conformances in an extension, conditionalize the extension by using the following pattern:

#if swift(>=3.2)
// Equatable and Hashable are provided by Swift.
#else
extension TheCFTypeICareAbout: Hashable {
static func ==(left: TheCFTypeICareAbout, right:
TheCFTypeICareAbout) -> Bool {
return CFEqual(left, right)
}
var hashValue: Int {
return CFHash(self)
}
}
#endif

(SR2388)

In Swift 4.0, if an Objective-C class has a designated initializer that cant be imported into Swift,
any Swift subclasses of that class will not inherit any convenience initializers. (31563662)

A new protocol RangeExpression is now used to unify all range types (such as
CountableRange, ClosedRange), and new one-sided ranges (such as PartialRangeUpTo)
have been added. Any type that conforms to RangeExpression can now be used to slice a
collection. For example:

Copyright 2017 Apple Inc. All rights reserved. Page 53 of 61


Xcode 9 beta 2 Relea
let numbers = [10, 20, 30, 40, 50, 60]
if let i = numbers.index(of: 40) {
print(numbers[..<i])
}
// Prints "[10, 20, 30]"

Countable partial ranges can be used as sequences. For example:

let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"


let asciiTable = zip(65, alphabet)
for (code, letter) in asciiTable {
print(code, letter)
}
// "65 A"
// "66 B"
// "67 C"
//
// "89 Y"
// "90 Z"

(32260581)

Protocol composition types can now contain one or more class type terms, forming a class-
constrained protocol composition.

For example:

protocol Paintable {
func paint()
}

class Canvas {
var origin: CGPoint
}

class Wall : Canvas, Paintable {


func paint() { }
}

func render(_: Canvas & Paintable) { }

render(Wall())

Note that class-constrained protocol compositions can be written and used in both Swift 3 and
Swift 4 mode.

Generated headers for Swift APIs will map class-constrained protocol compositions to
Objective-C protocol-qualified class types in both Swift 3 and Swift 4 mode (for instance,

Copyright 2017 Apple Inc. All rights reserved. Page 54 of 61


Xcode 9 beta 2 Relea
NSSomeClass & SomeProto & OtherProto in Swift becomes NSSomeClass <SomeProto,
OtherProto> in Objective-C).

Objective-C APIs which use protocol-qualified class types differ in behavior when imported by a
module compiled in Swift 3 mode and Swift 4 mode. In Swift 3 mode, these APIs will continue to
import as protocol compositions without a class constraint (eg, SomeProto & OtherProto).

In Swift 4 mode, protocol-qualified class types import as class-constrained protocol


compositions, for a more faithful mapping of APIs from Objective-C to Swift.

Note that the current implementation of class-constrained protocol compositions lacks three
features outlined in the Swift evolution proposal:

In the evolution proposal, a class-constrained protocol composition is permitted to contain


two different classes as long as one is a superclass of the other. The current
implementation only allows multiple classes to appear in the composition if they are
identical.

In the evolution proposal, associated type and class inheritance clauses are generalized to
allow class-constrained protocol compositions. The current implementation does not allow
this.

In the evolution proposal, protocol inheritance clauses are allowed to contain a class,
placing a requirement that all conforming types are a subclass of the given class. The
current implementation does not allow this.

These missing aspects of the proposal can be introduced in a future release without breaking
source compatibility with existing code. (SE0156)

NSNumber is more strict about the result of bridging some of its values to corresponding Swift
value types.

Specifically, using an as? cast will return nil if the value stored by NSNumber does not fit into
the requested Swift value type. For example, NSNumber(2) as? Bool will return nil, but
NSNumber(1) as? Bool will return true.

If you wish to force a cast and ignore this behavior, use the appropriate conversion function on
NSNumber instead. For example, myNumber.boolValue. (SE0170)

Swift Compiler

Protocols and associated types can now contain where clauses that provide additional
restrictions on associated types. For example:

Copyright 2017 Apple Inc. All rights reserved. Page 55 of 61


Xcode 9 beta 2 Relea
protocol StringRepresentable: RawRepresentable
where RawValue == String { }

protocol RawStringWrapper {
associatedtype Wrapped: RawRepresentable
where Wrapper.RawValue == String
}

(SE0142)

The Swift compiler now lazily and implicitly imports outer modules when importing a submodule
after Swift finishes parsing the bridging header. This is a behavior change from previous
releases where the import happened eagerly. As a result, some bridging headers that might
have relied on the eager implicit import (such as by directly using a type defined in the outer
module) will no longer compile; they will need to either forward-declare such definitions or
explicitly import the outer module. (30615193)

In order for default argument expressions to be inlined into the caller in a future version of Swift,
they must not reference any declarations that have less access than the enclosing function. For
example:

// Before
private func computeTheBestInteger() -> Int {
return 4
}
public func useAnInteger(_ x: Int =
computeTheBestInteger().absoluteValue) {
print(x)
}

There are multiple ways to modify existing code to satisfy this condition:

Option 1: Change the non-public reference to be public.

public func computeTheBestInteger() -> Int {


return 4
}
public func useAnInteger(_ x: Int =
computeTheBestInteger().absoluteValue) {
print(x)
}

Option 2: Add a helper function.

Copyright 2017 Apple Inc. All rights reserved. Page 56 of 61


Xcode 9 beta 2 Relea
private func computeTheBestInteger() -> Int {

}
return 4

public func defaultXForUseAnInteger() -> Int {


return computeTheBestInteger().absoluteValue
}
public func useAnInteger(_ x: Int = defaultXForUseAnInteger()) {
print(x)
}

Option 3: Use a sentinel.

private func computeTheBestInteger() -> Int {


return 4
}
public func useAnInteger(_ xOrNil: Int? = nil) {
let x = xOrNil ?? (computeTheBestInteger().absoluteValue)
print(x)
}

(32189807)

In Swift 4 mode, a declaration is inferred to be @objc where it is required for semantic


consistency of the programming model. Specifically, it is inferred when:

The declaration is an override of an @objc declaration


The declaration satisfies a requirement in an @objc protocol
The declaration has one of the following attributes: @IBAction, @IBOutlet,
@IBInspectable, @GKInspectable, or @NSManaged

Additionally, in Swift 4 mode, dynamic declarations that dont have @objc inferred based on the
rules above will need to be explicitly marked @objc.

Swift 3.2 retains the more-permissive Swift 3 rules for inference of @objc within subclasses of
NSObject. However, the compiler will emit warnings about places where the Objective-C entry
points for these inference cases are used, such as in a #selector or #keyPath expression, via
messaging through AnyObject, or direct uses in Objective-C code within a mixed Swift and
Objective-C project. The warnings can be silenced by adding an explicit @objc. Uses of these
entry points that are not statically visible to the compiler can be diagnosed at runtime by setting
the environment variable SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT to a value between 1 and
3 then testing the application. (SE0160)

In Swift 4 mode, Swifts type system properly distinguishes between functions that take one
tuple argument, and functions that take multiple arguments. (SE0110)

Swift Package Manager

Copyright 2017 Apple Inc. All rights reserved. Page 57 of 61


Xcode 9 beta 2 Relea
A package can declare the minimum version of the Swift tools (including the Swift package
manager) that are needed in order to use the package. (SE0152)

The package manifest API has been improved as documented in SE0158: Package Manager
Manifest API Redesign. Packages using the old API can still be parsed, but by using the new
minimum tools version functionality described above, new versions of package manifests can
opt into the new API. (SR3949)

A package can choose whether the Swift source files in it should be compiled using Swift 3 or
Swift 4 syntax. (SE0151)

A package can explicitly declare the products that the package vends to its clients (previously,
they were inferred based on the targets in the package) as described in SE0146: Package
Manager Product Definitions. (SR3606)

Custom directory layouts are supported for the source files in a package. Specifically, each
target in a package can specify the path of the directory that contains the source files for that
target. (SE0162, SR29)

In order to support custom directory layouts, the location of the LinuxMain.swift file that lists
the unit test targets for use on Linux is more flexible. Specifically, the Swift Package Manager
will look for LinuxMain.swift in any directory that contains a test target directory, and in any
ancestor thereof (up to the package root directory). (31585721)

Package dependencies can now refer to a branch name instead of a tagged version. This is only
intended for dependencies on packages that are closely coupled with all of their clients. Tagged
versions of a package must not depend on any branches. (SE0150, SR666)

The package edit command has a --path option that lets users manage their own checkout
of the remote package, supporting top-of-tree development of a related set of packages.
(SE0149, SR3709)

The pinning feature has been removed. In its place, packages now produce a
Package.resolved file containing resolved dependency versions, which can optionally be
committed to Git to share those versions. When present, dependency resolution will prefer the
recorded dependency versions. The swift package fetch command has been replaced with
a swift package resolve command. Related dependency resolution behaviors have been
improved. (SE0175)

On macOS, package manifest interpretation and package builds now occur in a sandbox which
prevents network access and file system modification. This helps mitigate the effect of
maliciously crafted manifests. (31107213)

The swift package edit command resolves package dependencies before putting the
package into edit mode, so that any dependency resolution errors are detected before changes
are made. (29772779)

Copyright 2017 Apple Inc. All rights reserved. Page 58 of 61


Xcode 9 beta 2 Relea
The --branch option of the swift package edit command is optional. If no branch is
provided, the Git repository is put into detached head state. (30120243)

The package manager emits clearer and more informative error messages for many problems.
(29772725)

On macOS, building a package only requires the Xcode Command Line Tools, not the full Xcode
IDE, to be installed. Running unit tests still requires the Xcode IDE to be installed. (30813768)

The error message that is shown when package dependencies cannot be satisfied now explains
which dependency requirements are in conflict. (SR4072, SR4237)

Generated Xcode projects use stable and readable object identifiers for objects such as targets,
allowing Xcode schemes to continue referencing the same objects even when the project is
regenerated with modified contents. (31019219)

Cloned package dependencies will have read-only file permissions, reducing the risk of
unintentional changes. When a package is put into edit mode, write permission is added for the
files in that package. (31286403)

C targets are now linked statically by default. This can be controlled using the type argument to
a .library() initializer in the new product API. (29730882)

Copyright 2017 Apple Inc. All rights reserved. Page 59 of 61


Xcode 9 beta 2 Relea
Resolved in Xcode Xcode 9 beta Apple LLVM
and Swift Compilers
Apple LLVM Compiler

The -Wdocumentation warning allows the use of \param and \returns documentation
directives in the documentation comment for a declaration with a function or a block pointer
type. (24978538)

The compiler does not warn about unreachable __builtin_unreachable() statements.


(28397146)

The compiler is aware of editor placeholders that are inserted by Xcode when inserting a code-
completion result. It can provide better diagnostics and recover better when parsing files with
editor placeholders. Several errors that were caused by editor placeholders are now suppressed
in live-issues in Xcode. (31581400)

The compiler will not crash when building with clang modules and using different -Werror flags
for different source files. (32338950)

The compiler will not crash when building with clang modules and using a precompiled header.
(32359950)

Copyright 2017 Apple Inc. All rights reserved. Page 60 of 61


Xcode 9 beta 2 Relea
Swift Compiler

A crash in the Swift compiler when an Objective-C property is redeclared with a different type or
nullability has been resolved. This may lead to certain Objective-C members being imported
differently than before, including some properties being imported as read-only (if the setter is
not consistent with the original property), and others no longer being imported as methods.
(30785976)

Covariant method overrides in classes are now fully supported, fixing many crashes and
compile-time assertions when defining or calling such methods.

For example:

class Bed {}
class Nook : Bed {}

class Cat<T> {
func eat(snack: T) {}
func play(game: String) {}
func sleep(where: Nook) {}
}

class Dog : Cat<(Int, Int)> {


// 'T' becomes concrete
override func eat(snack: (Int, Int)) {}

// 'game' becomes optional


override func play(game: String?) {}

// 'where' becomes a superclass


override func sleep(where: Bed) {}
}

SR1529

Swift Package Manager

The package manager properly errors if there is a parsing issue in the manifest of an edited
package. (31085712)

Copyright 2017 Apple Inc. All rights reserved. Page 61 of 61

Potrebbero piacerti anche