Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add path to XcodeProj and XCWorkspace #892

Merged
merged 2 commits into from
Dec 21, 2024

Conversation

ajkolean
Copy link
Contributor

Resolves tuist/XcodeGraph#87 (comment)

Short description 📝

This PR introduces an optional projectPath property to XcodeProj, allowing the project to be initialized and managed without requiring a file system path. It maintains full backward compatibility for existing users while offering more flexibility for in-memory project constructions or integrations with path management logic outside of XcodeProj.

Solution 📦

The projectPath property is now optional. When loading from a file system path, projectPath is set automatically. If users create XcodeProj instances in memory using the new initializer, projectPath can remain nil. This approach preserves existing behavior while enabling new use cases, such as working with XcodeProj in environments where a project might not yet exist on disk.

Implementation 👩‍💻👨‍💻

  • Introduce projectPath: Path? as an optional property in XcodeProj.
  • Update init(path:) to set projectPath when loading from disk.
  • Add a new initializer that allows creating XcodeProj instances without a projectPath.
  • Include projectPath in the equality check to distinguish between projects referencing different directories.
  • Retain backward compatibility and do not alter existing file loading or writing behavior.

Copy link
Member

@fortmarek fortmarek left a comment

Choose a reason for hiding this comment

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

Just some minor comments 🙂

Copy link
Member

@fortmarek fortmarek left a comment

Choose a reason for hiding this comment

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

I'd also add path to the XCWorkspace: https://github.com/tuist/XcodeProj/blob/main/Sources/XcodeProj/Workspace/XCWorkspace.swift

I'll leave it up to you if you wanna do it in this PR or in a subsequent one.

@fortmarek fortmarek changed the title feat: add optional projectPath to XcodeProj feat: add path to XcodeProj and XCWorkspace Dec 21, 2024
@fortmarek
Copy link
Member

We also really need to migrate the paths from PathKit to our Path. The needed conversion between the paths is unnecessary pain in the XcodeGraphMapper

@fortmarek fortmarek merged commit 2f6a810 into tuist:main Dec 21, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants