Kishyr Ramdial
Kishyr Ramdial

Reputation: 945

How do you import Metal in Swift?

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?

Upvotes: 9

Views: 8284

Answers (3)

vkalit
vkalit

Reputation: 647

IOS simulator don't support Metal, so you need to compile for iOS-device directly.

(Set "Your App -> iOS Device").

Upvotes: 1

Colin
Colin

Reputation: 1978

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.

Upvotes: 17

Abdullah Ossama Omari
Abdullah Ossama Omari

Reputation: 524

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'"

Upvotes: 3

Related Questions