Kiran P Nair
Kiran P Nair

Reputation: 2021

how to import a class present inside a custom framework in swift

I have a custom frame work and it contains some public class.But i cannot able to use that public class. In objective C we can import as

#import <XYZ/XYZCustomCell.h>

but how is it possible in swift

Upvotes: 6

Views: 4182

Answers (2)

Quentin Cl&#233;ment
Quentin Cl&#233;ment

Reputation: 11

It works also for classes, but the class that you try to import should be public :

public class DeviceHelper: NSObject {
}

And to use it, you just have to do :

import class DeviceHelper.DeviceHelper

with DeviceHelper that is a cocoa touch custom framework included in my project.

Upvotes: 1

binchik
binchik

Reputation: 919

You import a module using the "import" keyword, it works the following way:

import XYZ

If you want to import a struct/function/enum only, you can do this:

import struct XYZ.SomeStruct
import func XYZ.someFunc

That syntax fits for typealias, struct, class, enum, protocol, var, or func.

Upvotes: 8

Related Questions