Skip to content

Instantly share code, notes, and snippets.

/**
This is the simplest way I've found to create a dynamic library in swift, then call a function from it in another swift program.
It doesn't use any package manager nonsense, just a compiled library and executable.
**/
///// Step 1: Create your dylib/dll
///
/// This is a 'single' function way to get a UIImage from a Metal shader
/// You still need to set up an MTLibrary in your app, but you should be
/// able to fairly readily drop this into a standard XCode app and as long
/// as you have the vertex and fragment shaders compiled into the library
/// you should be good to go.
///
/**
In your shader file:
///
/// This is a very simple command line application to work out how
/// to just run a compute program on the Metal GPU. It's not safe,
/// and will crash without warning if anything goes wrong, but I
/// was just trying to get the bare minimum thing working.
///
/// It's based off of Apple's sample code here:
/// https://developer.apple.com/documentation/metal/basic_tasks_and_concepts/performing_calculations_on_a_gpu
/// but I converted it from Objective-C to Swift and stripped out all the OO stuff.
///
@Khrob
Khrob / test.js.pc
Created October 17, 2014 06:03
simple return for a postcode test
return "some string";