Create and import swift framework

前端 未结 4 1925
星月不相逢
星月不相逢 2020-12-03 05:38

I\'m new in swift programming. I need to create pure swift framework and import it in my existing pure swift project. When I try to import swift framework, I\'m getting this

4条回答
  •  半阙折子戏
    2020-12-03 06:11

    I've done with the following steps.

    1. Create a framework project, for example named "FooKit". (Cocoa Touch Framework to be selected)
    2. Create a ".swift" file and add a public symbol, for example public func foo(), to it.
    3. Create an use-side (app) project. (I've chosen Single View Application)
    4. Open the root directory of "FooKit" by Finder, drag "FooKit.xcodeproj" there and drop it into the app project via Project Navigator.
    5. Add "FooKit" to Target Dependencies in the app's Build Phases setting.
    6. Add "FooKit.framework" to Embedded Binaries in the app's General setting.

    Now you can build like this code in the use-side app.

    import FooKit
    
    func bar() {
        foo()
    }
    

提交回复
热议问题