简体   繁体   中英

Undeclared type - using C struct in Swift by bridging header

I have already seen other questions related with this, but nothing helped me. I have a problem integrating ImageMagick sdk into swift.

ViewController.swift

class ViewController: UIViewController {
    var wand: MagickWand!
    // [...]
}

The error:

Error: Use of undeclared type 'MagickWand'

I correctly imported MagicWand.h in Briding Header.

#ifndef Header_h
#define Header_h
#import "MagickWand.h"
#endif

In MagickWand.h, the struct is defined correctly.

typedef struct _MagickWand MagickWand;

Any help would be appreciated.

Incomplete struct definitions like that are imported as OpaquePointer (that's basically what OpaquePointer was made for). If Swift actually has access to the contents of the MagickWand struct, then it can import it as a named type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM