【发布时间】:2021-02-06 22:35:09
【问题描述】:
我想为 SwiftUI 视图创建一个自定义 Xcode 游乐场模板。 使用什么文件格式? 我怎样才能找到例子? 我应该把这些文件放在哪里?
【问题讨论】:
标签: xcode swiftui swift-playground xcode-template
我想为 SwiftUI 视图创建一个自定义 Xcode 游乐场模板。 使用什么文件格式? 我怎样才能找到例子? 我应该把这些文件放在哪里?
【问题讨论】:
标签: xcode swiftui swift-playground xcode-template
您可以通过在路径复制文件模板来制作模板
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/Playground
请注意,每个平台都有自己的模板。
TEMPLATE_NAME.xctemplate和TEMPLATE_NAME___FileMenu.xctemplate
到 ~/Library/Developer/Xcode/Templates/File Templates 并根据需要重命名。(你可以把它放在子文件夹SwiftUI,它的名字将用于将你的模板与其他模板分开)
TemplateInfo.plist 中的Name 字段
___FILEBASENAME___.playground 文件中(您可以使用占位符根据参数生成代码,例如,请参见article)这里以我的模板为例:https://github.com/DanSkeel/XcodeTemplates/tree/main/Playground
注意:
...___FileMenu.xctemplate文件将在您从打开的 Playground 创建新文件时使用。
【讨论】: