xcode 你如何在 Swift 中导入 Metal?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24086194/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you import Metal in Swift?
提问by Kishyr Ramdial
Whenever I try to import Metal
in my Swift file or a playground, Xcode says "No such module 'Metal'". Is this a Beta 1 bug?
每当我尝试import Metal
在我的 Swift 文件或 Playground 中使用时,Xcode 都会说“没有这样的模块‘金属’”。这是 Beta 1 错误吗?
回答by Colin
This is a platform issue, not a Swift issue. If you manually inspect the platform SDKs inside Xcode, you'll see that the Metal.framework only exists in the iOS8 SDK. That means you can only link to the framework when your code is going to run on an actual iOS device, and since playgrounds don't run on the device, there's no way to link to the framework.
这是平台问题,而不是 Swift 问题。如果您手动检查 Xcode 中的平台 SDK,您将看到 Metal.framework 仅存在于 iOS8 SDK 中。这意味着当您的代码要在实际的 iOS 设备上运行时,您只能链接到框架,并且由于 Playgrounds 不在设备上运行,因此无法链接到框架。
回答by Abdullah Ossama Omari
if you create a new project ,and you choose game(from the menu that tells you what app do u want to build .
如果您创建一个新项目,然后选择游戏(从告诉您要构建什么应用程序的菜单中)。
after you click next, you will have an option that you will not miss which is GameTechnology you have 4 choices:
单击下一步后,您将有一个不容错过的选项,即 GameTechnology,您有 4 个选择:
- SceneKit
- SpriteKit
- OpenGL
- Metal
- 场景套件
- 精灵套件
- OpenGL
- 金属
when you choose metal it will create a n project with metal framework imported , but under that import statement you will find a comment that says that the metal framework is still not available and apple are still improving it , also there will be an error that say "No such module 'Metal'"
当您选择金属时,它会创建一个导入金属框架的项目,但是在该导入语句下,您会发现一条评论说金属框架仍然不可用并且苹果仍在改进它,还会出现一个错误说“没有这样的模块‘金属’”
回答by vkalit
IOS simulator don't support Metal, so you need to compile for iOS-device directly.
IOS模拟器不支持Metal,需要直接为iOS设备编译。
(Set "Your App -> iOS Device").
(设置“您的应用程序 -> iOS 设备”)。