How to I import 3rd party frameworks into Xcode Playground?

后端 未结 6 903
轮回少年
轮回少年 2020-11-28 03:25

How do I import 3rd part frameworks into Xcode Playground?

Swift Playground obviously has a framework import mechanism because we can import Cocoa,

6条回答
  •  清歌不尽
    2020-11-28 03:41

    I solved it by copying the built frameworks to the Built Products Directory, where Playgrounds in the workspace also searches for frameworks. Note: you also need to run lipo and strip away unused architectures from the FAT binaries.

    The steps needed (in a nutshell):

    • Create an aggregate target
    • Add a script phase to copy the frameworks from Carthage/Build/iOS/ to BUILT_PRODUCTS_DIR (I use a swift script in the example below, but you can use also use bash, ruby python etc.)
    • Run aggregate target Now you can import the framework(s) in a Playground

    Additionally you can leverage the aggregate target in your app:

    • Embed frameworks from BUILT_PRODUCTS_DIR, not Carthage/Build/iOS/
    • Add aggregate target to app scheme to re-establish frameworks after a clean.

    Here is an example project setup as above: https://github.com/richardnees/CarthagePlaygrounds

提交回复
热议问题