【问题标题】:How to load .sks files from a Swift Playground that is embedded in a workspace?如何从嵌入工作区的 Swift Playground 加载 .sks 文件?
【发布时间】:2018-01-18 22:30:03
【问题描述】:

在 fileNamed 的文档中:从 .sks 文件加载场景时说:

The name of the file, without a file extension.
The file must be in the app’s main bundle and have a .sks filename extension.

我在游乐场的使用:

if let scene = PlanetsScene(fileNamed: "PlanetsScene") 

有什么解决方法吗?在 Playground 中运行的东西似乎无法访问应用程序主包。我已将我的 Playground 嵌入到项目工作区中,并且可以访问我设置为公共的所有其他类,但似乎无法加载 .sks 文件。

【问题讨论】:

  • 如果您使用的是 Xcode 9,创建一个新的 Playground 项目并选择 Game 作为模板将生成使用 .sks 文件的代码。
  • 是的,但这不能在我的项目中使用实际的 .sks 文件,这正是我想要的。我不想复制我所有的 sks 文件..
  • 如果您在项目旁边使用工作区中的游乐场,则必须将该代码转换为动态框架。比您可以在您的应用程序和游乐场中导入它。您只需将任何资产添加到框架包中。查看此演讲:youtube.com/watch?v=DrdxSNG-_DEuseyourloaf.com/blog/adding-playgrounds-to-xcode-projects
  • 是的,它是一个框架,问题是该方法不允许指定捆绑包,我将资产作为框架目标的成员。

标签: ios xcode sprite-kit swift-playground


【解决方案1】:

您能否将指向原始 *.sks 文件的符号链接放入 Playground 的 Resources 中?

【讨论】:

  • 让你让它工作了吗?我尝试时似乎不起作用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-08-22
  • 1970-01-01
  • 2021-03-09
  • 1970-01-01
  • 2017-02-09
  • 1970-01-01
  • 2011-08-01
相关资源
最近更新 更多