O'Reilly logo

Learning Swift™ Programming by Jacob Schatz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Bridging the Gap to Objective-C

Swift allows you to bring in Objective-C code and use it directly in your Swift code. You can create classes, enums, and structs—and anything else you want. If something is not available in Swift that is available in Objective-C, you can easily make it available yourself by bridging. In this case, you want to add a low-level library called SIMD.h to your game. But before you can add it, you need to bridge it to Swift. In SIMDHelper.h, add the following content:

#import <Foundation/Foundation.h>#import <SceneKit/SceneKit.h>#import <simd/simd.h>@interface SIMDHelper : NSObject{}+ (SCNVector3) vector_maker:(float)followMeX :(float)followMeY   :(float)followMeT :(SCNVector3)cameraSCNVector3 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required