Skip to content

Fix syncedFolder path when projectDirectory differs - #1636

Open
Ckitakishi wants to merge 1 commit into
yonaskolb:masterfrom
Ckitakishi:fix-synced-folder-project-directory-path
Open

Fix syncedFolder path when projectDirectory differs#1636
Ckitakishi wants to merge 1 commit into
yonaskolb:masterfrom
Ckitakishi:fix-synced-folder-project-directory-path

Conversation

@Ckitakishi

Copy link
Copy Markdown

Description

When the spec file and the generated project are in different directories, a syncedFolder source gets a path relative to the spec directory instead of the project directory. Xcode resolves that path from the xcodeproj location, so it points at a directory that doesn't exist. The synced folder is then silently treated as empty: the target compiles zero files but still reports BUILD SUCCEEDED.

# Modules/Shared/FooKit/project.yml
targets:
  FooKit:
    type: framework
    platform: iOS
    sources:
      - path: Sources
        type: syncedFolder
$ xcodegen generate --spec Modules/Shared/FooKit/project.yml --project .

# actual:   path = Sources;                        (resolves to <root>/Sources, doesn't exist)
# expected: path = Modules/Shared/FooKit/Sources;

The syncedFolder branch computes the relative path from project.basePath, which is the spec directory. Paths written into the pbxproj need to be relative to the output directory instead. Regular groups already handle this through resolveGroupPath, which uses the basePath property (projectDirectory ?? project.basePath).

Added a regression test that fails without the fix.

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.

1 participant