How to import a Swift framework globally?

后端 未结 6 927
情歌与酒
情歌与酒 2020-12-14 05:56

I want to have a way to import my Swift Cocoapods globally in every class, how can I achieve this?

I tried a lot of things and they didn\'t work. Here are some ways

6条回答
  •  囚心锁ツ
    2020-12-14 06:42

    There is no way to do this. And this is not a bug, this is a language feature (so far, as speaking of Swift 2.2).

    Swift uses modules (Apple introduced them in Xcode 5 for Objective-C) and each file is an semantic unit, so you need to explicitly inform Xcode which modules are exposed to defined file.

    Not only there is no support for your described behaviour, but you shouldn't also try to bypass it. Using unnecessary (unused) modules could theoretically produce slower code (taking into account that compiler uses this information to its optimisation process).

提交回复
热议问题