Importing pure Swift custom framework into other Swift project

前端 未结 2 610
无人共我
无人共我 2021-01-13 01:34

Let\'s, I have a custom Swift Cocoa Touch framework, MyLog, which has a simple function called printLog(). I have another Swift projec

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-13 02:16

    Finally I got the solution with below steps,

    Steps

    1. Mark your custom MyLog project as Framework when creating
    2. Implement func printLog and build the project (successful build will create a /Product/MyLog.framework file)
    3. Copy the /Product/Mylog.framework file into HelloWorld project directory using Finder
    4. Follow, HelloWorld Project -> Targets -> Build Phases -> Link Binary With Libraries -> + -> Add Other (select MyLog.framework from HelloWorld/ directory)
    5. Follow, HelloWorld Project -> Targets -> Build Phases -> Embed Frameworks -> + -> Other (select MyLog.framework from HelloWorld/ directory)
    6. Build HelloWorld and enjoy!

    Update 1

    1. If you don't find path, HelloWorld Project -> Targets -> Build Phases -> Embed Frameworks please check, HelloWorld Project -> Targets -> General -> Embedded Binaries in the later versions of xcode, which will do the same thing step-5 does.

提交回复
热议问题