I have my project running perfectly fine on Xcode 16. However, in Xcode 26 it doesn't build due to an error that I do not understand. I have three files that pertain to this error:
// FriendListResponse.swift
import Foundation
struct FriendListResponse: Decodable {
var friendships: [Friendship]
var collections: [FriendCollection]
}
// Friendship.swift
import Foundation
struct Friendship: Decodable {
var createdAt: String
var friendId: Int
var friendUserId: Int // user ID of the friend
var friendUsername: String
var id: Int
var tagNames: [String]
}
// FriendCollection.swift
struct FriendCollection: Decodable {
var id: Int
var permalink: String
var tagNames: [String]
var title: String
}
On the first file, FriendListResponse.swift
, I am the simple error message "circular reference." I do not understand how these self-contained structs could create a circular reference. Although I have other data types in my project, none of them are even referenced in these files except for Friendship
and FriendCollection
.
The FriendListResponse
is a struct that is created from JSON values that are fetched from an API. This is the function that fetches the JSON:
public static func listFriends(username: String) async throws -> [Friendship] {
let data = try await sendGETRequest(
url: "people/\(username)/friends/list.json"
)
print(String(data: data, encoding: .utf8)!)
let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
let wrapper = try decoder.decode(FriendListResponse.self, from: data)
return wrapper.friendships
}
// Note: the function sendGETRequest is just
// a function that I have created that takes a set
// of parameters and returns a data object
// using the HTTP GET protocol. I don't think
// that it is related to this issue. However, if you
// think that it is, I can share the code for that.
This error has also happened in a few other cases within contained networks of my data structure.
I do not know why this error is only appearing once I launch Xcode 26 beta with my project files. I would think that this error also would appear in Xcode 16.4.
Any help would be greatly appreciated in my process to compile my project on Xcode 26!
FYI, I’ve confirmed that the rogue circular reference diagnostic is a bug, but the fix missed the Xcode 26.0b2 bus. See here.
as I potentially integrate more concurrency later in development, will there be any issues directly stemming from using nonisolated as opposed to MainActor?
Potentially? Of course.
This is one of those ‘everything in engineering is a trade-off’ situations. You have two options, both of which you can make work, but it’s hard to know for such which will be the best in the long term.
My general advice for app developers is to do everything on the main actor until you have hard evidence that you need something else [1]. Given that, I’d probably use the main actor conformance approach, rather than the nonisolated
approach. However, I can in no way guarantee that you won’t need to change that as your app evolves.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] This has been my policy for many years, since long before Swift concurrency, or even Swift! I’m very happy to see that it’s now aligned with Swift’s approachable concurrency effort.