Custom Framework with Swift and SpriteKit: can't access custom class

97 views Asked by At

I created my custom framework in swift, let says MyCustomFramework.

Within this project, I added a new swift file: XYZCustomClass which looks like this:

public class XYZCustomClass: SKNode {
    // variables declaration

    public override init() {
        super.init()
        // make my custom init here
    }

    ...
}

I build my project as iOS Generic Device and get my MyCustomFramework.framework location.

Then I import MyCustomFramework.framework within a personal project and I import it in the good file:

import SpriteKit
import MyCustomFramework

class GameScene: SKScene {
    override func didMoveToView(view: SKView) {            
        let test = XYZCustomClass()    // Error
    }
}

And I finally get the following error:

"path"/MyProject/GameScene.swift:44:20: XYZCustomClass' is unavailable: cannot find Swift declaration for this class

As an additional information, the project has been built with SpriteKit in swift language.

Thank you in advance,

1

There are 1 answers

1
apotry On

Check that the framework is included under 'General'->'Linked Frameworks and Libraries' and/or under 'Build Phases'->'Target Dependencies', and add it if necessary.