Environment:
Swift >=2.3, Swift Framework in a Swift app
SetUp:
APIService.framework. public class APIService.swift and it
has static functions.It has another public class Item.swift.
A swift application that usage APIService.framework
APIService.function()
class Item.swift
If App needs to refer Item class of framework it has to do APIService.Item but since APIService is a class inside the framework, compiler always try to look for a property inside APIService class rather than in the APIService Module, hence throws an error saying
'Item' is not a member type of 'APIService'
Possible Solutions:
All these are just workarounds, the real issue remains that compiler is not able to differentiate between Module name and class name. Do we have anything in Swift by which I can say "Don't look into the ModuleName.swift, instead look into the whole Module" ?
Based on this answer, it looks like you can directly import a single type from a module to get around this.
import class APIService.Item
Then you can refer to Item directly without confusion.
The class, protocol, struct, enum and func keywords (at least) work in this situation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With