Skip to content

Instantly share code, notes, and snippets.

@bgromov
Created August 18, 2018 20:48
Show Gist options
  • Save bgromov/b5264295cf2e131a97b2bd0944aa868c to your computer and use it in GitHub Desktop.
Save bgromov/b5264295cf2e131a97b2bd0944aa868c to your computer and use it in GitHub Desktop.
Wrapping Swift function in Objective-C to use in C/C++

Taken from here

// SwiftWrapper.swift
@objc class SwiftWrapper {
    class func wrappedFunc() {
        // call Swift code
    }
}
// ObjCWrapper.m
extern “C” Func() {
    [SwiftWrapper wrappedFunc];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment