Skip to content

Instantly share code, notes, and snippets.

@bjhomer
Last active August 29, 2015 14:26
Show Gist options
  • Save bjhomer/81f7072fe88e2f5daafa to your computer and use it in GitHub Desktop.
Save bjhomer/81f7072fe88e2f5daafa to your computer and use it in GitHub Desktop.
Block typedef broken-ness in Xcode 7 beta 5
#import <Foundation/Foundation.h>
// This is pretty simple, right?
typedef void(^SampleBlock)(NSString *str);
// Huh? UnsafeMutablePointer? Int32? In a 64-bit target?
public typealias SampleBlock = @convention(block) (UnsafeMutablePointer<Int32>) -> Void
#import <Foundation/Foundation.h>
@class NSString; // Yes, even though we just imported Foundation, this makes a difference.
typedef void(^SampleBlock)(NSString *str);
// Look! Now we have a real type!
public typealias SampleBlock = @convention(block) (String!) -> Void
#import <Foundation/Foundation.h>
// Yeah, this totally won't compile. I wonder what Swift will think?
typedef void(^SampleBlock)(asdf *str);
// Aha. So "UnsafeMutablePointer<Int32>" basically means "a pointer to some symbol I know nothing about."
public typealias SampleBlock = @convention(block) (UnsafeMutablePointer<Int32>) -> Void
// Basically, it looks like imported symbols aren't visible within typedef'd block parameters. Or something.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment