Add swift extension to swift package

Viewed 1300

I want to move swift extension files into a swift package. But, after move files to swift package, I have got this kind of error:

"Type 'NSAttributedString' has no member 'makeUnderlineString'"

Can't we add a swift extension into a swift package?

Updated:

Finally, I have solved the issue. I missed several things. These are you have to do for using extensions in Swift Package. Thanks all for your comments.

  1. Add "public" in front of the "extension"

    public extension String {

  2. If you edit the Swift Package in local, create a scheme for the Swift Package.

  3. Add the Swift Package into "TARGET -> General -> Frameworks, Libraries, and Embedded Content".

  4. Import the target of the Swift Package. Here the MyLibrary is a target name in Swift Package.

    import MyLibrary

1 Answers

Try to clean the project CMD+Shift+K, then, if "public"-keyword is used where necessary, it should work.

Related