Environment:
Swift >=2.3, Swift Framework in a Swift app
SetUp:
- A Swift dynamic framework with module name, let's say
APIService.framework
. - It has a
public class APIService.swift
and it has static functions. It has another
public class Item.swift
.A swift application that usage
APIService.framework
- App can work with the framework like
APIService.function()
- App also has a
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:
- Change the framework's Module name to something other than class name.
- Change the class name to something other than the Module Name.
- Put a "Item" static property inside APIService class that points to
Item class in framework.
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"
?
Item
is not a member type of classAPIService.Item
. Still the question is "Do we have anything in Swift by which I can say "Don't look into the ModuleName.swift, instead look into the whole Module"" – Vert