I try to share an Enum that I defined in an Header File between metal and my swift project:
#ifndef SharedIndizes_h
#define SharedIndizes_h
#import <Foundation/Foundation.h>
#endif /* SharedIndizes_h */
typedef NS_ENUM(NSInteger, VertexAttribute)
{
VertexAttributePosition = 0,
VertexAttributeNormal = 1,
};
#include <metal_stdlib>
#import "ExchangeTypes/SharedIndizes.h"
using namespace metal;
struct VertexIn {
float3 position [[ attribute(VertexAttributePosition) ]];
float3 normal [[ attribute(VertexAttributeNormal) ]];
};
vertexDescriptor.attributes[VertexAttribute.position.rawValue]
vertexDescriptor.attributes[VertexAttribute.normal.rawValue]
But all I get is some unexpected Errors:
Unsupported architecture
unknown type name '_int64_t'
unknown type name '_int32_t'
...
Removing #import "ExchangeTypes/SharedIndizes.h"
from my metal File also removes the errors.
Replace this:
#ifndef SharedIndizes_h
#define SharedIndizes_h
#import <Foundation/Foundation.h>
#endif /* SharedIndizes_h */
typedef NS_ENUM(NSInteger, VertexAttribute)
{
VertexAttributePosition = 0,
VertexAttributeNormal = 1,
};
with this:
#ifndef SharedIndizes_h
#define SharedIndizes_h
#ifdef __METAL_VERSION__
#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
#define NSInteger metal::int32_t
#else
#import <Foundation/Foundation.h>
#endif /* __METAL_VERSION__ */
#endif /* SharedIndizes_h */
typedef NS_ENUM(NSInteger, VertexAttribute)
{
VertexAttributePosition = 0,
VertexAttributeNormal = 1,
};