9

I'm creating a custom react-native module and I have this custom type in a swift file

VideoTrimmer.swift

typealias TrimCompletion = (Error?) -> ()

how do I import or reuse it in a file with objective code? Or what's the syntax to redeclare it? I'm not so familiar with Objective-C syntax.

VideoTrimmer.m

#import "React/RCTBridgeModule.h"
@interface RCT_EXTERN_MODULE(VideoTrimmer, NSObject)
  RCT_EXTERN_METHOD(trimVideo:(NSURL *)sourceURL destinationURL:(NSURL 
  *)destinationURL startTime:(int *)startTime endTime:(int *)endTime 
  completion:(TrimCompletion *)completion)
@end
0

1 Answer 1

19

Typealiases defined in Swift are not supported in Objective-C. However, you should be able redeclare the block type in Objective-C with typedef:

typedef void (^TrimCompletion)(NSError *);
Sign up to request clarification or add additional context in comments.

2 Comments

Can you post the Swift equivalent of the Objective-C code you posted.
@Adrian it's in the question: typealias TrimCompletion = (Error?) -> Void

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.