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

Add support for Swift 3 and Xcode 8 support #78

Merged
merged 32 commits into from
Sep 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
23420cb
Initial work on Swift 3 and Xcode 8 support
drmohundro Jun 19, 2016
083193d
Merge branch 'master' into xcode-8.0
drmohundro Jul 13, 2016
e56067f
Convert Tests to Swift 3.0 syntax
drmohundro Jul 13, 2016
45d5f29
Fix XMLParserDelegate method signatures
thomas-em Jul 15, 2016
0ada1a9
Fix deserialize() signature in XMLIndexerDeserializable adoptions
thomas-em Jul 15, 2016
d1a6bcf
Shut up »unused result« warnings
thomas-em Jul 15, 2016
89fafda
Merge pull request #86 from thomas-em/tm/swift-3
drmohundro Jul 15, 2016
292e980
Fix all Swiftlint issues
drmohundro Jul 17, 2016
60089e7
Merge branch 'master' into xcode-8.0
drmohundro Jul 17, 2016
e259fbc
Add swiftlint support to .travis.yml
drmohundro Jul 17, 2016
208fbb0
Add destination for Travis build
drmohundro Jul 17, 2016
8efde3d
Support Xcode 8 beta 4
drmohundro Aug 2, 2016
b10c2e3
Merge branch 'master' into xcode-8.0
drmohundro Aug 9, 2016
9d3b2cf
Tweak README re: deserialization example
drmohundro Aug 9, 2016
54f7747
Update to Xcode 8 beta 6
drmohundro Aug 18, 2016
f9a49c2
Record Swift migration to suppress warning on Xcode 8
norio-nomura Aug 26, 2016
8ed2090
Add workaround for build error on macOS
norio-nomura Aug 26, 2016
9b88de5
Support linux
norio-nomura Aug 26, 2016
4a78bcc
Move tests to Tests/SWXMLHashTests
norio-nomura Aug 26, 2016
f80a501
Update tests for SPM and Linux
norio-nomura Aug 27, 2016
b82b251
Fix “error: Force Cast Violation: Force casts should be avoided. (for…
norio-nomura Aug 28, 2016
2987da5
Merge pull request #96 from norio-nomura/swift-3.0-preview-6
drmohundro Aug 28, 2016
30561b3
Rename SWXMLParser to FullXMLParser
drmohundro Aug 28, 2016
a97ede2
Change generating path of “test.xml” on SPM
norio-nomura Aug 29, 2016
7d41337
Change to catching error instead of using `try!` on Tests
norio-nomura Aug 29, 2016
cf4d7e8
Add `XCTAssertNotNil()` to some tests for avoiding crashes on Linux
norio-nomura Aug 29, 2016
5df7273
Update .travis.yml
norio-nomura Aug 29, 2016
76ca74c
Fix warning “’catch' block is unreachable because no errors are throw…
norio-nomura Aug 29, 2016
fed7e7e
Disable test on Linux
norio-nomura Aug 29, 2016
e48ea38
Merge pull request #97 from norio-nomura/fix-test-on-spm
drmohundro Aug 31, 2016
fdcfceb
Merge branch 'master' into xcode-8.0
drmohundro Sep 14, 2016
a9f965c
Update docs for Swift 3.0!
drmohundro Sep 14, 2016
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
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0-PREVIEW-6
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
opt_in_rules:
- empty_count
- missing_docs
- valid_docs

excluded:
- Carthage
39 changes: 32 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
language: objective-c
xcode_workspace: SWXMLHash.xcworkspace
xcode_scheme: SWXMLHash iOS
osx_image: xcode7.3

script:
- ./Scripts/build.sh
matrix:
include:
- script:
- swiftlint
- set -o pipefail
- xcodebuild $XCODE_ACTION $WORKSPACE -scheme "SWXMLHash OSX" | xcpretty
- xcodebuild $XCODE_ACTION $WORKSPACE -scheme "SWXMLHash iOS" -sdk iphonesimulator -destination "OS=10.0,name=iPhone 6S" | xcpretty
- xcodebuild $XCODE_ACTION $WORKSPACE -scheme "SWXMLHash tvOS" -sdk appletvsimulator -destination "name=Apple TV 1080p" | xcpretty
- xcodebuild build $WORKSPACE -scheme "SWXMLHash watchOS" -sdk watchsimulator | xcpretty
env:
- JOB=Xcode
- WORKSPACE="-workspace SWXMLHash.xcworkspace"
- XCODE_ACTION="build-for-testing test-without-building"
os: osx
osx_image: xcode8
language: objective-c
- script:
- swift build
- swift test
env: JOB=SPM
os: osx
osx_image: xcode8
language: objective-c
- script:
- swift build
# - swift test
env: JOB=Linux
sudo: required
dist: trusty
language: generic
install:
- eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)"
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## v3.0.0 (September 13, 2016)

* Official support for Xcode 8.0 and Swift 3.0
* See corresponding [PR #78](https://github.com/drmohundro/SWXMLHash/pull/78)
* `XMLIndexer.Error` was renamed to `IndexingError` because of a naming conflict with the built-in `Error` type.
* Linux support is partially available and there is a Travis CI build for it as well.
* Currently failing functionality is because of https://bugs.swift.org/browse/SR-2301.

## v2.5.1 (August 23, 2016)

* Support Swift 2.3 on Xcode 8
Expand Down
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ The API takes a lot of inspiration from [SwiftyJSON](https://github.com/SwiftyJS
## Requirements

- iOS 8.0+ / Mac OS X 10.9+ / tvOS 9.0+ / watchOS 2.0+
- Xcode 7.1+

(note that Xcode 8 beta and Swift 3 support are being tracked in [PR 78](https://github.com/drmohundro/SWXMLHash/pull/78))
- Xcode 8.0+

## Installation

Expand All @@ -47,7 +45,7 @@ Then create a `Podfile` with the following contents:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

pod 'SWXMLHash', '~> 2.5.0'
pod 'SWXMLHash', '~> 3.0.0'
```

Finally, run the following command to install it:
Expand All @@ -68,7 +66,7 @@ $ brew install carthage
Then add the following line to your `Cartfile`:

```
github "drmohundro/SWXMLHash" ~> 2.5
github "drmohundro/SWXMLHash" ~> 3.0
```

### Manual Installation
Expand Down Expand Up @@ -273,8 +271,8 @@ Using Swift 2.0's new error handling feature:
```swift
do {
try xml!.byKey("root").byKey("what").byKey("header").byKey("foo")
} catch let error as XMLIndexer.Error {
// error is an XMLIndexer.Error instance that you can deal with
} catch let error as IndexerError {
// error is an IndexerError instance that you can deal with
}
```

Expand All @@ -285,7 +283,7 @@ switch xml["root"]["what"]["header"]["foo"] {
case .Element(let elem):
// everything is good, code away!
case .XMLError(let error):
// error is an XMLIndexer.Error instance that you can deal with
// error is an IndexerError instance that you can deal with
}
```

Expand Down Expand Up @@ -327,7 +325,7 @@ struct Book: XMLIndexerDeserializable {
let amount: Int?
let isbn: Int

static func deserialize(node: XMLIndexer) throws -> Book {
static func deserialize(_ node: XMLIndexer) throws -> Book {
return try Book(
title: node["title"].value(),
price: node["price"].value(),
Expand Down
8 changes: 4 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ task :test do |t|
xctool_build_cmd = './scripts/build.sh'
xcode_build_cmd = 'xcodebuild -workspace SWXMLHash.xcworkspace -scheme "SWXMLHash iOS" clean build test -sdk iphonesimulator'

if system('which xctool')
run xctool_build_cmd
else
#if system('which xctool')
#run xctool_build_cmd
#else
if system('which xcpretty')
run "#{xcode_build_cmd} | xcpretty -c"
else
run xcode_build_cmd
end
end
#end
end
7 changes: 4 additions & 3 deletions SWXMLHash.podspec
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
Pod::Spec.new do |s|
s.name = 'SWXMLHash'
s.version = '2.5.1'
s.version = '3.0.0'
s.summary = 'Simple XML parsing in Swift'
s.homepage = 'https://github.com/drmohundro/SWXMLHash'
s.license = { type: 'MIT' }
s.authors = { 'David Mohundro' => '[email protected]' }

s.requires_arc = true
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '2.3' }
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '3.0' }

s.osx.deployment_target = '10.9'
s.ios.deployment_target = '8.0'
s.watchos.deployment_target = '2.0'
s.tvos.deployment_target = '9.0'

s.source = { git: 'https://github.com/drmohundro/SWXMLHash.git', tag: '2.5.1' }
s.source = { git: 'https://github.com/drmohundro/SWXMLHash.git',
tag: '3.0.0' }
s.source_files = 'Source/*.swift'
end
32 changes: 22 additions & 10 deletions SWXMLHash.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@

/* Begin PBXFileReference section */
54B83CC41C849D9B00D588B5 /* SWXMLHash+TypeConversion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SWXMLHash+TypeConversion.swift"; sourceTree = "<group>"; };
CD4B5F3919E2C42D005C1F33 /* test.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = test.xml; path = Tests/test.xml; sourceTree = SOURCE_ROOT; };
6C0CE0F01D7440F8005F1248 /* LinuxShims.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinuxShims.swift; sourceTree = "<group>"; };
6C477A9C1D702C0900D76FCA /* LinuxMain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = LinuxMain.swift; path = Tests/LinuxMain.swift; sourceTree = SOURCE_ROOT; };
CD4B5F3919E2C42D005C1F33 /* test.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = test.xml; sourceTree = "<group>"; };
CD6083EF196CA106000B4F8D /* SWXMLHash.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SWXMLHash.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CD6083F3196CA106000B4F8D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CD6083F4196CA106000B4F8D /* SWXMLHash.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SWXMLHash.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -267,8 +269,11 @@
CDC6D13E1D32D98400570DE5 /* TypeConversionPrimitypeTypesTests.swift */,
CDC6D11E1D32D70800570DE5 /* WhiteSpaceParsingTests.swift */,
CDC6D11A1D32D6CE00570DE5 /* XMLParsingTests.swift */,
6C0CE0F01D7440F8005F1248 /* LinuxShims.swift */,
6C477A9C1D702C0900D76FCA /* LinuxMain.swift */,
);
path = Tests;
name = Tests;
path = Tests/SWXMLHashTests;
sourceTree = "<group>";
};
CD6083FF196CA106000B4F8D /* Supporting Files */ = {
Expand Down Expand Up @@ -734,7 +739,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -777,7 +782,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand Down Expand Up @@ -827,6 +832,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "drmohundro.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = SWXMLHash;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
Expand All @@ -841,7 +847,7 @@
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = Tests/Info.plist;
INFOPLIST_FILE = Tests/SWXMLHashTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "drmohundro.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -855,10 +861,11 @@
"$(PLATFORM_DIR)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = Tests/Info.plist;
INFOPLIST_FILE = Tests/SWXMLHashTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "drmohundro.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
Expand Down Expand Up @@ -910,6 +917,7 @@
PRODUCT_NAME = SWXMLHash;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
Expand All @@ -925,7 +933,7 @@
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = Tests/Info.plist;
INFOPLIST_FILE = Tests/SWXMLHashTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "drmohundro.${PRODUCT_NAME:rfc1034identifier}";
Expand All @@ -943,12 +951,13 @@
"$(DEVELOPER_FRAMEWORKS_DIR)",
"$(inherited)",
);
INFOPLIST_FILE = Tests/Info.plist;
INFOPLIST_FILE = Tests/SWXMLHashTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "drmohundro.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
Expand Down Expand Up @@ -992,6 +1001,7 @@
PRODUCT_NAME = SWXMLHash;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
Expand All @@ -1003,7 +1013,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
INFOPLIST_FILE = Tests/SWXMLHashTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "drmohundro.SWXMLHash-tvOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1019,11 +1029,12 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
INFOPLIST_FILE = Tests/SWXMLHashTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "drmohundro.SWXMLHash-tvOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TVOS_DEPLOYMENT_TARGET = 9.0;
};
name = Release;
Expand Down Expand Up @@ -1070,6 +1081,7 @@
PRODUCT_NAME = SWXMLHash;
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
Expand Down
6 changes: 3 additions & 3 deletions SWXMLHashPlayground.playground/section-1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ func enumerate(indexer: XMLIndexer, level: Int) {
let name = child.element!.name
print("\(level) \(name)")

enumerate(child, level: level + 1)
enumerate(indexer: child, level: level + 1)
}
}

enumerate(xml, level: 0)
enumerate(indexer: xml, level: 0)


// enumerate all child elements (functionally)
Expand Down Expand Up @@ -78,7 +78,7 @@ struct Book: XMLIndexerDeserializable {
let year: Int
let amount: Int?

static func deserialize(node: XMLIndexer) throws -> Book {
static func deserialize(_ node: XMLIndexer) throws -> Book {
return try Book(
title: node["title"].value(),
price: node["price"].value(),
Expand Down
6 changes: 0 additions & 6 deletions SWXMLHashPlayground.playground/timeline.xctimeline

This file was deleted.

2 changes: 1 addition & 1 deletion Scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set -ev

#xctool -scheme "SWXMLHash iOS" clean build test -sdk iphonesimulator
set -o pipefail && xcodebuild -workspace SWXMLHash.xcworkspace -scheme "SWXMLHash iOS" clean build test -sdk iphonesimulator | xcpretty
set -o pipefail && xcodebuild -workspace SWXMLHash.xcworkspace -scheme "SWXMLHash iOS" -destination "OS=10.0,name=iPhone 6S" clean build test -sdk iphonesimulator | xcpretty
Loading