CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Dec 2017 |
| SwiftSwift Version | 4.0 |
| SPMSupports SPM | ✗ |
Maintained by coderfish.
Lotusoot is a router tool and a decoupling tool of modular project.
pod 'Lotusoot'
TARGETS, click the Build Phases tab and add a New Run Script Phase by clicking the little plus icon in the top leftCheck Pods Manifest.lock, expand it and paste the following script:python ${PODS_ROOT}/Lotusoot/Lotusoot/Lotusoot.py ${SRC_ROOT} ${SRCROOT} Lotusoot
# parameter1: scan path
# parameter2: ${SRCROOT}, output path of Lotusoot.plist
# parameter3: suffix of Lotusoot(Can bes omited), Omit leads to script execution timeLotusoot.plist in the $SRCROOT-folder, add Lotusoot.plist into your project and uncheck Copy items if neededTip: Add the
Lotusoot.plistto your .gitignore file to prevent unnecessary conflicts.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// register all routes
LotusootCoordinator.registerAll()
return true
}let lotus = s(AccountLotus.self)
let accountModule: AccountLotus = LotusootCoordinator.lotusoot(lotus: lotus) as! AccountLotus
accountModule.login(username: "admin", password: "wow") { (error) in
print(error ?? "")
}let error: NSError? = LotusootRouter.register(route: "newproj://account/login") { (lotusootURL) in
accountModule.showLoginVC(username: "admin", password: "wow")
}let param: Dictionary = ["username" : "admin",
"password" : "wow"]
// no call back
LotusootRouter.open(route: "newproj://account/login", params: param)
// has call back
LotusootRouter.open(route: "newproj://account/login", params: param).completion { (error) in
print(error ?? "open success")
}
// ⚠️Not recommanded, use ?pram0=xxx lead to mismanagement
// This method just for H5 page of Hybrid project
LotusootRouter.open(url: "newproj://account/login?username=zhoulingyu").completion { (error) in
print(error ?? "open success")
}
Good usage example of Lotusoot:
Public module, where it defines Lotus protocol for all modules. A Lotus protocol defines all the functionality that open to other modules。For Example:public protocol AccountLotus {
func login(username: String, password: String, complete: (Error?) -> Void)
func register(username: String, password: String, complete: (Error?) -> Void)
func email(username: String) -> String
func showLoginVC(username: String, password: String)
}Lotus protocol you have defined in Public Module, you can call it Lotusoot. In Lotusoot, you must add Annotation for current Lotusoot, include: NameSpace-@NameSpace, Lotusoot-@Lotusoot, Lotus-@Lotus:// @NameSpace(TestAccountModule)
// @Lotusoot(AccountLotusoot)
// @Lotus(AccountLotus)
class AccountLotusoot: NSObject, AccountLotus {
func email(username: String) -> String {
return OtherService.email(username: "zhoulingyu")
}
func login(username: String, password: String, complete: (Error?) -> Void) {
LoginService.login(username: username, password: password, complete: complete)
}
func register(username: String, password: String, complete: (Error?) -> Void) {
RegisterService.register(username: username, password: password, complete: complete)
}
func showLoginVC(username: String, password: String) {
print("show login view controller")
}
}
LotusootMUST inherit fromNSObject
import Lotusoot、import ModulePublic. You are free to call all the service and routers nowTip: You can refer Demo -> NewProject
Demo 工程,Please do not forget build every Scheme first.
Lotusoot Use MIT License