I've been messing around with swift and trying to get a Physicsworld working.
This is the error I get "Undefined symbols for architecture i386: "_OBJC_CLASS_$_SCNPhysicsWorld", referenced from: __TFC3sk218GameViewController11viewDidLoadfS0_FT_T_ in GameViewController.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) "
I assume it has to do with linking or importing a library that I'm not, but I have added everything that I could find that I thought might fix it (found in other posts on game kit) Does anyone know what this might be? Thanks.
There is a bug here with the Obj-c / Swift bridge.
While you wait for a solution, you can work around this by creating a temporary bridge for yourself:
Add the following class:
PhysWorldBridge.h
#import <Foundation/Foundation.h>
#import <SceneKit/SceneKit.h>//
@interface PhysWorldBridge : NSObject
- (void) physicsWorldSpeed:(SCNScene *) scene withSpeed:(float) speed;
- (void) physicsGravity:(SCNScene *) scene withGravity:(SCNVector3) gravity;
@end
PhysWorldBridge.m
#import "PhysWorldBridge.h"
@implementation PhysWorldBridge
- (id) init
{
if (self = [super init])
{
}
return self;
}
- (void) physicsWorldSpeed:(SCNScene *) scene withSpeed:(float) speed
{
scene.physicsWorld.speed = speed;
}
- (void) physicsGravity:(SCNScene *) scene withGravity:(SCNVector3) gravity
{
scene.physicsWorld.gravity = gravity;
}
@end
Xcode should prompt you to create a XXX-Bridging-Header.h
when you add the first objective-c file. Let it create this file.
Add an import for the class to the 'XXX-Bridging-header.h":
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import "PhysWorldBridge.h"
Now you can use this (hacky) bridge to set the properties from Swift:
//scene.physicsWorld.speed = 2.0
// CAN'T USE ABOVE OR LINKER ERROR
let bridge = PhysWorldBridge();
bridge.physicsWorldSpeed(scene, withSpeed: 2.0);
//This call bridges properly
//So would the gravity one:
bridge.physicsGravity(scene, withGravity: SCNVector3Make(0, -90.81, 0));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With