This post describes an error in the parsing of extended delimiter strings in the Xcode 14.2 Swift editor, but not in the compiler. The problem occurs with an extended delimiter string with a backslash at the end: #"xyzzy\"#. The editor treats the backslash as escaping the closing quote mark, and thus sees the string as unclosed. The bug is manifested in the syntax coloring of text following the string on the same line, and also in the indentation of subsequent lines if there were opening or closing parentheses or braces following the string on the same line.
Here is a trivial command-line app main.swift that illustrates the bug.
print("Hello, World!")
print(#"Hello, World!\ "#)
print(#"Hello, World!\"#)
print("I'm not dead yet")
This screen shot shows the editor misbehavior:
Note that the color of the closing parenthesis on line 3 shows that the editor thinks it is part of the string, and that the indentation of line 4 shows that the editor did not recognize the closing parenthesis on line 3.
The execution output shows that the bug is limited to the editor — the program compiled and ran correctly:
Post
Replies
Boosts
Views
Activity
Xcode 14.0.1 running on macOS Monterey 12.6.
I have a class MeetingDirectory that defines two subscript functions:
public subscript(_ date: String) -> ValueOrMessage<Meeting> { ... }
public subscript(_ date: String, visit: CaseID) -> ValueOrMessage<Meeting> { ... }
In my DocC extension file for this class, I want to generate links to the documentation for both subscripts.
Problem 1: I type two backticks and Xcode offers autocompletions for all the class's public functions, including two subscript functions; but the subscript functions are each presented in the autocomplete list as just subscript with no additional information — there is no way to differentiate them.
Problem 2: By trial-and-error, I find that one subscript expands into subscript(_:) and the other one expands into subscript(_:visit:), as I would have expected. So my topics list looks like:
### Getting a Specific Meeting
- ``subscript(_:)``
- ``subscript(_:visit:)``
But when I compile the documentation, the subscript(_:visit:) line gets this warning: “Topic reference 'subscript(_%3Avisit%3A)' couldn't be resolved. No local documentation matches this reference.” and subscript(_:visit:) doesn't show up in the “Getting a Specific Meeting” topic section. Instead, it shows up in the default “Subscripts” section, with the signature
subscript(String, CaseID) -> ValueOrMessage<Meeting>
and if you click on the link, the title on the function documentation page has the signature subscript(_:_:) (although the “Declaration” and “Parameters” sections on the function documentation page are correct).
Problem 3: So I tried writing the symbol reference as subscript(_:_:) instead. Now the documentation compiles without errors, and both subscript functions show up under “Getting a Specific Meeting”, but, as you might expect, it still shows up with the (_:_:) signature.
Is there a way to use NSPathControl or something equivalent in SwiftUI on Mac?
I'm asking about this here, because I only get this behavior in Safari — it works as I expect in Chrome.
Safari 14.0.3
macOS Mojave 10.14.6
I have an S3 static website, wiltonzba.org, served via CloudFront. The site has a subdirectory, ordinance, containing both the current and archived versions of a zoning ordinance:
ordinance/
index.html
ordinance_01.html
ordinance_02.html
...
ordinance_2019/
index.html
ordinance_01.html
ordinance_02.html
...
ordinance_2020/
index.html
ordinance_01.html
ordinance_02.html
...
...
ordinance_2021/ - redirects up to ordinance/
Since 2021 is the current version, I want references to ordinance/ordinance_2021/ to redirect to ordinance/. I’m using an S3 conditional redirect rule:
[
{
"Condition": {
"KeyPrefixEquals": "ordinance/ordinance_2021/"
},
"Redirect": {
"ReplaceKeyPrefixWith": "ordinance/"
}
}
]
(Next year I’ll remove the redirect rule, create the ordinance_2021 subdirectory, copy this year’s version into it, and create a redirect rule for ordinance_2022.)
This sort of works.
I create a new browser window (Safari 14 on macOS Mojave), and type the link wiltonzba.org/ordinance/ordinance_2021/index.html into the address bar. The page loads properly and the browser address field shows “https://wiltonzba.org/ordinance/index.html”.
The page has a link with the text 2021 and the HREF ordinance_2021/index.html. If I click on it, I get exactly the same result.
Now if I click on the 2021 link, the (same) page loads properly, but the browser address field shows “Not Secure — http://wiltonzba.org/ordinance/index.html”.
Now if I click on the 2021 link, the browser address field shows “https://wiltonzba.org/ordinance/ordinance_2021/index.html”. The page HTML loads, but the associated CSS and images don’t load, because they are referenced with relative “up one level” URLs.
Is this a Safari bug? (As I noted above, this works in Chrome.)
I have a struct that can throw an error.
If I just wanted to know if it had succeeded or not, I would use
guard let try? thing = Thing()
else { terminate }
But I want to catch the error so that I can give a useful message before terminating, and I don't think I can do/catch in a guard statement.. The best I can come up with is
let thing: Thing
do
		try thing = Thing()
catch ... {
		give useful message
		terminate
}
That isn't as attractive in several ways. Is there a better way?
I've created a simple Swift module, built as an Xcode framework.
I have a Swift script (text file starting with #! /usr/bin/swift) that imports my module (import moduleName).
The question is, where does Swift look for that framework?
I can force the issue by adding "-F <directory containing the framework>" to the command line, but I don't really want to hard-code the specific path into my script.
I understand that I could put the framework into /Library/Frameworks, but this is just a personal hack, not that needs to be exposed at the system level.
Are there user-level directories that Swift will also look in by default? Is there an environment variable I can define?
iPhone 11 Pro
iOS 13.5.1
MacBook Air 2020
macOS Catalina 10.15.5
Mac Safari 13.1.1
Develop Menu is enabled in Mac Safari
Safari > Advanced > Web Inspector is enabled on the iPhone.
I have Safari open on the Mac, and a web page open in Safari on the iPhone.
I connect the iPhone to the MacBook with a USB/Lightning cable.
I get the "Trust this Computer?" dialog, click "Trust", and enter my passcode.
I open the Develop menu in Safari on the Mac.
My iPhone DOES NOT appear in the develop menu.
I tried resetting Location & Privacy in the iPhone Settings, but it doesn't make any difference.