比如有两个ViewController,在第一个ViewController文件import CoreLocation之后,在第二个ViewController文件不import CoreLocation的话没法用CoreLocation,import的时候CoreLocation上面有道横线。
新建了一个工程,试了一下,还是不好使,不import系统的库就提示有错误
巴扎黑2017-04-18 09:07:08
You can create a swift file in the project to import external files. There is no need to import elsewhere.
天蓬老师2017-04-18 09:07:08
There is no need to think about this issue. Because all Swift files are global and can be called without import. Just drop it directly, no need to import
PHP中文网2017-04-18 09:07:08
Actually, I don’t understand it too well
In the same namespace, you can directly reference it without import
When I was in OC, there was a PrefixHeader that specifically imported a class and was universal
But Swift doesn’t have this thing. I know it can be implemented using bridging
I installed several common libraries in pod
I found that SDWebImage only needs to be imported once, and all classes can be used
But other libraries still seem to need to be imported every time
Sit and wait downstairs
怪我咯2017-04-18 09:07:08
To import a swift file into OC, don’t you need a bridge file? Just write the import in the bridge file. All other swift files in the entire program can be used directly. That’s how swift is.
PHP中文网2017-04-18 09:07:08
That would be great. Similarly, you can look at Java, Python, etc., and you can also explicitly indicate which packages you use in this file. import
的地方 import
multiple times will cause the app size to increase, then you are worrying too much. import