diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..18d4754 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +# Carthage +Carthage/ diff --git a/Cartfile b/Cartfile new file mode 100644 index 0000000..b3d6110 --- /dev/null +++ b/Cartfile @@ -0,0 +1,2 @@ +github "onevcat/Kingfisher" ~> 5.0 +github "scinfu/SwiftSoup" diff --git a/Cartfile.resolved b/Cartfile.resolved new file mode 100644 index 0000000..ff2a94c --- /dev/null +++ b/Cartfile.resolved @@ -0,0 +1,2 @@ +github "onevcat/Kingfisher" "5.12.0" +github "scinfu/SwiftSoup" "2.3.0" diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..94ae234 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,9 @@ +The MIT License +Copyright © 2020 Naoto Takahashi naoto0101@gmail.com +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/MetaRod.podspec b/MetaRod.podspec new file mode 100644 index 0000000..d476097 --- /dev/null +++ b/MetaRod.podspec @@ -0,0 +1,25 @@ +# +# Be sure to run `pod spec lint MetaRod.podspec' to ensure this is a +# valid spec and to remove all comments including this before submitting the spec. +# +# To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html +# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ +# + +Pod::Spec.new do |spec| + spec.name = "MetaRod" + spec.version = "1.0.0" + spec.summary = "lightweight url meta data parser library" + spec.homepage = "https://github.com/misyobun/MetaRod" + spec.screenshots = "https://user-images.githubusercontent.com/509448/72453120-f123cf00-3801-11ea-8947-a1540f91b27e.gif" + spec.license = "MIT" + spec.author = "misyobun" + spec.social_media_url = "https://twitter.com/misyobun" + spec.platform = :ios + spec.requires_arc = true + spec.swift_versions = ['5.0'] + spec.source = { :git => "https://github.com/misyobun/MetaRod.git", :tag => spec.version.to_s } + spec.source_files = "MetaRod/Sources/**/*" + spec.ios.deployment_target = '8.0' + spec.dependency "SwiftSoup" +end diff --git a/MetaRod.xcodeproj/project.pbxproj b/MetaRod.xcodeproj/project.pbxproj new file mode 100644 index 0000000..a8cd0a3 --- /dev/null +++ b/MetaRod.xcodeproj/project.pbxproj @@ -0,0 +1,641 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 74BEC7A223C5D15800B76B59 /* MetaRod.h in Headers */ = {isa = PBXBuildFile; fileRef = 74BEC7A023C5D15800B76B59 /* MetaRod.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 74BEC7AF23C5D70A00B76B59 /* MetaRod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74BEC7AE23C5D70A00B76B59 /* MetaRod.swift */; }; + 74BEC84023C6D21200B76B59 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74BEC83F23C6D21200B76B59 /* AppDelegate.swift */; }; + 74BEC84223C6D21200B76B59 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74BEC84123C6D21200B76B59 /* SceneDelegate.swift */; }; + 74BEC84423C6D21200B76B59 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74BEC84323C6D21200B76B59 /* ContentView.swift */; }; + 74BEC84623C6D21300B76B59 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 74BEC84523C6D21300B76B59 /* Assets.xcassets */; }; + 74BEC84923C6D21300B76B59 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 74BEC84823C6D21300B76B59 /* Preview Assets.xcassets */; }; + 74BEC84C23C6D21300B76B59 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 74BEC84A23C6D21300B76B59 /* LaunchScreen.storyboard */; }; + 74BEC85123C6D23400B76B59 /* MetaRod.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 74BEC79D23C5D15800B76B59 /* MetaRod.framework */; }; + 74BEC85223C6D23400B76B59 /* MetaRod.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 74BEC79D23C5D15800B76B59 /* MetaRod.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 74BEC88323CADF8D00B76B59 /* SwiftSoup.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 74BEC7A923C5D42400B76B59 /* SwiftSoup.framework */; }; + 74BEC88423CADF8D00B76B59 /* SwiftSoup.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 74BEC7A923C5D42400B76B59 /* SwiftSoup.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 74BEC8D223CDA3AF00B76B59 /* MetaData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74BEC8D123CDA3AF00B76B59 /* MetaData.swift */; }; + 74BEC8D423CEBAEE00B76B59 /* Kingfisher.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 74BEC8D323CEBAEE00B76B59 /* Kingfisher.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 74BEC8D623CEBAF700B76B59 /* KingfisherSwiftUI.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 74BEC8D523CEBAF700B76B59 /* KingfisherSwiftUI.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 74BEC8D823CED2AF00B76B59 /* Kingfisher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 74BEC8D323CEBAEE00B76B59 /* Kingfisher.framework */; }; + 74BEC8D923CED2B300B76B59 /* KingfisherSwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 74BEC8D523CEBAF700B76B59 /* KingfisherSwiftUI.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 74BEC85323C6D23400B76B59 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 74BEC79423C5D15800B76B59 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 74BEC79C23C5D15800B76B59; + remoteInfo = MetaRod; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 74BEC85523C6D23400B76B59 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 74BEC85223C6D23400B76B59 /* MetaRod.framework in Embed Frameworks */, + 74BEC8D423CEBAEE00B76B59 /* Kingfisher.framework in Embed Frameworks */, + 74BEC8D623CEBAF700B76B59 /* KingfisherSwiftUI.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + 74BEC88523CADF8D00B76B59 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 74BEC88423CADF8D00B76B59 /* SwiftSoup.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 74BEC79D23C5D15800B76B59 /* MetaRod.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MetaRod.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 74BEC7A023C5D15800B76B59 /* MetaRod.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MetaRod.h; sourceTree = ""; }; + 74BEC7A123C5D15800B76B59 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 74BEC7A923C5D42400B76B59 /* SwiftSoup.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftSoup.framework; path = Carthage/Build/iOS/SwiftSoup.framework; sourceTree = ""; }; + 74BEC7AE23C5D70A00B76B59 /* MetaRod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MetaRod.swift; sourceTree = ""; }; + 74BEC83D23C6D21200B76B59 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 74BEC83F23C6D21200B76B59 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 74BEC84123C6D21200B76B59 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 74BEC84323C6D21200B76B59 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 74BEC84523C6D21300B76B59 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 74BEC84823C6D21300B76B59 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + 74BEC84B23C6D21300B76B59 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 74BEC84D23C6D21300B76B59 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 74BEC8D123CDA3AF00B76B59 /* MetaData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MetaData.swift; sourceTree = ""; }; + 74BEC8D323CEBAEE00B76B59 /* Kingfisher.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Kingfisher.framework; path = Carthage/Build/iOS/Kingfisher.framework; sourceTree = ""; }; + 74BEC8D523CEBAF700B76B59 /* KingfisherSwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = KingfisherSwiftUI.framework; path = Carthage/Build/iOS/KingfisherSwiftUI.framework; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 74BEC79A23C5D15800B76B59 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 74BEC88323CADF8D00B76B59 /* SwiftSoup.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 74BEC83A23C6D21200B76B59 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 74BEC85123C6D23400B76B59 /* MetaRod.framework in Frameworks */, + 74BEC8D823CED2AF00B76B59 /* Kingfisher.framework in Frameworks */, + 74BEC8D923CED2B300B76B59 /* KingfisherSwiftUI.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 74BEC79323C5D15800B76B59 = { + isa = PBXGroup; + children = ( + 74BEC8D523CEBAF700B76B59 /* KingfisherSwiftUI.framework */, + 74BEC8D323CEBAEE00B76B59 /* Kingfisher.framework */, + 74BEC79F23C5D15800B76B59 /* MetaRod */, + 74BEC83E23C6D21200B76B59 /* Sample */, + 74BEC79E23C5D15800B76B59 /* Products */, + 74BEC7A823C5D42400B76B59 /* Frameworks */, + ); + sourceTree = ""; + }; + 74BEC79E23C5D15800B76B59 /* Products */ = { + isa = PBXGroup; + children = ( + 74BEC79D23C5D15800B76B59 /* MetaRod.framework */, + 74BEC83D23C6D21200B76B59 /* Sample.app */, + ); + name = Products; + sourceTree = ""; + }; + 74BEC79F23C5D15800B76B59 /* MetaRod */ = { + isa = PBXGroup; + children = ( + 74BEC7AC23C5D6D200B76B59 /* Sources */, + 74BEC7A023C5D15800B76B59 /* MetaRod.h */, + 74BEC7A123C5D15800B76B59 /* Info.plist */, + ); + path = MetaRod; + sourceTree = ""; + }; + 74BEC7A823C5D42400B76B59 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 74BEC7A923C5D42400B76B59 /* SwiftSoup.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 74BEC7AC23C5D6D200B76B59 /* Sources */ = { + isa = PBXGroup; + children = ( + 74BEC7AE23C5D70A00B76B59 /* MetaRod.swift */, + ); + path = Sources; + sourceTree = ""; + }; + 74BEC83E23C6D21200B76B59 /* Sample */ = { + isa = PBXGroup; + children = ( + 74BEC85623C850EB00B76B59 /* Models */, + 74BEC83F23C6D21200B76B59 /* AppDelegate.swift */, + 74BEC84123C6D21200B76B59 /* SceneDelegate.swift */, + 74BEC84323C6D21200B76B59 /* ContentView.swift */, + 74BEC84523C6D21300B76B59 /* Assets.xcassets */, + 74BEC84A23C6D21300B76B59 /* LaunchScreen.storyboard */, + 74BEC84D23C6D21300B76B59 /* Info.plist */, + 74BEC84723C6D21300B76B59 /* Preview Content */, + ); + path = Sample; + sourceTree = ""; + }; + 74BEC84723C6D21300B76B59 /* Preview Content */ = { + isa = PBXGroup; + children = ( + 74BEC84823C6D21300B76B59 /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; + 74BEC85623C850EB00B76B59 /* Models */ = { + isa = PBXGroup; + children = ( + 74BEC8D123CDA3AF00B76B59 /* MetaData.swift */, + ); + path = Models; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 74BEC79823C5D15800B76B59 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 74BEC7A223C5D15800B76B59 /* MetaRod.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 74BEC79C23C5D15800B76B59 /* MetaRod-iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 74BEC7A523C5D15800B76B59 /* Build configuration list for PBXNativeTarget "MetaRod-iOS" */; + buildPhases = ( + 74BEC79823C5D15800B76B59 /* Headers */, + 74BEC79923C5D15800B76B59 /* Sources */, + 74BEC79A23C5D15800B76B59 /* Frameworks */, + 74BEC79B23C5D15800B76B59 /* Resources */, + 74BEC7AB23C5D43500B76B59 /* ShellScript */, + 74BEC88523CADF8D00B76B59 /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "MetaRod-iOS"; + productName = MetaRod; + productReference = 74BEC79D23C5D15800B76B59 /* MetaRod.framework */; + productType = "com.apple.product-type.framework"; + }; + 74BEC83C23C6D21200B76B59 /* Sample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 74BEC84E23C6D21300B76B59 /* Build configuration list for PBXNativeTarget "Sample" */; + buildPhases = ( + 74BEC83923C6D21200B76B59 /* Sources */, + 74BEC83A23C6D21200B76B59 /* Frameworks */, + 74BEC83B23C6D21200B76B59 /* Resources */, + 74BEC85523C6D23400B76B59 /* Embed Frameworks */, + 74BEC8D723CEBC1F00B76B59 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 74BEC85423C6D23400B76B59 /* PBXTargetDependency */, + ); + name = Sample; + productName = Sample; + productReference = 74BEC83D23C6D21200B76B59 /* Sample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 74BEC79423C5D15800B76B59 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1130; + LastUpgradeCheck = 1130; + ORGANIZATIONNAME = msb; + TargetAttributes = { + 74BEC79C23C5D15800B76B59 = { + CreatedOnToolsVersion = 11.3; + LastSwiftMigration = 1130; + }; + 74BEC83C23C6D21200B76B59 = { + CreatedOnToolsVersion = 11.3; + }; + }; + }; + buildConfigurationList = 74BEC79723C5D15800B76B59 /* Build configuration list for PBXProject "MetaRod" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 74BEC79323C5D15800B76B59; + productRefGroup = 74BEC79E23C5D15800B76B59 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 74BEC79C23C5D15800B76B59 /* MetaRod-iOS */, + 74BEC83C23C6D21200B76B59 /* Sample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 74BEC79B23C5D15800B76B59 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 74BEC83B23C6D21200B76B59 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74BEC84C23C6D21300B76B59 /* LaunchScreen.storyboard in Resources */, + 74BEC84923C6D21300B76B59 /* Preview Assets.xcassets in Resources */, + 74BEC84623C6D21300B76B59 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 74BEC7AB23C5D43500B76B59 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "$(SRCROOT)/Carthage/Build/iOS/SwiftSoup.framework", + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/usr/local/bin/carthage copy-frameworks\n"; + }; + 74BEC8D723CEBC1F00B76B59 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "$(SRCROOT)/Carthage/Build/iOS/Kingfisher.framework", + "$(SRCROOT)/Carthage/Build/iOS/KingfisherSwiftUI.framework", + ); + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Carthage/Build/iOS/Kingfisher.framework", + "$(DERIVED_FILE_DIR)/Carthage/Build/iOS/KingfisherSwiftUI.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/usr/local/bin/carthage copy-frameworks\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 74BEC79923C5D15800B76B59 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74BEC7AF23C5D70A00B76B59 /* MetaRod.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 74BEC83923C6D21200B76B59 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74BEC84023C6D21200B76B59 /* AppDelegate.swift in Sources */, + 74BEC84223C6D21200B76B59 /* SceneDelegate.swift in Sources */, + 74BEC8D223CDA3AF00B76B59 /* MetaData.swift in Sources */, + 74BEC84423C6D21200B76B59 /* ContentView.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 74BEC85423C6D23400B76B59 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 74BEC79C23C5D15800B76B59 /* MetaRod-iOS */; + targetProxy = 74BEC85323C6D23400B76B59 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 74BEC84A23C6D21300B76B59 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 74BEC84B23C6D21300B76B59 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 74BEC7A323C5D15800B76B59 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 74BEC7A423C5D15800B76B59 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 74BEC7A623C5D15800B76B59 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Automatic; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = M8G9M4S72X; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); + INFOPLIST_FILE = MetaRod/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = msb.MetaRod; + PRODUCT_NAME = MetaRod; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 74BEC7A723C5D15800B76B59 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Automatic; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = M8G9M4S72X; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); + INFOPLIST_FILE = MetaRod/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = msb.MetaRod; + PRODUCT_NAME = MetaRod; + SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 74BEC84F23C6D21300B76B59 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_ASSET_PATHS = "\"Sample/Preview Content\""; + DEVELOPMENT_TEAM = M8G9M4S72X; + ENABLE_PREVIEWS = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); + INFOPLIST_FILE = Sample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = msb.Sample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 74BEC85023C6D21300B76B59 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_ASSET_PATHS = "\"Sample/Preview Content\""; + DEVELOPMENT_TEAM = M8G9M4S72X; + ENABLE_PREVIEWS = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); + INFOPLIST_FILE = Sample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = msb.Sample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 74BEC79723C5D15800B76B59 /* Build configuration list for PBXProject "MetaRod" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 74BEC7A323C5D15800B76B59 /* Debug */, + 74BEC7A423C5D15800B76B59 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 74BEC7A523C5D15800B76B59 /* Build configuration list for PBXNativeTarget "MetaRod-iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 74BEC7A623C5D15800B76B59 /* Debug */, + 74BEC7A723C5D15800B76B59 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 74BEC84E23C6D21300B76B59 /* Build configuration list for PBXNativeTarget "Sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 74BEC84F23C6D21300B76B59 /* Debug */, + 74BEC85023C6D21300B76B59 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 74BEC79423C5D15800B76B59 /* Project object */; +} diff --git a/MetaRod.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/MetaRod.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1ff3e68 --- /dev/null +++ b/MetaRod.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/MetaRod.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/MetaRod.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/MetaRod.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/MetaRod.xcodeproj/project.xcworkspace/xcuserdata/takahashinaoto.xcuserdatad/UserInterfaceState.xcuserstate b/MetaRod.xcodeproj/project.xcworkspace/xcuserdata/takahashinaoto.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..6e17e7f Binary files /dev/null and b/MetaRod.xcodeproj/project.xcworkspace/xcuserdata/takahashinaoto.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/MetaRod.xcodeproj/xcshareddata/xcschemes/MetaRod.xcscheme b/MetaRod.xcodeproj/xcshareddata/xcschemes/MetaRod.xcscheme new file mode 100644 index 0000000..9058936 --- /dev/null +++ b/MetaRod.xcodeproj/xcshareddata/xcschemes/MetaRod.xcscheme @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MetaRod.xcodeproj/xcuserdata/takahashinaoto.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/MetaRod.xcodeproj/xcuserdata/takahashinaoto.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..cef26c5 --- /dev/null +++ b/MetaRod.xcodeproj/xcuserdata/takahashinaoto.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,24 @@ + + + + + + + + + diff --git a/MetaRod.xcodeproj/xcuserdata/takahashinaoto.xcuserdatad/xcschemes/Sample.xcscheme b/MetaRod.xcodeproj/xcuserdata/takahashinaoto.xcuserdatad/xcschemes/Sample.xcscheme new file mode 100644 index 0000000..cfe981e --- /dev/null +++ b/MetaRod.xcodeproj/xcuserdata/takahashinaoto.xcuserdatad/xcschemes/Sample.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MetaRod.xcodeproj/xcuserdata/takahashinaoto.xcuserdatad/xcschemes/xcschememanagement.plist b/MetaRod.xcodeproj/xcuserdata/takahashinaoto.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..f6cd3be --- /dev/null +++ b/MetaRod.xcodeproj/xcuserdata/takahashinaoto.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,44 @@ + + + + + SchemeUserState + + MetaRod.xcscheme_^#shared#^_ + + orderHint + 0 + + MetaRodSamples.xcscheme_^#shared#^_ + + orderHint + 0 + + Sample.xcscheme + + isShown + + orderHint + 1 + + sample.xcscheme_^#shared#^_ + + orderHint + 0 + + + SuppressBuildableAutocreation + + 74BEC79C23C5D15800B76B59 + + primary + + + 74BEC83C23C6D21200B76B59 + + primary + + + + + diff --git a/MetaRod/Info.plist b/MetaRod/Info.plist new file mode 100644 index 0000000..9bcb244 --- /dev/null +++ b/MetaRod/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + + diff --git a/MetaRod/MetaRod.h b/MetaRod/MetaRod.h new file mode 100644 index 0000000..42da040 --- /dev/null +++ b/MetaRod/MetaRod.h @@ -0,0 +1,19 @@ +// +// MetaRod.h +// MetaRod +// +// Created by NaotoTakahashi +// Copyright © 2020 msb. All rights reserved. +// + +#import + +//! Project version number for MetaRod. +FOUNDATION_EXPORT double MetaRodVersionNumber; + +//! Project version string for MetaRod. +FOUNDATION_EXPORT const unsigned char MetaRodVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + + diff --git a/MetaRod/Sources/MetaRod.swift b/MetaRod/Sources/MetaRod.swift new file mode 100644 index 0000000..3b0c6bd --- /dev/null +++ b/MetaRod/Sources/MetaRod.swift @@ -0,0 +1,125 @@ +// +// MetaRod.swift +// MetaRod +// +// Created by NaotoTakahashi +// Copyright © 2020 msb. All rights reserved. +// + +import Foundation +import SwiftSoup + +public enum MetaRodError: Error { + case parseError(String) + case unknown(String) +} +public class MetaRod:NSObject { + + fileprivate var document:Document? = nil + + public func build(_ urlstr:String) -> Self{ + do { + guard let url = URL(string: urlstr), let html = try? String(contentsOf: url, encoding: .utf8) else { return self } + self.document = try SwiftSoup.parse(html) + } catch Exception.Error(let type, let message) { + print("error type \(type) message \(message)") + } catch { + print("unknown error") + } + return self + } + + public func meta() throws -> [String : String] { + var meta:[String:String] = [:] + do { + let header = self.document?.head() + let metaList = try header?.getElementsByTag("meta") + try metaList?.forEach{ elm in + let prop = try elm.attr("property") + if (!prop.isEmpty) { + meta[prop] = try elm.attr("content") + } + } + } catch Exception.Error(_, let message) { + throw MetaRodError.parseError(message) + } catch { + throw MetaRodError.unknown("failed") + } + return meta + } + + public func meta(completion: @escaping([String: String]) -> Void, errorCompletion: @escaping(MetaRodError) -> Void) { + DispatchQueue.global().async { + do { + var meta:[String:String] = [:] + let header = self.document?.head() + let metaList = try header?.getElementsByTag("meta") + try metaList?.forEach{ elm in + let prop = try elm.attr("property") + if (!prop.isEmpty) { + meta[prop] = try elm.attr("content") + } + } + DispatchQueue.main.async { + completion(meta) + } + + } catch Exception.Error(_, let message) { + DispatchQueue.main.async { + errorCompletion(MetaRodError.parseError(message)) + } + } catch { + DispatchQueue.main.async { + errorCompletion(MetaRodError.unknown("failed")) + } + } + } + } + + public func og() throws -> [String : String] { + var og:[String:String] = [:] + do { + let header = self.document?.head() + let metaList = try header?.getElementsByTag("meta") + try metaList?.forEach{ elm in + let prop = try elm.attr("property") + if (!prop.isEmpty && prop.contains("og:")) { + og[prop] = try elm.attr("content") + } + } + } catch Exception.Error(_, let message) { + throw MetaRodError.parseError(message) + } catch { + throw MetaRodError.unknown("failed") + } + return og + } + + public func og(completion: @escaping([String: String]) -> Void, errorCompletion: @escaping(MetaRodError) -> Void) { + DispatchQueue.global().async { + do { + var og:[String:String] = [:] + let header = self.document?.head() + let metaList = try header?.getElementsByTag("meta") + try metaList?.forEach{ elm in + let prop = try elm.attr("property") + if (!prop.isEmpty && prop.contains("og:")) { + og[prop] = try elm.attr("content") + } + } + DispatchQueue.main.async { + completion(og) + } + + } catch Exception.Error(_, let message) { + DispatchQueue.main.async { + errorCompletion(MetaRodError.parseError(message)) + } + } catch { + DispatchQueue.main.async { + errorCompletion(MetaRodError.unknown("failed")) + } + } + } + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..36dac9b --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# MetaRod +MetaRod is a lightweight url meta data parser library. + + +![e5b4c37582a718534d2e83ea48cea18c](https://user-images.githubusercontent.com/509448/72453120-f123cf00-3801-11ea-8947-a1540f91b27e.gif) + +## Installation +### Carthage + +[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager for Cocoa application. + +``` bash +$ brew update +$ brew install carthage +``` + +To integrate MetaRod into your Xcode project using Carthage, specify it in your `Cartfile`: + +``` ogdl +github "misyobun/MetaRod" +``` + +Then, run the following command to build the MetaRod framework: + +``` bash +$ carthage update +``` diff --git a/Sample/AppDelegate.swift b/Sample/AppDelegate.swift new file mode 100644 index 0000000..db5e805 --- /dev/null +++ b/Sample/AppDelegate.swift @@ -0,0 +1,37 @@ +// +// AppDelegate.swift +// Sample +// +// Created by NaotoTakahashi +// Copyright © 2020 msb. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/Sample/Assets.xcassets/AppIcon.appiconset/Contents.json b/Sample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d8db8d6 --- /dev/null +++ b/Sample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Sample/Assets.xcassets/Contents.json b/Sample/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/Sample/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Sample/Base.lproj/LaunchScreen.storyboard b/Sample/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/Sample/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Sample/ContentView.swift b/Sample/ContentView.swift new file mode 100644 index 0000000..2349118 --- /dev/null +++ b/Sample/ContentView.swift @@ -0,0 +1,39 @@ +// +// ContentView.swift +// Sample +// +// Created by NaotoTakahashi +// Copyright © 2020 msb. All rights reserved. +// + +import SwiftUI +import KingfisherSwiftUI + +struct ContentView: View { + @EnvironmentObject private var metaData: MetaData + + var body: some View { + VStack { + VStack { + Text(verbatim: self.metaData.og["og:title"] ?? "").font(.headline).frame(width: 320, height: 50, alignment: .center) + Spacer().frame(width:0, height: 20, alignment: .center) + KFImage(URL(string: self.metaData.og["og:image"] ?? "")).resizable().frame(width:300, height:400) + Spacer().frame(width:0, height: 20, alignment: .center) + Text(verbatim: self.metaData.og["og:description"] ?? "") + .font(.subheadline).frame(width: 320, height: 40, alignment: .center) + Spacer().frame(width:0, height: 20, alignment: .center) + }.padding() + Button(action: { + self.metaData.fetchOg() + }) { + Text("Fetch OG") + } + }.padding() + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView() + } +} diff --git a/Sample/Info.plist b/Sample/Info.plist new file mode 100644 index 0000000..9742bf0 --- /dev/null +++ b/Sample/Info.plist @@ -0,0 +1,60 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + + + + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Sample/Models/MetaData.swift b/Sample/Models/MetaData.swift new file mode 100644 index 0000000..4424e85 --- /dev/null +++ b/Sample/Models/MetaData.swift @@ -0,0 +1,43 @@ +// +// MetaData.swift +// Sample +// +// Created by NaotoTakahashi +// Copyright © 2020 msb. All rights reserved. +// + +import Combine +import SwiftUI +import MetaRod + +final class MetaData: ObservableObject { + + @Published var meta:[String:String] = [:] + @Published var og:[String:String] = [:] + + func fetchOg() { + DispatchQueue.global().async { + do { + let result = try MetaRod().build("https://www.vagrantup.jp/entry/2020/01/08/012539").og() + DispatchQueue.main.async { + self.og = result + } + } catch { + print("error") + } + } + } + + func fetchMeta() { + DispatchQueue.global().async { + do { + let result = try MetaRod().build("https://www.vagrantup.jp/entry/2020/01/08/012539").meta() + DispatchQueue.main.async { + self.meta = result + } + }catch{ + print("error") + } + } + } +} diff --git a/Sample/Preview Content/Preview Assets.xcassets/Contents.json b/Sample/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/Sample/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Sample/SceneDelegate.swift b/Sample/SceneDelegate.swift new file mode 100644 index 0000000..05612f2 --- /dev/null +++ b/Sample/SceneDelegate.swift @@ -0,0 +1,59 @@ +// +// SceneDelegate.swift +// Sample +// +// Created by NaotoTakahashi +// Copyright © 2020 msb. All rights reserved. +// + +import UIKit +import SwiftUI +import MetaRod + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + let contentView = ContentView() + // Use a UIHostingController as window root view controller. + if let windowScene = scene as? UIWindowScene { + let window = UIWindow(windowScene: windowScene) + window.rootViewController = UIHostingController(rootView: contentView.environmentObject(MetaData())) + self.window = window + window.makeKeyAndVisible() + } + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} +