Is is possible to enable Xcode autocompletion of basic Swift language code snippets like 'iflet' in a top level context ? If yes, then how?
Use case: Just experimenting with simple basic Swift syntax in the main.swift file of a new Command Line Tool project. Just minimalist tinkering stuff that is not required to be inside of struct
, func
, etc.
main.swift Xcode template
import Foundation
print("Hello, World!")
In the top level context of a freshly created main.swift , ifl
does not autocomplete to anything useful:
However, inside a func
inside a struct
, then ifl
autocompletes to an 'If-Let Statement':
Another use case: Or, maybe just doing some simple math. A quick calculator.
Another use case: Or, maybe just demonstrating a basic "if statement" to a young not-yet-a-programmer without complicating the demo with other programming constructs.
A workaround is to manually create a duplicate user entry and then change the availability scope.
Some observations of this workaround approach are:
.codesnippet
file can be moved to (add to) another Xcode installation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.