【问题标题】:How to create custom SwiftUI View playground template in Xcode?如何在 Xcode 中创建自定义 SwiftUI View Playground 模板?
【发布时间】:2021-02-06 22:35:09
【问题描述】:

我想为 SwiftUI 视图创建一个自定义 Xcode 游乐场模板。 使用什么文件格式? 我怎样才能找到例子? 我应该把这些文件放在哪里?

【问题讨论】:

    标签: xcode swiftui swift-playground xcode-template


    【解决方案1】:

    您可以通过在路径复制文件模板来制作模板

    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/Playground

    请注意,每个平台都有自己的模板。

    1. 复制两个文件夹TEMPLATE_NAME.xctemplateTEMPLATE_NAME___FileMenu.xctemplate~/Library/Developer/Xcode/Templates/File Templates 并根据需要重命名。

    (你可以把它放在子文件夹SwiftUI,它的名字将用于将你的模板与其他模板分开)

    1. 要更改模板的显示名称,您可以更改TemplateInfo.plist 中的Name 字段
    2. 将模板的代码粘贴到___FILEBASENAME___.playground 文件中(您可以使用占位符根据参数生成代码,例如,请参见article

    这里以我的模板为例:https://github.com/DanSkeel/XcodeTemplates/tree/main/Playground

    注意:...___FileMenu.xctemplate 文件将在您从打开的 Playground 创建新文件时使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-17
      • 1970-01-01
      • 2017-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-10
      • 1970-01-01
      相关资源
      最近更新 更多