Peter's answer above is correct, but I have a suggestion that does not include the C preprocessor (not available in Swift), which is slightly larger than Cocoa-like.
Watch a WWDC 2014 233 session to configure iOS and Mac applications in the same project as separate targets, and then use the categories in the document class to implement common functions:
CommonFunctions.h @interface AppDocument (CommonFunctions) - (void)function; @end
-
CommonFunctions.m @implementation AppDocument (CommonFunctions) - (void) function {
Your AppDocument
class would have 2 different classes inheriting from the UI / NSDocument, as needed for each platform / target, and each target would pull categories from a common place.
source share