Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Sources/XcodeProj/Project/XcodeProj.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ extension XcodeProj: Writable {
/// - Parameter override: if workspace should be overridden. Default is true.
/// If false will throw error if workspace already exists at the given path.
public func writeWorkspace(path: Path, override: Bool = true) throws {
guard let p = path.glob("*.xcworkspacedata").first, workspace.data != (try? XCWorkspaceData(path: p)) else { return }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a few caveats we should be mindful here:

  • The xcworkspacedata serialisation is a responsibility of the XCWorkspace class, a check of this nature can potentially go there, as that component knows the exact path and there wouldn't be a need to search / glob for it :)
  • XCWorkspace deletes and recreates the underlying contents.xcworkspacedata file when override is set, which I believe may be the source of the issue - this is also the same when viewing a Workspace rather than a standalone Project
if override, dataPath.exists {
   try dataPath.delete()
}
  • We need to mindful of not reloading and deserialising content from disk to verify equality as that could potentially be expensive for large workspaces (needs benchmarking), we may be able to compare the raw data without deserialisation - From my quick test locally on a test fixture with 100 projects it didn't have as big of an impact as I feared it would <1%

try workspace.write(path: XcodeProj.workspacePath(path), override: override)
}

Expand Down