Save packages downloaded by SPM into project GIT using Xcode 11

房东的猫 提交于 2019-12-10 09:41:09

问题


I started using new Xcode 11 which integrates SPM.

I added first dependency to my project:

but detected that files are not fetched into my project folder but into Xcode's cache:

I would like to commit all my dependencies files into my main project repository so my question is:

Is it possible to change location of fetched packages via SPM using Xcode 11?


回答1:


SwiftPM integration has been setup to prevent this. It clones the files into a DerivedData/ProjectName-[RandomStuff]. You should commit your Package.resolved into the repo to ensure that you get the same version of each dependency across clones of the project.




回答2:


It's somewhat possible, although the solution isn't necessarily a good or great practice, so I can't recommend.

  1. Set the DerivedData in workspace settings to be relative to the workspace.
  2. Add gitignore rules such that the workspace/WORKSPACE_NAME_DIR/SourcePackages/checkouts and related files are includes. Maybe best to ensure repositories directory is not included.
  3. Add a Run Script phase to remove .git and .gitignore files in the checkouts directory.

Obviously, this is fragile largely through fighting the way SPM works. The workspace settings are per person so it's not great in teams.



来源:https://stackoverflow.com/questions/57819160/save-packages-downloaded-by-spm-into-project-git-using-xcode-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!