diff --git a/Example/Kitsunebi.xcodeproj/project.pbxproj b/Example/Kitsunebi.xcodeproj/project.pbxproj index 5d85f4f..c43f995 100644 --- a/Example/Kitsunebi.xcodeproj/project.pbxproj +++ b/Example/Kitsunebi.xcodeproj/project.pbxproj @@ -12,12 +12,25 @@ 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; }; 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; + AB8C53334AF0B93B9AA35F63 /* Pods_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 82C1CC1000A9FEDF5633C59D /* Pods_Tests.framework */; }; D72C379721410B7800F6D22F /* ResourceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D72C379621410B7800F6D22F /* ResourceViewController.swift */; }; D72C379A21410B9E00F6D22F /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = D72C379921410B9E00F6D22F /* Models.swift */; }; + D74145C7255E73BF00B2AECA /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; }; + D74145C8255E73C200B2AECA /* AssetTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D74145B8255E727900B2AECA /* AssetTests.swift */; }; D7791985208744A1000C3E18 /* logo.png in Resources */ = {isa = PBXBuildFile; fileRef = D7791984208744A0000C3E18 /* logo.png */; }; E2CAB7B5F04A203502BC5156 /* Pods_Kitsunebi_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A5132DBA2BB7A65D07CBA851 /* Pods_Kitsunebi_Example.framework */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + D74145C2255E72CD00B2AECA /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 607FACC81AFB9204008FA782 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 607FACCF1AFB9204008FA782; + remoteInfo = Kitsunebi_Example; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXFileReference section */ 189F5007590E4ACCF8A3024B /* Kitsunebi.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Kitsunebi.podspec; path = ../Kitsunebi.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 52B48990017D52AA5985AE83 /* Pods_Kitsunebi_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Kitsunebi_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -30,7 +43,9 @@ 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; + 68F193C2794126D0ADB734AB /* Pods-Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Tests/Pods-Tests.debug.xcconfig"; sourceTree = ""; }; 80E0FF848D4AAC1267BDE663 /* Pods-Kitsunebi_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Kitsunebi_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-Kitsunebi_Tests/Pods-Kitsunebi_Tests.release.xcconfig"; sourceTree = ""; }; + 82C1CC1000A9FEDF5633C59D /* Pods_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 89B2F51FB230E86F098D8D07 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; A5132DBA2BB7A65D07CBA851 /* Pods_Kitsunebi_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Kitsunebi_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B6601D19AF70E61C6D38E91E /* Pods-Kitsunebi_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Kitsunebi_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-Kitsunebi_Example/Pods-Kitsunebi_Example.release.xcconfig"; sourceTree = ""; }; @@ -39,7 +54,10 @@ CA14B7D7D40EAAE3D380AD89 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; D72C379621410B7800F6D22F /* ResourceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResourceViewController.swift; sourceTree = ""; }; D72C379921410B9E00F6D22F /* Models.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = ""; }; + D74145B8255E727900B2AECA /* AssetTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssetTests.swift; sourceTree = ""; }; + D74145BD255E72CD00B2AECA /* Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; D7791984208744A0000C3E18 /* logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = logo.png; sourceTree = ""; }; + F7154481AF7048032601351A /* Pods-Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-Tests/Pods-Tests.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -51,6 +69,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + D74145BA255E72CD00B2AECA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + AB8C53334AF0B93B9AA35F63 /* Pods_Tests.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -70,6 +96,7 @@ isa = PBXGroup; children = ( 607FACD01AFB9204008FA782 /* Kitsunebi_Example.app */, + D74145BD255E72CD00B2AECA /* Tests.xctest */, ); name = Products; sourceTree = ""; @@ -104,6 +131,7 @@ children = ( 607FACEB1AFB9204008FA782 /* Tests.swift */, 607FACE91AFB9204008FA782 /* Supporting Files */, + D74145B8255E727900B2AECA /* AssetTests.swift */, ); path = Tests; sourceTree = ""; @@ -133,6 +161,8 @@ B6601D19AF70E61C6D38E91E /* Pods-Kitsunebi_Example.release.xcconfig */, C76B8A08CF3BA0FC8B959D07 /* Pods-Kitsunebi_Tests.debug.xcconfig */, 80E0FF848D4AAC1267BDE663 /* Pods-Kitsunebi_Tests.release.xcconfig */, + 68F193C2794126D0ADB734AB /* Pods-Tests.debug.xcconfig */, + F7154481AF7048032601351A /* Pods-Tests.release.xcconfig */, ); name = Pods; sourceTree = ""; @@ -142,6 +172,7 @@ children = ( A5132DBA2BB7A65D07CBA851 /* Pods_Kitsunebi_Example.framework */, 52B48990017D52AA5985AE83 /* Pods_Kitsunebi_Tests.framework */, + 82C1CC1000A9FEDF5633C59D /* Pods_Tests.framework */, ); name = Frameworks; sourceTree = ""; @@ -184,13 +215,34 @@ productReference = 607FACD01AFB9204008FA782 /* Kitsunebi_Example.app */; productType = "com.apple.product-type.application"; }; + D74145BC255E72CD00B2AECA /* Tests */ = { + isa = PBXNativeTarget; + buildConfigurationList = D74145C4255E72CD00B2AECA /* Build configuration list for PBXNativeTarget "Tests" */; + buildPhases = ( + A45D2332CEDE9D8782BE9B51 /* [CP] Check Pods Manifest.lock */, + D74145B9255E72CD00B2AECA /* Sources */, + D74145BA255E72CD00B2AECA /* Frameworks */, + D74145BB255E72CD00B2AECA /* Resources */, + 8A1CB169C3331CC3122136D4 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + D74145C3255E72CD00B2AECA /* PBXTargetDependency */, + ); + name = Tests; + productName = Tests; + productReference = D74145BD255E72CD00B2AECA /* Tests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 607FACC81AFB9204008FA782 /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 0830; + DefaultBuildSystemTypeForWorkspace = Original; + LastSwiftUpdateCheck = 1220; LastUpgradeCheck = 1000; ORGANIZATIONNAME = CocoaPods; TargetAttributes = { @@ -200,6 +252,12 @@ LastSwiftMigration = 0900; ProvisioningStyle = Automatic; }; + D74145BC255E72CD00B2AECA = { + CreatedOnToolsVersion = 12.2; + DevelopmentTeam = FBQ6Z8AF3U; + ProvisioningStyle = Automatic; + TestTargetID = 607FACCF1AFB9204008FA782; + }; }; }; buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "Kitsunebi" */; @@ -216,6 +274,7 @@ projectRoot = ""; targets = ( 607FACCF1AFB9204008FA782 /* Kitsunebi_Example */, + D74145BC255E72CD00B2AECA /* Tests */, ); }; /* End PBXProject section */ @@ -232,6 +291,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + D74145BB255E72CD00B2AECA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -253,6 +319,24 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Kitsunebi_Example/Pods-Kitsunebi_Example-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + 8A1CB169C3331CC3122136D4 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Tests/Pods-Tests-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/Kitsunebi/Kitsunebi.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Kitsunebi.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Tests/Pods-Tests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 8FC031CC332B4C8AE2A0A2E0 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -271,6 +355,28 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + A45D2332CEDE9D8782BE9B51 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Tests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -285,8 +391,25 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + D74145B9255E72CD00B2AECA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D74145C8255E73C200B2AECA /* AssetTests.swift in Sources */, + D74145C7255E73BF00B2AECA /* Tests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + D74145C3255E72CD00B2AECA /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 607FACCF1AFB9204008FA782 /* Kitsunebi_Example */; + targetProxy = D74145C2255E72CD00B2AECA /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin PBXVariantGroup section */ 607FACD91AFB9204008FA782 /* Main.storyboard */ = { isa = PBXVariantGroup; @@ -451,6 +574,63 @@ }; name = Release; }; + D74145C5255E72CD00B2AECA /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 68F193C2794126D0ADB734AB /* Pods-Tests.debug.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = FBQ6Z8AF3U; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = Tests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.noppelab.Tests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Kitsunebi_Example.app/Kitsunebi_Example"; + }; + name = Debug; + }; + D74145C6255E72CD00B2AECA /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F7154481AF7048032601351A /* Pods-Tests.release.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = FBQ6Z8AF3U; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = Tests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.noppelab.Tests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Kitsunebi_Example.app/Kitsunebi_Example"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -472,6 +652,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + D74145C4255E72CD00B2AECA /* Build configuration list for PBXNativeTarget "Tests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D74145C5255E72CD00B2AECA /* Debug */, + D74145C6255E72CD00B2AECA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 607FACC81AFB9204008FA782 /* Project object */; diff --git a/Example/Kitsunebi.xcodeproj/xcshareddata/xcschemes/Kitsunebi-Example.xcscheme b/Example/Kitsunebi.xcodeproj/xcshareddata/xcschemes/Kitsunebi-Example.xcscheme index c2b76db..79913fa 100644 --- a/Example/Kitsunebi.xcodeproj/xcshareddata/xcschemes/Kitsunebi-Example.xcscheme +++ b/Example/Kitsunebi.xcodeproj/xcshareddata/xcschemes/Kitsunebi-Example.xcscheme @@ -41,6 +41,15 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> + + + + @@ -52,18 +61,17 @@ ReferencedContainer = "container:Kitsunebi.xcodeproj"> + + + + - - - - - - - - '../' end + +target 'Tests' do + pod 'Kitsunebi', :path => '../' +end diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 513c0cd..0663d03 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -11,6 +11,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Kitsunebi: 728531ae3060c166376b1a118c9a22b0f01e9d90 -PODFILE CHECKSUM: fd524ebd71fba6c1aaaa283f1d3b32f80fd19cda +PODFILE CHECKSUM: 76ed2f2b7a60b498883386901c667ffa48dbcb69 + +COCOAPODS: 1.10.0 -COCOAPODS: 1.9.3 diff --git a/Example/Tests/AssetTests.swift b/Example/Tests/AssetTests.swift new file mode 100644 index 0000000..4f6fd81 --- /dev/null +++ b/Example/Tests/AssetTests.swift @@ -0,0 +1,19 @@ +// +// AssetTests.swift +// Kitsunebi +// +// Created by Tomoya Hirano on 2020/11/13. +// Copyright © 2020 CocoaPods. All rights reserved. +// + +@testable import Kitsunebi +import XCTest + +class AssetTests: XCTestCase { + func testNotFatalBeforeReset() { + let asset = Asset(url: URL(fileURLWithPath: "")) + _ = asset.status + XCTAssert(true, "Pass") + } +} + diff --git a/Example/Tests/Info.plist b/Example/Tests/Info.plist index ba72822..64d65ca 100644 --- a/Example/Tests/Info.plist +++ b/Example/Tests/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - en + $(DEVELOPMENT_LANGUAGE) CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier @@ -13,11 +13,9 @@ CFBundleName $(PRODUCT_NAME) CFBundlePackageType - BNDL + $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString 1.0 - CFBundleSignature - ???? CFBundleVersion 1 diff --git a/Example/Tests/Tests.swift b/Example/Tests/Tests.swift index 37023a6..0638a46 100644 --- a/Example/Tests/Tests.swift +++ b/Example/Tests/Tests.swift @@ -1,28 +1,33 @@ +// +// Tests.swift +// Tests +// +// Created by Tomoya Hirano on 2020/11/13. +// Copyright © 2020 CocoaPods. All rights reserved. +// + import XCTest -import Kitsunebi class Tests: XCTestCase { - - override func setUp() { - super.setUp() + + override func setUpWithError() throws { // Put setup code here. This method is called before the invocation of each test method in the class. } - - override func tearDown() { + + override func tearDownWithError() throws { // Put teardown code here. This method is called after the invocation of each test method in the class. - super.tearDown() } - - func testExample() { + + func testExample() throws { // This is an example of a functional test case. - XCTAssert(true, "Pass") + // Use XCTAssert and related functions to verify your tests produce the correct results. } - - func testPerformanceExample() { + + func testPerformanceExample() throws { // This is an example of a performance test case. - self.measure() { + measure { // Put the code you want to measure the time of here. } } - + } diff --git a/Kitsunebi/Classes/Asset.swift b/Kitsunebi/Classes/Asset.swift index fd59b3e..7ea75e4 100644 --- a/Kitsunebi/Classes/Asset.swift +++ b/Kitsunebi/Classes/Asset.swift @@ -12,18 +12,17 @@ final class Asset { kCVPixelBufferMetalCompatibilityKey as String : true, ] let asset: AVURLAsset - lazy var reader: AVAssetReader = { preconditionFailure() }() - lazy var output: AVAssetReaderTrackOutput = { preconditionFailure() }() - var status: AVAssetReader.Status { return reader.status } - var isRunning: Bool { return reader.status != .completed && reader.status != .cancelled } + private var reader: AVAssetReader? = nil + private var output: AVAssetReaderTrackOutput? = nil + var status: AVAssetReader.Status? { reader?.status } init(url: URL) { asset = AVURLAsset(url: url) } func reset() throws { - reader = try AVAssetReader(asset: asset) - output = AVAssetReaderTrackOutput(track: asset.tracks(withMediaType: AVMediaType.video)[0], outputSettings: outputSettings) + let reader = try AVAssetReader(asset: asset) + let output = AVAssetReaderTrackOutput(track: asset.tracks(withMediaType: AVMediaType.video)[0], outputSettings: outputSettings) if reader.canAdd(output) { reader.add(output) } else { @@ -31,20 +30,23 @@ final class Asset { } output.alwaysCopiesSampleData = false reader.startReading() + + self.reader = reader + self.output = output } func cancelReading() { - reader.cancelReading() + reader?.cancelReading() } func copyNextImageBuffer() throws -> CVImageBuffer { - if let error = reader.error { + if let error = reader?.error { throw error } if status != .reading { throw AssetError.readerWasStopped } - if let sampleBuffer = output.copyNextSampleBuffer(), let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) { + if let sampleBuffer = output?.copyNextSampleBuffer(), let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) { return imageBuffer } else { throw AssetError.readerNotReturnedImage