Load HTML from Resources, into WebView

The resource file URL appears to be wrong in some way
This commit is contained in:
Andrew n marshall
2018-08-09 15:32:31 -07:00
parent 43f10c52c3
commit 7e375ce7a7
5 changed files with 76 additions and 4 deletions

View File

@@ -7,14 +7,17 @@
objects = {
/* Begin PBXBuildFile section */
AB036C55211B89D600CCC9D8 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB036C54211B89D600CCC9D8 /* WebKit.framework */; };
AB980111211A37B50025AFF2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB980110211A37B50025AFF2 /* AppDelegate.swift */; };
AB980113211A37B50025AFF2 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB980112211A37B50025AFF2 /* ViewController.swift */; };
AB980116211A37B50025AFF2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB980114211A37B50025AFF2 /* Main.storyboard */; };
AB980118211A37B70025AFF2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AB980117211A37B70025AFF2 /* Assets.xcassets */; };
AB98011B211A37B70025AFF2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB980119211A37B70025AFF2 /* LaunchScreen.storyboard */; };
ABA1B7FC212214E7000D3CC5 /* Blockly in Resources */ = {isa = PBXBuildFile; fileRef = ABA1B7FB212214E7000D3CC5 /* Blockly */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
AB036C54211B89D600CCC9D8 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
AB98010D211A37B50025AFF2 /* Blockly WebView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Blockly WebView.app"; sourceTree = BUILT_PRODUCTS_DIR; };
AB980110211A37B50025AFF2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
AB980112211A37B50025AFF2 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
@@ -22,6 +25,7 @@
AB980117211A37B70025AFF2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
AB98011A211A37B70025AFF2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
AB98011C211A37B70025AFF2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
ABA1B7FB212214E7000D3CC5 /* Blockly */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Blockly; path = "Resources/Non-Localized/Blockly"; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -29,17 +33,27 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
AB036C55211B89D600CCC9D8 /* WebKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
AB036C53211B89D500CCC9D8 /* Frameworks */ = {
isa = PBXGroup;
children = (
AB036C54211B89D600CCC9D8 /* WebKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
AB980104211A37B50025AFF2 = {
isa = PBXGroup;
children = (
AB98010F211A37B50025AFF2 /* Blockly WebView */,
AB98010E211A37B50025AFF2 /* Products */,
AB036C53211B89D500CCC9D8 /* Frameworks */,
);
sourceTree = "<group>";
};
@@ -54,6 +68,7 @@
AB98010F211A37B50025AFF2 /* Blockly WebView */ = {
isa = PBXGroup;
children = (
ABA1B7F9212214B9000D3CC5 /* Resources */,
AB980110211A37B50025AFF2 /* AppDelegate.swift */,
AB980112211A37B50025AFF2 /* ViewController.swift */,
AB980114211A37B50025AFF2 /* Main.storyboard */,
@@ -64,6 +79,22 @@
path = "Blockly WebView";
sourceTree = "<group>";
};
ABA1B7F9212214B9000D3CC5 /* Resources */ = {
isa = PBXGroup;
children = (
ABA1B7FA212214C6000D3CC5 /* Non-Localized */,
);
path = Resources;
sourceTree = "<group>";
};
ABA1B7FA212214C6000D3CC5 /* Non-Localized */ = {
isa = PBXGroup;
children = (
ABA1B7FB212214E7000D3CC5 /* Blockly */,
);
path = "Non-Localized";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -125,6 +156,7 @@
AB98011B211A37B70025AFF2 /* LaunchScreen.storyboard in Resources */,
AB980118211A37B70025AFF2 /* Assets.xcassets in Resources */,
AB980116211A37B50025AFF2 /* Main.storyboard in Resources */,
ABA1B7FC212214E7000D3CC5 /* Blockly in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@@ -9,16 +13,32 @@
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Blockly_WebView" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<wkWebView multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="HmE-ZW-QKv">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<wkWebViewConfiguration key="configuration" allowsAirPlayForMediaPlayback="NO">
<dataDetectorTypes key="dataDetectorTypes"/>
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
<wkPreferences key="preferences"/>
</wkWebViewConfiguration>
</wkWebView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
<connections>
<outlet property="webView" destination="HmE-ZW-QKv" id="OGc-PV-TAB"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-10" y="51"/>
</scene>
</scenes>
</document>

View File

@@ -7,12 +7,27 @@
//
import UIKit
import WebKit
class ViewController: UIViewController {
/// The name used to reference this iOS object when executing callbacks from the JS code.
/// If this value is changed, it should also be changed in the `CODE_GENERATOR_BRIDGE_JS` file.
fileprivate static let HOST_HTML = "Blockly/webview.html"
@IBOutlet weak var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
loadWebView()
}
func loadWebView() {
print("loadWebView: Bundle.main = ", Bundle.main); // This prints
if let htmlUrl = Bundle.main.url(forResource: "webview", withExtension: "html", subdirectory: "Blockly") {
print("htmlUrl = ", htmlUrl) // Doesn't print
webView.load(URLRequest.init(url: htmlUrl))
}
}
override func didReceiveMemoryWarning() {

View File

@@ -0,0 +1,5 @@
<html>
<body>
<h1>Blockly/webview.html</h1>
</body>
</html>