Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoufan123 committed Aug 4, 2020
1 parent 4c0dc78 commit 21db7b7
Show file tree
Hide file tree
Showing 19 changed files with 505 additions and 201 deletions.
23 changes: 22 additions & 1 deletion Example/FZRouter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/* Begin PBXBuildFile section */
1D25920C24D9174800832FA4 /* TestObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D25920B24D9174800832FA4 /* TestObject.swift */; };
1D25920E24D930E900832FA4 /* FZRouterDemo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1D25920D24D930E900832FA4 /* FZRouterDemo.plist */; };
1D25921024D931A400832FA4 /* Target_RouterDemo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D25920F24D931A400832FA4 /* Target_RouterDemo.swift */; };
1D25921424D9329700832FA4 /* Target_OCRouterDemo.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D25921324D9329700832FA4 /* Target_OCRouterDemo.m */; };
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; };
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; };
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; };
Expand All @@ -30,6 +33,11 @@

/* Begin PBXFileReference section */
1D25920B24D9174800832FA4 /* TestObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestObject.swift; sourceTree = "<group>"; };
1D25920D24D930E900832FA4 /* FZRouterDemo.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = FZRouterDemo.plist; sourceTree = "<group>"; };
1D25920F24D931A400832FA4 /* Target_RouterDemo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Target_RouterDemo.swift; sourceTree = "<group>"; };
1D25921124D9329700832FA4 /* FZRouter_Example-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FZRouter_Example-Bridging-Header.h"; sourceTree = "<group>"; };
1D25921224D9329700832FA4 /* Target_OCRouterDemo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Target_OCRouterDemo.h; sourceTree = "<group>"; };
1D25921324D9329700832FA4 /* Target_OCRouterDemo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Target_OCRouterDemo.m; sourceTree = "<group>"; };
41C395EB68E3C45C6BA2037D /* FZRouter.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = FZRouter.podspec; path = ../FZRouter.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
4232C756C0BCB515647CF38C /* Pods-FZRouter_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FZRouter_Tests.release.xcconfig"; path = "Target Support Files/Pods-FZRouter_Tests/Pods-FZRouter_Tests.release.xcconfig"; sourceTree = "<group>"; };
607FACD01AFB9204008FA782 /* FZRouter_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FZRouter_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -109,10 +117,15 @@
607FACD51AFB9204008FA782 /* AppDelegate.swift */,
607FACD71AFB9204008FA782 /* ViewController.swift */,
1D25920B24D9174800832FA4 /* TestObject.swift */,
1D25920F24D931A400832FA4 /* Target_RouterDemo.swift */,
1D25921224D9329700832FA4 /* Target_OCRouterDemo.h */,
1D25921324D9329700832FA4 /* Target_OCRouterDemo.m */,
607FACD91AFB9204008FA782 /* Main.storyboard */,
607FACDC1AFB9204008FA782 /* Images.xcassets */,
607FACDE1AFB9204008FA782 /* LaunchScreen.xib */,
607FACD31AFB9204008FA782 /* Supporting Files */,
1D25920D24D930E900832FA4 /* FZRouterDemo.plist */,
1D25921124D9329700832FA4 /* FZRouter_Example-Bridging-Header.h */,
);
name = "Example for FZRouter";
path = FZRouter;
Expand Down Expand Up @@ -215,7 +228,7 @@
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1160;
};
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
Expand Down Expand Up @@ -251,6 +264,7 @@
files = (
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */,
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */,
1D25920E24D930E900832FA4 /* FZRouterDemo.plist in Resources */,
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -334,8 +348,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1D25921424D9329700832FA4 /* Target_OCRouterDemo.m in Sources */,
1D25920C24D9174800832FA4 /* TestObject.swift in Sources */,
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */,
1D25921024D931A400832FA4 /* Target_RouterDemo.swift in Sources */,
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -482,11 +498,14 @@
baseConfigurationReference = 9841B1D0BED9B2E3899B81A7 /* Pods-FZRouter_Example.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
INFOPLIST_FILE = FZRouter/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "FZRouter/FZRouter_Example-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
Expand All @@ -497,11 +516,13 @@
baseConfigurationReference = 720E5B25F0700C9862216EC6 /* Pods-FZRouter_Example.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
INFOPLIST_FILE = FZRouter/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "FZRouter/FZRouter_Example-Bridging-Header.h";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
Expand Down
Binary file not shown.
35 changes: 35 additions & 0 deletions Example/FZRouter/FZRouterDemo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fran</key>
<dict>
<key>www.franzhou.com</key>
<dict>
<key>routerTest</key>
<array>
<dict>
<key>target</key>
<string>RouterDemo</string>
<key>actions</key>
<dict>
<key>router_action</key>
<string>testRouterAction</string>
</dict>
</dict>
<dict>
<key>actions</key>
<dict>
<key>oc_router_action</key>
<string>testOCRouterAction</string>
<key>oc_router_action_2</key>
<string>testOCRouterAction2</string>
</dict>
<key>target</key>
<string>OCRouterDemo</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
4 changes: 4 additions & 0 deletions Example/FZRouter/FZRouter_Example-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//

17 changes: 17 additions & 0 deletions Example/FZRouter/Target_OCRouterDemo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Target_OCRouterDemo.h
// FZRouter_Example
//
// Created by FranZhou on 2020/8/4.
// Copyright © 2020 CocoaPods. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface Target_OCRouterDemo : NSObject

@end

NS_ASSUME_NONNULL_END
28 changes: 28 additions & 0 deletions Example/FZRouter/Target_OCRouterDemo.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Target_OCRouterDemo.m
// FZRouter_Example
//
// Created by FranZhou on 2020/8/4.
// Copyright © 2020 CocoaPods. All rights reserved.
//

#import "Target_OCRouterDemo.h"
#import <FZRouter/FZRouter-Swift.h>

@implementation Target_OCRouterDemo

+ (void)testOCRouterAction:(id<FZRouterDataPacketProtocol>)dataPacket{

NSLog(@"testOCRouterAction parameters : %@", dataPacket.parameters);

dataPacket.returnValue = @"Target_OCRouterDemo.testOCRouterAction";
}

+ (void)testOCRouterAction2:(id<FZRouterDataPacketProtocol>)dataPacket{

NSLog(@"%@", dataPacket.parameters);

dataPacket.returnValue = @(9527);
}

@end
34 changes: 34 additions & 0 deletions Example/FZRouter/Target_RouterDemo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// Target_RouterDemo.swift
// FZRouter_Example
//
// Created by FranZhou on 2020/8/4.
// Copyright © 2020 CocoaPods. All rights reserved.
//

import UIKit
import FZRouter

@objc(Target_RouterDemo)
class Target_RouterDemo: NSObject {

@objc class func testRouterAction(_ dataPacket: FZRouterDataPacketProtocol) {

if let params = dataPacket.parameters {
print("testRouterAction parameters : \(params.description)")
}

dataPacket.returnValue = "Target_RouterDemo.testRouterAction"

}

@objc class func urlRouter(_ dataPacket: FZRouterDataPacketProtocol) {
if let params = dataPacket.parameters {
print("urlRouter parameters : \(params.description)")
}

dataPacket.returnValue = "Target_RouterDemo.urlRouter"

}

}
7 changes: 6 additions & 1 deletion Example/FZRouter/TestObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public class TestObject {
public class TestObject: CustomStringConvertible {

var a: String

Expand All @@ -27,4 +27,9 @@ public class TestObject {
self.b = b
self.c = c
}

public var description: String {
return "TestObject[a = \(a), b = \(b), c = \(c)]"
}

}
40 changes: 40 additions & 0 deletions Example/FZRouter/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,54 @@
//

import UIKit
import FZRouter

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

// a = "123" b = "unknown b" c = "unknown c"
let obj = TestObject(a: "123")
print(obj)

print("======================")

if let filePath = Bundle.main.path(forResource: "FZRouterDemo", ofType: "plist") {
FZRouter.defaultRouter.loadRouter(withFilePath: filePath)
}

if let res1 = try? FZRouter.defaultRouter.router(withRouterURL: "fran://www.franzhou.com/routerTest/router_action?name=zhoufan") {
print("\(String(describing: res1.parameters)) -> \(String(describing: res1.returnValue))")
}

if let res2 = try? FZRouter.defaultRouter.router(withRouterURL: "fran://www.franzhou.com/routerTest/oc_router_action", extraParameters: ["name": "FranZhou", "age": 29]) {
print("\(String(describing: res2.parameters)) -> \(String(describing: res2.returnValue))")
}

if let res3 = try? FZRouter.defaultRouter.router(withRouterURL: "fran://www.franzhou.com/routerTest/oc_router_action_2") {
print("\(String(describing: res3.parameters)) -> \(String(describing: res3.returnValue))")
}

FZRouter.defaultRouter.appendRouter(withRouterURL: "fran://www.franzhou.com/routerDemo/urlRouter")

if let res4 = try? FZRouter.defaultRouter.router(withRouterURL: "fran://www.franzhou.com/routerDemo/urlRouter", extraParameters: ["name": "FranZhou", "age": 30]) {
print("\(String(describing: res4.parameters)) -> \(String(describing: res4.returnValue))")
}

FZRouter.defaultRouter.updateOrSave(withRouterURL: "fran://www.franzhou.com/routerDemo/urlRouter") { (dataPacket) in
dataPacket.returnValue = { () -> Void in
print("I am happy")
}
}
if let res5 = try? FZRouter.defaultRouter.router(withRouterURL: "fran://www.franzhou.com/routerDemo/urlRouter") {
print("\(String(describing: res5.parameters)) -> \(String(describing: res5.returnValue))")

if let returnValue = res5.returnValue as? () -> Void {
returnValue()
}
}

}

Expand Down
2 changes: 1 addition & 1 deletion Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
FZRouter: 2e1d79c99cb43c75e21aa477d66598fd5a31d0b4
FZRouter: 9761050c0acdfa6a16a69ae29b3493161c81d582

PODFILE CHECKSUM: adcd5ed8e48155c5bca1e9998eea41a86b40812d

Expand Down
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/FZRouter.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 21db7b7

Please sign in to comment.