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?
-
1@Kishyr I think it's because the Metal framework is only available for running on the actual device atm.– AkyCommented Jun 6, 2014 at 16:11
-
@Aky, but he said that he tried it in a normal swift file. My opinion is that this is a bug.– 67cherriesCommented Jun 6, 2014 at 16:14
-
@68cherries I've run some Metal-related sample code (available on the developer portal) on my device and it's worked for me, at least.– AkyCommented Jun 6, 2014 at 16:17
-
Make sure that you have an iOS playground, by default you will get an OS X playground.– PascalCommented Jun 6, 2014 at 18:03
-
@Pascal this doesn't work in iOS playgrounds either. I think Metal may still be work in progress for Swift but I can't find a source.– Charlie EganCommented Jun 7, 2014 at 20:43
3 Answers
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.
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:
- SceneKit
- SpriteKit
- OpenGL
- Metal
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'"
IOS simulator don't support Metal, so you need to compile for iOS-device directly.
(Set "Your App -> iOS Device").