Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refine: 使用 objc_copyClassNamesForImage 方法查找对应的类,比 objc_getClassList … #10

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ install! 'cocoapods',
generate_multiple_pod_projects: true

target 'TheRouter_Example' do
pod 'TheRouterTestModule', :path => '../Librarys/TheRouterTestModule'
pod 'TheRouter', :path => '../'
pod 'SnapKit', '5.6.0'
pod 'Toast', '4.0.0'
pod 'JKSwiftExtension'

target 'TheRouter_Tests' do
inherit! :search_paths

Expand Down
4 changes: 2 additions & 2 deletions Example/TheRouter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.sdemo.--PRODUCT-NAME-rfc1034identifier-";
PRODUCT_BUNDLE_IDENTIFIER = "org.demo.sdemo.--PRODUCT-NAME-rfc1034identifier-";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "TheRouter/TheRouter_Example-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -545,7 +545,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.sdemo.--PRODUCT-NAME-rfc1034identifier-";
PRODUCT_BUNDLE_IDENTIFIER = "org.demo.sdemo.--PRODUCT-NAME-rfc1034identifier-";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "TheRouter/TheRouter_Example-Bridging-Header.h";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
BuildableName = "TheRouter_Example.app"
BlueprintName = "TheRouter_Example"
ReferencedContainer = "container:TheRouter.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -54,23 +62,11 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
BuildableName = "TheRouter_Example.app"
BlueprintName = "TheRouter_Example"
ReferencedContainer = "container:TheRouter.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand All @@ -87,8 +83,6 @@
ReferencedContainer = "container:TheRouter.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
232 changes: 232 additions & 0 deletions Example/TheRouter/AppConfigServices.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,235 @@ final class AppRouterModuleService: NSObject, AppRouterProtocol {
debugPrint("打开路由了")
}
}


@objc
public protocol TestServiceProtocol: TheRouterServiceProtocol {
// 打开小程序
func testOpenMiniProgram(info: [String: Any])
}

final class TestModuleService: NSObject, TestServiceProtocol {

static var seriverName: String {
String(describing: TestServiceProtocol.self)
}

func testOpenMiniProgram(info: [String : Any]) {
if let window = UIApplication.shared.delegate?.window {
window?.makeToast("打开微信小程序", duration: 1, position: window?.center)
}
}
}

@objc
public protocol TestServiceProtocol1: TheRouterServiceProtocol {
// 打开小程序
func testOpenMiniProgram(info: [String: Any])
}

final class TestModuleService1: NSObject, TestServiceProtocol1 {

static var seriverName: String {
String(describing: TestServiceProtocol1.self)
}

func testOpenMiniProgram(info: [String : Any]) {
if let window = UIApplication.shared.delegate?.window {
window?.makeToast("打开微信小程序", duration: 1, position: window?.center)
}
}
}


@objc
public protocol TestServiceProtocol2: TheRouterServiceProtocol {
// 打开小程序
func testOpenMiniProgram(info: [String: Any])
}

final class TestModuleService2: NSObject, TestServiceProtocol2 {

static var seriverName: String {
String(describing: TestServiceProtocol2.self)
}

func testOpenMiniProgram(info: [String : Any]) {
if let window = UIApplication.shared.delegate?.window {
window?.makeToast("打开微信小程序", duration: 1, position: window?.center)
}
}
}


@objc
public protocol TestServiceProtocol3: TheRouterServiceProtocol {
// 打开小程序
func testOpenMiniProgram(info: [String: Any])
}

final class TestModuleService3: NSObject, TestServiceProtocol3 {

static var seriverName: String {
String(describing: TestServiceProtocol3.self)
}

func testOpenMiniProgram(info: [String : Any]) {
if let window = UIApplication.shared.delegate?.window {
window?.makeToast("打开微信小程序", duration: 1, position: window?.center)
}
}
}

@objc
public protocol TestServiceProtocol4: TheRouterServiceProtocol {
// 打开小程序
func testOpenMiniProgram(info: [String: Any])
}

final class TestModuleService4: NSObject, TestServiceProtocol4 {

static var seriverName: String {
String(describing: TestServiceProtocol4.self)
}

func testOpenMiniProgram(info: [String : Any]) {
if let window = UIApplication.shared.delegate?.window {
window?.makeToast("打开微信小程序", duration: 1, position: window?.center)
}
}
}


@objc
public protocol TestServiceProtocol5: TheRouterServiceProtocol {
// 打开小程序
func testOpenMiniProgram(info: [String: Any])
}

final class TestModuleService5: NSObject, TestServiceProtocol5 {

static var seriverName: String {
String(describing: TestServiceProtocol5.self)
}

func testOpenMiniProgram(info: [String : Any]) {
if let window = UIApplication.shared.delegate?.window {
window?.makeToast("打开微信小程序", duration: 1, position: window?.center)
}
}
}

@objc
public protocol TestServiceProtocol6: TheRouterServiceProtocol {
// 打开小程序
func testOpenMiniProgram(info: [String: Any])
}

final class TestModuleService6: NSObject, TestServiceProtocol6 {

static var seriverName: String {
String(describing: TestServiceProtocol6.self)
}

func testOpenMiniProgram(info: [String : Any]) {
if let window = UIApplication.shared.delegate?.window {
window?.makeToast("打开微信小程序", duration: 1, position: window?.center)
}
}
}

@objc
public protocol TestServiceProtocol7: TheRouterServiceProtocol {
// 打开小程序
func testOpenMiniProgram(info: [String: Any])
}

final class TestModuleService7: NSObject, TestServiceProtocol7 {

static var seriverName: String {
String(describing: TestServiceProtocol7.self)
}

func testOpenMiniProgram(info: [String : Any]) {
if let window = UIApplication.shared.delegate?.window {
window?.makeToast("打开微信小程序", duration: 1, position: window?.center)
}
}
}

@objc
public protocol TestServiceProtocol8: TheRouterServiceProtocol {
// 打开小程序
func testOpenMiniProgram(info: [String: Any])
}

final class TestModuleService8: NSObject, TestServiceProtocol8 {

static var seriverName: String {
String(describing: TestServiceProtocol8.self)
}

func testOpenMiniProgram(info: [String : Any]) {
if let window = UIApplication.shared.delegate?.window {
window?.makeToast("打开微信小程序", duration: 1, position: window?.center)
}
}
}

@objc
public protocol TestServiceProtocol9: TheRouterServiceProtocol {
// 打开小程序
func testOpenMiniProgram(info: [String: Any])
}

final class TestModuleService9: NSObject, TestServiceProtocol9 {

static var seriverName: String {
String(describing: TestServiceProtocol9.self)
}

func testOpenMiniProgram(info: [String : Any]) {
if let window = UIApplication.shared.delegate?.window {
window?.makeToast("打开微信小程序", duration: 1, position: window?.center)
}
}
}

@objc
public protocol TestServiceProtocol10: TheRouterServiceProtocol {
// 打开小程序
func testOpenMiniProgram(info: [String: Any])
}

final class TestModuleService10: NSObject, TestServiceProtocol10 {

static var seriverName: String {
String(describing: TestServiceProtocol10.self)
}

func testOpenMiniProgram(info: [String : Any]) {
if let window = UIApplication.shared.delegate?.window {
window?.makeToast("打开微信小程序", duration: 1, position: window?.center)
}
}
}

@objc
public protocol TestServiceProtocol11: TheRouterServiceProtocol {
// 打开小程序
func testOpenMiniProgram(info: [String: Any])
}

final class TestModuleService11: NSObject, TestServiceProtocol11 {

static var seriverName: String {
String(describing: TestServiceProtocol11.self)
}

func testOpenMiniProgram(info: [String : Any]) {
if let window = UIApplication.shared.delegate?.window {
window?.makeToast("打开微信小程序", duration: 1, position: window?.center)
}
}
}
21 changes: 11 additions & 10 deletions Example/TheRouter/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,26 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {


// 日志回调,可以监控线上路由运行情况
TheRouter.logcat { url, logType, errorMsg in
NSLog("TheRouter: logMsg- \(url) \(logType.rawValue) \(errorMsg)")
}

// 路由懒加载注册
TheRouterManager.loadRouterClass([".The"], useCache: true)
TheRouterManager.loadRouterClass([".The"], true, useCache: true)

TheRouter.lazyRegisterRouterHandle { url, userInfo in
TheRouterManager.injectRouterServiceConfig(webRouterUrl, serivceHost)
return TheRouterManager.addGloableRouter([".The"], url, userInfo)
return TheRouterManager.addGloableRouter([".The"], true, url, userInfo)
}

// 动态注册服务
TheRouterManager.registerServices()

// 日志回调,可以监控线上路由运行情况
TheRouter.logcat { url, logType, errorMsg in
debugPrint("TheRouter: logMsg- \(url) \(logType.rawValue) \(errorMsg)")
}
TheRouterManager.registerServices(excludeCocoapods: true)

return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
Expand Down
Loading