Skip to content

Commit 7e2ee15

Browse files
Merge pull request #28 from satoshi-takano/swift4
Make it available for Swift 4
2 parents b20ba24 + e4eb3d6 commit 7e2ee15

File tree

8 files changed

+34
-30
lines changed

8 files changed

+34
-30
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0
1+
4.0

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode8
2+
osx_image: xcode9
33

44
xcode_project: OpenGraph.xcodeproj
55
xcode_scheme: OpenGraph

OpenGraph.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "OpenGraph"
3-
s.version = "1.0.2"
3+
s.version = "1.0.3"
44
s.summary = "A Swift wrapper for the Open Graph protocol."
55
s.homepage = "https://github.com/satoshi-takano/OpenGraph"
66
s.license = {

OpenGraph.xcodeproj/project.pbxproj

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
isa = PBXProject;
169169
attributes = {
170170
LastSwiftUpdateCheck = 0730;
171-
LastUpgradeCheck = 0820;
171+
LastUpgradeCheck = 0900;
172172
ORGANIZATIONNAME = "Satoshi Takano";
173173
TargetAttributes = {
174174
7B24FB141D3B2583005275B0 = {
@@ -278,14 +278,20 @@
278278
CLANG_CXX_LIBRARY = "libc++";
279279
CLANG_ENABLE_MODULES = YES;
280280
CLANG_ENABLE_OBJC_ARC = YES;
281+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
281282
CLANG_WARN_BOOL_CONVERSION = YES;
283+
CLANG_WARN_COMMA = YES;
282284
CLANG_WARN_CONSTANT_CONVERSION = YES;
283285
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
284286
CLANG_WARN_EMPTY_BODY = YES;
285287
CLANG_WARN_ENUM_CONVERSION = YES;
286288
CLANG_WARN_INFINITE_RECURSION = YES;
287289
CLANG_WARN_INT_CONVERSION = YES;
290+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
291+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
288292
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
293+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
294+
CLANG_WARN_STRICT_PROTOTYPES = YES;
289295
CLANG_WARN_SUSPICIOUS_MOVE = YES;
290296
CLANG_WARN_UNREACHABLE_CODE = YES;
291297
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -331,14 +337,20 @@
331337
CLANG_CXX_LIBRARY = "libc++";
332338
CLANG_ENABLE_MODULES = YES;
333339
CLANG_ENABLE_OBJC_ARC = YES;
340+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
334341
CLANG_WARN_BOOL_CONVERSION = YES;
342+
CLANG_WARN_COMMA = YES;
335343
CLANG_WARN_CONSTANT_CONVERSION = YES;
336344
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
337345
CLANG_WARN_EMPTY_BODY = YES;
338346
CLANG_WARN_ENUM_CONVERSION = YES;
339347
CLANG_WARN_INFINITE_RECURSION = YES;
340348
CLANG_WARN_INT_CONVERSION = YES;
349+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
350+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
341351
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
352+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
353+
CLANG_WARN_STRICT_PROTOTYPES = YES;
342354
CLANG_WARN_SUSPICIOUS_MOVE = YES;
343355
CLANG_WARN_UNREACHABLE_CODE = YES;
344356
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -372,7 +384,7 @@
372384
isa = XCBuildConfiguration;
373385
buildSettings = {
374386
CLANG_ENABLE_MODULES = YES;
375-
CODE_SIGN_IDENTITY = "Mac Developer";
387+
CODE_SIGN_IDENTITY = "";
376388
COMBINE_HIDPI_IMAGES = YES;
377389
DEFINES_MODULE = YES;
378390
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -393,7 +405,7 @@
393405
SKIP_INSTALL = YES;
394406
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator";
395407
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
396-
SWIFT_VERSION = 3.0;
408+
SWIFT_VERSION = 4.0;
397409
TVOS_DEPLOYMENT_TARGET = 9.0;
398410
WATCHOS_DEPLOYMENT_TARGET = 2.0;
399411
};
@@ -403,7 +415,7 @@
403415
isa = XCBuildConfiguration;
404416
buildSettings = {
405417
CLANG_ENABLE_MODULES = YES;
406-
CODE_SIGN_IDENTITY = "Mac Developer";
418+
CODE_SIGN_IDENTITY = "";
407419
COMBINE_HIDPI_IMAGES = YES;
408420
DEFINES_MODULE = YES;
409421
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -423,7 +435,7 @@
423435
PRODUCT_NAME = "$(TARGET_NAME)";
424436
SKIP_INSTALL = YES;
425437
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator";
426-
SWIFT_VERSION = 3.0;
438+
SWIFT_VERSION = 4.0;
427439
TVOS_DEPLOYMENT_TARGET = 9.0;
428440
WATCHOS_DEPLOYMENT_TARGET = 2.0;
429441
};
@@ -444,7 +456,7 @@
444456
PRODUCT_BUNDLE_IDENTIFIER = "net.cloud-dj.OpenGraphTests";
445457
PRODUCT_NAME = "$(TARGET_NAME)";
446458
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
447-
SWIFT_VERSION = 3.0;
459+
SWIFT_VERSION = 4.0;
448460
};
449461
name = Debug;
450462
};
@@ -462,7 +474,7 @@
462474
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
463475
PRODUCT_BUNDLE_IDENTIFIER = "net.cloud-dj.OpenGraphTests";
464476
PRODUCT_NAME = "$(TARGET_NAME)";
465-
SWIFT_VERSION = 3.0;
477+
SWIFT_VERSION = 4.0;
466478
};
467479
name = Release;
468480
};

OpenGraph.xcodeproj/xcshareddata/xcschemes/OpenGraph.xcscheme

Lines changed: 3 additions & 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 = "0820"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES">
3031
<Testables>
3132
<TestableReference
@@ -55,6 +56,7 @@
5556
buildConfiguration = "Debug"
5657
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5758
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
59+
language = ""
5860
launchStyle = "0"
5961
useCustomWorkingDirectory = "NO"
6062
ignoresPersistentStateOnLaunch = "NO"

OpenGraph/OpenGraph.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@ public struct OpenGraph {
66
public static func fetch(url: URL, completion: @escaping (OpenGraph?, Error?) -> Void) {
77
let configuration = URLSessionConfiguration.default
88
let session = URLSession(configuration: configuration)
9-
109
let task = session.dataTask(with: url, completionHandler: { (data, response, error) in
1110
handleFetchResult(data: data, response: response, error: error, callback: completion)
1211
})
13-
1412
task.resume()
1513
}
1614

1715
public static func fetch(url: URL, headers: [String:String], completion: @escaping (OpenGraph?, Error?) -> Void) {
18-
1916
var mutableURLRequest = URLRequest(url: url)
2017
for hkey in headers.keys {
2118
let value:String! = headers[hkey]
@@ -26,11 +23,9 @@ public struct OpenGraph {
2623

2724
let configuration = URLSessionConfiguration.default
2825
let session = URLSession(configuration: configuration)
29-
3026
let task = session.dataTask(with: mutableURLRequest, completionHandler: { (data, response, error) in
3127
handleFetchResult(data: data, response: response, error: error, callback: completion)
3228
})
33-
3429
task.resume()
3530
}
3631

OpenGraph/OpenGraphParser.swift

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extension OpenGraphParser {
1313
)
1414
let metaTagMatches = metatagRegex.matches(in: htmlString,
1515
options: [],
16-
range: NSMakeRange(0, htmlString.characters.count))
16+
range: NSMakeRange(0, htmlString.count))
1717
if metaTagMatches.isEmpty {
1818
return [:]
1919
}
@@ -34,29 +34,24 @@ extension OpenGraphParser {
3434
var copiedAttributes = attributes
3535

3636
let property = { () -> (name: String, content: String)? in
37-
let metaTag = nsString.substring(with: result.rangeAt(0))
38-
let nsMetaTag = metaTag as NSString
39-
37+
let metaTag = nsString.substring(with: result.range(at: 0))
4038
let propertyMatches = propertyRegexp.matches(in: metaTag,
4139
options: [],
42-
range: NSMakeRange(0, metaTag.characters.count))
43-
40+
range: NSMakeRange(0, metaTag.count))
4441
guard let propertyResult = propertyMatches.first else { return nil }
4542

46-
47-
let contentMatches = contentRegexp.matches(in: metaTag, options: [], range: NSMakeRange(0, metaTag.characters.count))
48-
43+
let contentMatches = contentRegexp.matches(in: metaTag, options: [], range: NSMakeRange(0, metaTag.count))
4944
guard let contentResult = contentMatches.first else { return nil }
5045

51-
let property = nsMetaTag.substring(with: propertyResult.rangeAt(1))
52-
let content = nsMetaTag.substring(with: contentResult.rangeAt(1))
46+
let nsMetaTag = metaTag as NSString
47+
let property = nsMetaTag.substring(with: propertyResult.range(at: 1))
48+
let content = nsMetaTag.substring(with: contentResult.range(at: 1))
49+
5350
return (name: property, content: content)
5451
}()
55-
5652
if let property = property, let metadata = OpenGraphMetadata(rawValue: property.name) {
5753
copiedAttributes[metadata] = property.content
5854
}
59-
6055
return copiedAttributes
6156
}
6257

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extension OpenGraph {
3939
```
4040

4141
## Requirements
42-
- Swift 3.0
42+
- Xcode 9 / Swift 4.0 or 3.2 (If you use Xcode 8.x, you can use [1.0.2](https://github.com/satoshi-takano/OpenGraph/releases/tag/1.0.2).)
4343
- iOS 8.0 or later
4444
- macOS 10.9 or later
4545
- tvOS 9.0 or later

0 commit comments

Comments
 (0)