Skip to content

Commit e9fb6c4

Browse files
committed
Migrate playground to Swift 3 and project to Xcode 8.
1 parent f021921 commit e9fb6c4

File tree

9 files changed

+70
-41
lines changed

9 files changed

+70
-41
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [Unreleased][]
44

55
* Fix `HTMLElement`'s subscripting abilities not getting bridged into Swift (issue #59 revisited).
6+
* Update project and playground for Xcode 8 and Swift 3.
67

78
## [1.0.1][]
89

HTMLReader.playground/Contents.swift

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
//: HTMLReader – A WHATWG-compliant HTML parser
22
import HTMLReader
3-
import XCPlayground
4-
5-
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
3+
import PlaygroundSupport
64

75
let homepage = "https://github.com/nolanw/HTMLReader"
8-
NSURLSession.sharedSession().dataTaskWithURL(NSURL(string: homepage)!) {
9-
(data, response, error) in
6+
7+
URLSession.shared.dataTask(with: URL(string: homepage)!) { (data, response, error) in
8+
defer { PlaygroundPage.finishExecution(PlaygroundPage.current) }
9+
10+
1011
var contentType: String? = nil
11-
if let response = response as? NSHTTPURLResponse {
12+
if let response = response as? HTTPURLResponse {
1213
contentType = response.allHeaderFields["Content-Type"] as? String
1314
}
14-
if let data = data {
15-
let home = HTMLDocument(data: data, contentTypeHeader:contentType)
16-
if let div = home.firstNodeMatchingSelector(".repository-meta-content") {
17-
let whitespace = NSCharacterSet.whitespaceAndNewlineCharacterSet()
18-
print(div.textContent.stringByTrimmingCharactersInSet(whitespace))
19-
} else {
20-
print("Failed to match .repository-meta-content, maybe the HTML changed?")
21-
}
22-
} else {
15+
16+
guard let data = data else {
2317
print("No data received, sorry.")
18+
return
2419
}
25-
XCPlaygroundPage.finishExecution(XCPlaygroundPage.currentPage)
20+
21+
let home = HTMLDocument(data: data, contentTypeHeader:contentType)
22+
23+
guard let div = home.firstNode(matchingSelector: ".repository-meta-content") else {
24+
print("Failed to match .repository-meta-content, maybe the HTML changed?")
25+
return
26+
}
27+
28+
print(div.textContent.trimmingCharacters(in: .whitespacesAndNewlines))
29+
30+
2631
}.resume()
32+
33+
PlaygroundPage.current.needsIndefiniteExecution = true

HTMLReader.xcodeproj/project.pbxproj

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@
825825
isa = PBXProject;
826826
attributes = {
827827
CLASSPREFIX = HTML;
828-
LastUpgradeCheck = 0700;
828+
LastUpgradeCheck = 0800;
829829
ORGANIZATIONNAME = "Nolan Waite";
830830
TargetAttributes = {
831831
0D10776D1C1AC2DF00CF9B41 = {
@@ -1171,6 +1171,7 @@
11711171
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
11721172
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
11731173
CLANG_WARN_UNREACHABLE_CODE = YES;
1174+
"CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
11741175
CURRENT_PROJECT_VERSION = 1;
11751176
DEBUG_INFORMATION_FORMAT = dwarf;
11761177
DEFINES_MODULE = YES;
@@ -1207,6 +1208,7 @@
12071208
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
12081209
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
12091210
CLANG_WARN_UNREACHABLE_CODE = YES;
1211+
"CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
12101212
COPY_PHASE_STRIP = NO;
12111213
CURRENT_PROJECT_VERSION = 1;
12121214
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
@@ -1307,6 +1309,7 @@
13071309
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
13081310
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
13091311
CLANG_WARN_UNREACHABLE_CODE = YES;
1312+
"CODE_SIGN_IDENTITY[sdk=watchos*]" = "";
13101313
DEFINES_MODULE = YES;
13111314
DYLIB_COMPATIBILITY_VERSION = 1;
13121315
DYLIB_CURRENT_VERSION = 1;
@@ -1338,6 +1341,7 @@
13381341
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
13391342
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
13401343
CLANG_WARN_UNREACHABLE_CODE = YES;
1344+
"CODE_SIGN_IDENTITY[sdk=watchos*]" = "";
13411345
DEFINES_MODULE = YES;
13421346
DYLIB_COMPATIBILITY_VERSION = 1;
13431347
DYLIB_CURRENT_VERSION = 1;
@@ -1370,7 +1374,7 @@
13701374
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
13711375
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
13721376
CLANG_WARN_UNREACHABLE_CODE = YES;
1373-
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
1377+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
13741378
DEFINES_MODULE = YES;
13751379
DYLIB_COMPATIBILITY_VERSION = 1;
13761380
DYLIB_CURRENT_VERSION = 1;
@@ -1401,7 +1405,7 @@
14011405
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
14021406
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
14031407
CLANG_WARN_UNREACHABLE_CODE = YES;
1404-
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
1408+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
14051409
DEFINES_MODULE = YES;
14061410
DYLIB_COMPATIBILITY_VERSION = 1;
14071411
DYLIB_CURRENT_VERSION = 1;
@@ -1629,13 +1633,18 @@
16291633
CLANG_CXX_LIBRARY = "libc++";
16301634
CLANG_ENABLE_MODULES = YES;
16311635
CLANG_ENABLE_OBJC_ARC = YES;
1636+
CLANG_WARN_BOOL_CONVERSION = YES;
16321637
CLANG_WARN_CONSTANT_CONVERSION = YES;
16331638
CLANG_WARN_EMPTY_BODY = YES;
16341639
CLANG_WARN_ENUM_CONVERSION = YES;
1640+
CLANG_WARN_INFINITE_RECURSION = YES;
16351641
CLANG_WARN_INT_CONVERSION = YES;
16361642
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
1643+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
1644+
CLANG_WARN_UNREACHABLE_CODE = YES;
16371645
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
16381646
COPY_PHASE_STRIP = NO;
1647+
ENABLE_STRICT_OBJC_MSGSEND = YES;
16391648
ENABLE_TESTABILITY = YES;
16401649
GCC_C_LANGUAGE_STANDARD = gnu99;
16411650
GCC_DYNAMIC_NO_PIC = NO;
@@ -1647,8 +1656,11 @@
16471656
);
16481657
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
16491658
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
1659+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
16501660
GCC_WARN_ABOUT_RETURN_TYPE = YES;
1661+
GCC_WARN_UNDECLARED_SELECTOR = YES;
16511662
GCC_WARN_UNINITIALIZED_AUTOS = YES;
1663+
GCC_WARN_UNUSED_FUNCTION = YES;
16521664
GCC_WARN_UNUSED_VARIABLE = YES;
16531665
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
16541666
MACOSX_DEPLOYMENT_TARGET = 10.7;
@@ -1671,18 +1683,26 @@
16711683
CLANG_CXX_LIBRARY = "libc++";
16721684
CLANG_ENABLE_MODULES = YES;
16731685
CLANG_ENABLE_OBJC_ARC = YES;
1686+
CLANG_WARN_BOOL_CONVERSION = YES;
16741687
CLANG_WARN_CONSTANT_CONVERSION = YES;
16751688
CLANG_WARN_EMPTY_BODY = YES;
16761689
CLANG_WARN_ENUM_CONVERSION = YES;
1690+
CLANG_WARN_INFINITE_RECURSION = YES;
16771691
CLANG_WARN_INT_CONVERSION = YES;
16781692
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
1693+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
1694+
CLANG_WARN_UNREACHABLE_CODE = YES;
16791695
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
16801696
COPY_PHASE_STRIP = YES;
1697+
ENABLE_STRICT_OBJC_MSGSEND = YES;
16811698
GCC_C_LANGUAGE_STANDARD = gnu99;
16821699
GCC_NO_COMMON_BLOCKS = YES;
16831700
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
1701+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
16841702
GCC_WARN_ABOUT_RETURN_TYPE = YES;
1703+
GCC_WARN_UNDECLARED_SELECTOR = YES;
16851704
GCC_WARN_UNINITIALIZED_AUTOS = YES;
1705+
GCC_WARN_UNUSED_FUNCTION = YES;
16861706
GCC_WARN_UNUSED_VARIABLE = YES;
16871707
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
16881708
MACOSX_DEPLOYMENT_TARGET = 10.7;
@@ -1823,6 +1843,7 @@
18231843
1C319BC91C618863000DAA63 /* Release */,
18241844
);
18251845
defaultConfigurationIsVisible = 0;
1846+
defaultConfigurationName = Release;
18261847
};
18271848
1C6C1F631A179BF600236076 /* Build configuration list for PBXNativeTarget "HTMLReader iOS" */ = {
18281849
isa = XCConfigurationList;

HTMLReader.xcodeproj/xcshareddata/xcschemes/Encoding Labeler.xcscheme

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0700"
3+
LastUpgradeVersion = "0800"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -23,10 +23,10 @@
2323
</BuildActionEntries>
2424
</BuildAction>
2525
<TestAction
26+
buildConfiguration = "Debug"
2627
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2728
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
28-
shouldUseLaunchSchemeArgsEnv = "YES"
29-
buildConfiguration = "Debug">
29+
shouldUseLaunchSchemeArgsEnv = "YES">
3030
<Testables>
3131
</Testables>
3232
<MacroExpansion>
@@ -42,11 +42,11 @@
4242
</AdditionalOptions>
4343
</TestAction>
4444
<LaunchAction
45+
buildConfiguration = "Debug"
4546
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4647
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
4748
launchStyle = "0"
4849
useCustomWorkingDirectory = "NO"
49-
buildConfiguration = "Debug"
5050
ignoresPersistentStateOnLaunch = "NO"
5151
debugDocumentVersioning = "YES"
5252
debugServiceExtension = "internal"
@@ -65,10 +65,10 @@
6565
</AdditionalOptions>
6666
</LaunchAction>
6767
<ProfileAction
68+
buildConfiguration = "Release"
6869
shouldUseLaunchSchemeArgsEnv = "YES"
6970
savedToolIdentifier = ""
7071
useCustomWorkingDirectory = "NO"
71-
buildConfiguration = "Release"
7272
debugDocumentVersioning = "YES">
7373
<BuildableProductRunnable
7474
runnableDebuggingMode = "0">

HTMLReader.xcodeproj/xcshareddata/xcschemes/HTMLReader OS X.xcscheme

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0700"
3+
LastUpgradeVersion = "0800"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -23,10 +23,10 @@
2323
</BuildActionEntries>
2424
</BuildAction>
2525
<TestAction
26+
buildConfiguration = "Debug"
2627
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2728
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
28-
shouldUseLaunchSchemeArgsEnv = "YES"
29-
buildConfiguration = "Debug">
29+
shouldUseLaunchSchemeArgsEnv = "YES">
3030
<Testables>
3131
<TestableReference
3232
skipped = "NO">
@@ -43,11 +43,11 @@
4343
</AdditionalOptions>
4444
</TestAction>
4545
<LaunchAction
46+
buildConfiguration = "Debug"
4647
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4748
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
4849
launchStyle = "0"
4950
useCustomWorkingDirectory = "NO"
50-
buildConfiguration = "Debug"
5151
ignoresPersistentStateOnLaunch = "NO"
5252
debugDocumentVersioning = "YES"
5353
debugServiceExtension = "internal"
@@ -65,10 +65,10 @@
6565
</AdditionalOptions>
6666
</LaunchAction>
6767
<ProfileAction
68+
buildConfiguration = "Release"
6869
shouldUseLaunchSchemeArgsEnv = "YES"
6970
savedToolIdentifier = ""
7071
useCustomWorkingDirectory = "NO"
71-
buildConfiguration = "Release"
7272
debugDocumentVersioning = "YES">
7373
</ProfileAction>
7474
<AnalyzeAction

HTMLReader.xcodeproj/xcshareddata/xcschemes/HTMLReader iOS Static Library.xcscheme

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0700"
3+
LastUpgradeVersion = "0800"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -23,10 +23,10 @@
2323
</BuildActionEntries>
2424
</BuildAction>
2525
<TestAction
26+
buildConfiguration = "Debug"
2627
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2728
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
28-
shouldUseLaunchSchemeArgsEnv = "YES"
29-
buildConfiguration = "Debug">
29+
shouldUseLaunchSchemeArgsEnv = "YES">
3030
<Testables>
3131
<TestableReference
3232
skipped = "NO">
@@ -43,11 +43,11 @@
4343
</AdditionalOptions>
4444
</TestAction>
4545
<LaunchAction
46+
buildConfiguration = "Debug"
4647
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4748
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
4849
launchStyle = "0"
4950
useCustomWorkingDirectory = "NO"
50-
buildConfiguration = "Debug"
5151
ignoresPersistentStateOnLaunch = "NO"
5252
debugDocumentVersioning = "YES"
5353
debugServiceExtension = "internal"
@@ -65,10 +65,10 @@
6565
</AdditionalOptions>
6666
</LaunchAction>
6767
<ProfileAction
68+
buildConfiguration = "Release"
6869
shouldUseLaunchSchemeArgsEnv = "YES"
6970
savedToolIdentifier = ""
7071
useCustomWorkingDirectory = "NO"
71-
buildConfiguration = "Release"
7272
debugDocumentVersioning = "YES">
7373
</ProfileAction>
7474
<AnalyzeAction

HTMLReader.xcodeproj/xcshareddata/xcschemes/HTMLReader iOS.xcscheme

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0700"
3+
LastUpgradeVersion = "0800"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -23,10 +23,10 @@
2323
</BuildActionEntries>
2424
</BuildAction>
2525
<TestAction
26+
buildConfiguration = "Debug"
2627
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2728
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
28-
shouldUseLaunchSchemeArgsEnv = "YES"
29-
buildConfiguration = "Debug">
29+
shouldUseLaunchSchemeArgsEnv = "YES">
3030
<Testables>
3131
<TestableReference
3232
skipped = "NO">
@@ -52,11 +52,11 @@
5252
</AdditionalOptions>
5353
</TestAction>
5454
<LaunchAction
55+
buildConfiguration = "Debug"
5556
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5657
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
5758
launchStyle = "0"
5859
useCustomWorkingDirectory = "NO"
59-
buildConfiguration = "Debug"
6060
ignoresPersistentStateOnLaunch = "NO"
6161
debugDocumentVersioning = "YES"
6262
debugServiceExtension = "internal"
@@ -74,10 +74,10 @@
7474
</AdditionalOptions>
7575
</LaunchAction>
7676
<ProfileAction
77+
buildConfiguration = "Release"
7778
shouldUseLaunchSchemeArgsEnv = "YES"
7879
savedToolIdentifier = ""
7980
useCustomWorkingDirectory = "NO"
80-
buildConfiguration = "Release"
8181
debugDocumentVersioning = "YES">
8282
<MacroExpansion>
8383
<BuildableReference

HTMLReader.xcodeproj/xcshareddata/xcschemes/HTMLReader tvOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0720"
3+
LastUpgradeVersion = "0800"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

HTMLReader.xcodeproj/xcshareddata/xcschemes/HTMLReader watchOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0720"
3+
LastUpgradeVersion = "0800"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

0 commit comments

Comments
 (0)