Search code examples
swiftxlform

Parse Issue / Expected a type for CGFloat in Swift


I've added XLForm, an Objective C library, to my Swift project using Xcode 6 beta 6.

The compiler trips on the method prototype of a protocol definition in XLFormDescriptorCell.h

#import <Foundation/Foundation.h>
...
@protocol XLFormDescriptorCell <NSObject>
...
@optional
+(CGFloat)formDescriptorCellHeightForRowDescriptor:(XLFormRowDescriptor *)rowDescriptor;
  ^
  Parse Issue / Expected a type

Additionally a warning: "Semantic Issue: Conflicting return type in implementation of 'forDescriptorCellHeightForRowDescriptor:" 'id' vs 'CGFloat' (aka 'float')

To my project's Bridging-Header.h file I've added (although the parse error occurs whether I add this or not):

#import "XLForm.h"

which itself includes XLFormDescriptorCell.h

I can't see where XLForm returns an 'id'. Anyone come across this or something similar?


Solution

  • CGFloat is declared at CoreGraphics/CGBase.h, which is imported by some headers imported at UIKit/UIKit.h, which is imported by default at most code files that Xcode creates for you, import it manually as needed.

    As for return types mismatch, check the returned value at your implementation, make sure it returns precisely CGFloat, not NSNumber or anything else.