Skip to content

Commit 30d06a3

Browse files
committed
Add Pod.
Modify podspec.
1 parent f6e6036 commit 30d06a3

10 files changed

Lines changed: 151 additions & 35 deletions

File tree

BlueCompass.podspec

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Pod::Spec.new do |s|
1010
s.name = 'BlueCompass'
1111
s.version = '0.1.0'
12-
s.summary = 'A short description of BlueCompass.'
12+
s.summary = 'Routing for WKScriptMessage'
1313

1414
# This description is used to generate tags and improve search results.
1515
# * Think: What does it do? Why did you write it? What is the focus?
@@ -26,9 +26,9 @@ TODO: Add long description of the pod here.
2626
s.license = { :type => 'MIT', :file => 'LICENSE' }
2727
s.author = { 'kogarasi' => 'kogarasi.cross@gmail.com' }
2828
s.source = { :git => 'https://github.com/kogarasi/BlueCompass.git', :tag => s.version.to_s }
29-
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
29+
s.social_media_url = 'https://twitter.com/koga0v0'
3030

31-
s.ios.deployment_target = '8.0'
31+
s.ios.deployment_target = '11.0'
3232

3333
s.source_files = 'BlueCompass/Classes/**/*'
3434

@@ -39,4 +39,5 @@ TODO: Add long description of the pod here.
3939
# s.public_header_files = 'Pod/Classes/**/*.h'
4040
# s.frameworks = 'UIKit', 'MapKit'
4141
# s.dependency 'AFNetworking', '~> 2.3'
42+
s.dependency 'RxSwift', '~> 5.0'
4243
end
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//
2+
// ScriptRoutingHelper.swift
3+
// dc7
4+
//
5+
// Created by こが on 2019/08/15.
6+
// Copyright © 2019 こが. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import WebKit
11+
import RxSwift
12+
13+
class WebViewScriptRouter: WKUserContentController {
14+
typealias Key = String
15+
typealias Content = String
16+
typealias Observer = PublishSubject<Content>
17+
18+
var observers = Dictionary<Key, Observer>()
19+
20+
//
21+
// Routerへ購読を登録
22+
//
23+
func receive( _ key: Key ) -> Observer {
24+
25+
if let observer = observers[ key ] {
26+
return observer
27+
} else {
28+
add( self, name: key )
29+
30+
31+
let observer = Observer()
32+
observers[ key ] = observer
33+
34+
print( observers )
35+
36+
return observer
37+
}
38+
39+
}
40+
41+
}
42+
43+
extension WebViewScriptRouter: WKScriptMessageHandler {
44+
45+
// JSから呼ばれる
46+
func userContentController( _ userContentController: WKUserContentController, didReceive message: WKScriptMessage ){
47+
48+
guard let messageData = message.body as? String else {
49+
fatalError( "message data is not stringified" )
50+
}
51+
52+
if let observer = observers[ message.name ] {
53+
observer.on( .next( messageData ) )
54+
}
55+
}
56+
}

BlueCompass/Classes/ReplaceMe.swift

Whitespace-only changes.

Example/BlueCompass.xcodeproj/project.pbxproj

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; };
11-
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; };
11+
607FACD81AFB9204008FA782 /* ExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ExampleViewController.swift */; };
1212
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; };
1313
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
1414
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
@@ -29,12 +29,12 @@
2929

3030
/* Begin PBXFileReference section */
3131
12FEEB85CB27F217C1F18E80 /* Pods_BlueCompass_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_BlueCompass_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
32-
2099A8284452314E85D62319 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
32+
2099A8284452314E85D62319 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
3333
27C08807BD8AE672984E6E5C /* Pods-BlueCompass_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BlueCompass_Example.debug.xcconfig"; path = "Target Support Files/Pods-BlueCompass_Example/Pods-BlueCompass_Example.debug.xcconfig"; sourceTree = "<group>"; };
3434
607FACD01AFB9204008FA782 /* BlueCompass_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BlueCompass_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
3535
607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3636
607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
37-
607FACD71AFB9204008FA782 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
37+
607FACD71AFB9204008FA782 /* ExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleViewController.swift; sourceTree = "<group>"; };
3838
607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
3939
607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
4040
607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
@@ -44,8 +44,8 @@
4444
841627A0D3B2431AC5BF7DA5 /* Pods-BlueCompass_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BlueCompass_Tests.release.xcconfig"; path = "Target Support Files/Pods-BlueCompass_Tests/Pods-BlueCompass_Tests.release.xcconfig"; sourceTree = "<group>"; };
4545
9B12090BB9AD6EE989106D8B /* Pods-BlueCompass_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BlueCompass_Example.release.xcconfig"; path = "Target Support Files/Pods-BlueCompass_Example/Pods-BlueCompass_Example.release.xcconfig"; sourceTree = "<group>"; };
4646
B66DC8489303D8C348BE83D1 /* Pods_BlueCompass_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_BlueCompass_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
47-
CB6055ADA8F67307D550D949 /* BlueCompass.podspec */ = {isa = PBXFileReference; includeInIndex = 1; name = BlueCompass.podspec; path = ../BlueCompass.podspec; sourceTree = "<group>"; };
48-
DB62A7E5A55B889A09203EAE /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; name = README.md; path = ../README.md; sourceTree = "<group>"; };
47+
CB6055ADA8F67307D550D949 /* BlueCompass.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = BlueCompass.podspec; path = ../BlueCompass.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
48+
DB62A7E5A55B889A09203EAE /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
4949
E7493A945B8DC207119F2987 /* Pods-BlueCompass_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BlueCompass_Tests.debug.xcconfig"; path = "Target Support Files/Pods-BlueCompass_Tests/Pods-BlueCompass_Tests.debug.xcconfig"; sourceTree = "<group>"; };
5050
/* End PBXFileReference section */
5151

@@ -77,7 +77,6 @@
7777
E7493A945B8DC207119F2987 /* Pods-BlueCompass_Tests.debug.xcconfig */,
7878
841627A0D3B2431AC5BF7DA5 /* Pods-BlueCompass_Tests.release.xcconfig */,
7979
);
80-
name = Pods;
8180
path = Pods;
8281
sourceTree = "<group>";
8382
};
@@ -106,7 +105,7 @@
106105
isa = PBXGroup;
107106
children = (
108107
607FACD51AFB9204008FA782 /* AppDelegate.swift */,
109-
607FACD71AFB9204008FA782 /* ViewController.swift */,
108+
607FACD71AFB9204008FA782 /* ExampleViewController.swift */,
110109
607FACD91AFB9204008FA782 /* Main.storyboard */,
111110
607FACDC1AFB9204008FA782 /* Images.xcassets */,
112111
607FACDE1AFB9204008FA782 /* LaunchScreen.xib */,
@@ -228,6 +227,7 @@
228227
developmentRegion = English;
229228
hasScannedForEncodings = 0;
230229
knownRegions = (
230+
English,
231231
en,
232232
Base,
233233
);
@@ -271,10 +271,12 @@
271271
inputPaths = (
272272
"${PODS_ROOT}/Target Support Files/Pods-BlueCompass_Example/Pods-BlueCompass_Example-frameworks.sh",
273273
"${BUILT_PRODUCTS_DIR}/BlueCompass/BlueCompass.framework",
274+
"${BUILT_PRODUCTS_DIR}/RxSwift/RxSwift.framework",
274275
);
275276
name = "[CP] Embed Pods Frameworks";
276277
outputPaths = (
277278
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BlueCompass.framework",
279+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwift.framework",
278280
);
279281
runOnlyForDeploymentPostprocessing = 0;
280282
shellPath = /bin/sh;
@@ -356,7 +358,7 @@
356358
isa = PBXSourcesBuildPhase;
357359
buildActionMask = 2147483647;
358360
files = (
359-
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */,
361+
607FACD81AFB9204008FA782 /* ExampleViewController.swift in Sources */,
360362
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */,
361363
);
362364
runOnlyForDeploymentPostprocessing = 0;

Example/BlueCompass.xcworkspace/contents.xcworkspacedata

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// ViewController.swift
3+
// BlueCompass
4+
//
5+
// Created by kogarasi on 08/16/2019.
6+
// Copyright (c) 2019 kogarasi. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class ExampleViewController: UIViewController {
12+
}
13+

Example/BlueCompass/ViewController.swift

Lines changed: 0 additions & 24 deletions
This file was deleted.

Example/Podfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use_frameworks!
33
target 'BlueCompass_Example' do
44
pod 'BlueCompass', :path => '../'
55

6+
pod 'RxSwift'
7+
68
target 'BlueCompass_Tests' do
79
inherit! :search_paths
810

Example/Podfile.lock

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
PODS:
2+
- BlueCompass (0.1.0):
3+
- RxSwift
4+
- FBSnapshotTestCase (2.1.4):
5+
- FBSnapshotTestCase/SwiftSupport (= 2.1.4)
6+
- FBSnapshotTestCase/Core (2.1.4)
7+
- FBSnapshotTestCase/SwiftSupport (2.1.4):
8+
- FBSnapshotTestCase/Core
9+
- Nimble (7.3.4)
10+
- Nimble-Snapshots (6.3.0):
11+
- Nimble-Snapshots/Core (= 6.3.0)
12+
- Nimble-Snapshots/Core (6.3.0):
13+
- FBSnapshotTestCase (~> 2.0)
14+
- Nimble (~> 7.0)
15+
- Quick (1.2.0)
16+
- RxSwift (5.0.0)
17+
18+
DEPENDENCIES:
19+
- BlueCompass (from `../`)
20+
- FBSnapshotTestCase (~> 2.1.4)
21+
- Nimble (~> 7.0)
22+
- Nimble-Snapshots (~> 6.3.0)
23+
- Quick (~> 1.2.0)
24+
- RxSwift
25+
26+
SPEC REPOS:
27+
https://github.com/cocoapods/specs.git:
28+
- FBSnapshotTestCase
29+
- Nimble
30+
- Nimble-Snapshots
31+
- Quick
32+
- RxSwift
33+
34+
EXTERNAL SOURCES:
35+
BlueCompass:
36+
:path: "../"
37+
38+
SPEC CHECKSUMS:
39+
BlueCompass: f20e24f92d998d2e0647a85c813be49d82eccd5c
40+
FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a
41+
Nimble: 051e3d8912d40138fa5591c78594f95fb172af37
42+
Nimble-Snapshots: f5459b5b091678dc942d03ec4741cacb58ba4a52
43+
Quick: 58d203b1c5e27fff7229c4c1ae445ad7069a7a08
44+
RxSwift: 8b0671caa829a763bbce7271095859121cbd895f
45+
46+
PODFILE CHECKSUM: c284453b6e24accd896447eaabf7c3549cbf6c48
47+
48+
COCOAPODS: 1.7.4

0 commit comments

Comments
 (0)