diff --git a/.github/workflows/Xcode_build_test.yml b/.github/workflows/Xcode_build_test.yml index d61884a..116eb3d 100644 --- a/.github/workflows/Xcode_build_test.yml +++ b/.github/workflows/Xcode_build_test.yml @@ -1,7 +1,7 @@ name: Xcode_build_test env: - PACKAGES_JSON: '["MSCoreKit", "MSFoundation", "MSUIKit"]' + WORKSPACE: iOS/MusicSpot.xcworkspace on: pull_request: @@ -14,7 +14,7 @@ jobs: prepare-matrix: runs-on: macos-13 outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} + matrix: ${{ steps.generate-matrix.outputs.matrix }} steps: - uses: actions/checkout@v4 @@ -24,45 +24,21 @@ jobs: with: xcode-version: '15.0.1' - - name: Install jq - run: brew install jq - - name: Generate matrix - id: set-matrix + id: generate-matrix run: | - cd iOS matrix="{\"include\":[" - packages=$(echo $PACKAGES_JSON | jq -r '.[]') first_entry=true - for package in $packages; do - cd $package - for scheme in $(xcodebuild -list | grep -E '^[[:space:]]*Schemes:' -A 10 | tail -n +2 | grep -v '^$'); do - if [[ $scheme != *"-Package" ]] && [[ $scheme != *"Tests" ]]; then - if [ "$first_entry" = true ]; then - first_entry=false - else - matrix+="," - fi - matrix+="{\"package\":\"$package\", \"scheme\":\"$scheme\"}" + for scheme in $(xcodebuild -workspace ${{ env.WORKSPACE }} -list | grep -A 100 "Schemes:" | grep -v "Schemes:" | sed '/^$/d' | sed 's/^[ \t]*//'); do + if [[ $scheme != *"-Package" ]] && [[ $scheme != *"Tests" ]]; then + if [ "$first_entry" = true ]; then + first_entry=false + else + matrix+="," fi - done - cd .. + matrix+="{\"scheme\":\"$scheme\"}" + fi done - # cd Features - # for package in JourneyList SaveJourney; do - # cd $package - # for scheme in $(xcodebuild -list | grep -E '^[[:space:]]*Schemes:' -A 10 | tail -n +2 | grep -v '^$'); do - # if [[ $scheme != *"-Package" ]]; then - # if [ "$first_entry" = true ]; then - # first_entry=false - # else - # matrix+="," - # fi - # matrix+="{\"package\":\"$package\", \"scheme\":\"$scheme\"}" - # fi - # done - # cd .. - # done matrix+="]}" echo "matrix=$matrix" >> $GITHUB_OUTPUT @@ -82,11 +58,10 @@ jobs: xcode-version: '15.0.1' - name: ๐Ÿ› ๏ธ Build ${{ matrix.scheme }} - if: ${{ !contains(matrix.scheme, 'Tests') }} run: | - echo "๐Ÿ› ๏ธ Building ${{ matrix.package }} - Scheme: ${{ matrix.scheme }}" - cd iOS/${{ matrix.package }} + echo "๐Ÿ› ๏ธ Building ${{ matrix.scheme }}" xcodebuild \ + -workspace ${{ env.WORKSPACE }} \ -scheme ${{ matrix.scheme }} \ -sdk 'iphonesimulator' \ -destination 'platform=iOS Simulator,OS=17.0.1,name=iPhone 15 Pro' \ @@ -95,12 +70,33 @@ jobs: prepare-test-matrix: runs-on: macos-13 outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} + matrix: ${{ steps.generate-test-matrix.outputs.matrix }} steps: - - id: set-matrix - run: | - matrix="{\"package\": $PACKAGES_JSON}" - echo "matrix=$matrix" >> $GITHUB_OUTPUT + - uses: actions/checkout@v4 + + - name: Setup Xcode + if: ${{ !env.ACT }} + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '15.0.1' + + - name: Generate test matrix + id: generate-test-matrix + run: | + matrix="{\"include\":[" + first_entry=true + for scheme in $(xcodebuild -workspace ${{ env.WORKSPACE }} -list | grep -A 100 "Schemes:" | grep -v "Schemes:" | sed '/^$/d' | sed 's/^[ \t]*//'); do + if [[ $scheme == *"Tests" ]]; then + if [ "$first_entry" = true ]; then + first_entry=false + else + matrix+="," + fi + matrix+="{\"scheme\":\"$scheme\"}" + fi + done + matrix+="]}" + echo "matrix=$matrix" >> $GITHUB_OUTPUT xcode-test: needs: prepare-test-matrix @@ -117,12 +113,12 @@ jobs: with: xcode-version: '15.0.1' - - name: ๐Ÿงช Test ${{ matrix.package }} + - name: ๐Ÿงช Test ${{ matrix.scheme }} run: | - echo "๐Ÿงช Testing ${{ matrix.package }}" - cd iOS/${{ matrix.package }} + echo "๐Ÿงช Testing ${{ matrix.scheme }}" xcodebuild \ - -scheme ${{ matrix.package }}-Package \ + -workspace ${{ env.WORKSPACE }} \ + -scheme ${{ matrix.scheme }} \ -sdk 'iphonesimulator' \ -destination 'platform=iOS Simulator,OS=17.0.1,name=iPhone 15 Pro' \ - clean test + test diff --git a/iOS/Features/HomeMap/.gitignore b/iOS/Features/HomeMap/.gitignore new file mode 100644 index 0000000..0023a53 --- /dev/null +++ b/iOS/Features/HomeMap/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +/.build +/Packages +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/iOS/Features/HomeMap/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/iOS/Features/HomeMap/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/iOS/Features/HomeMap/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/iOS/Features/HomeMap/Package.swift b/iOS/Features/HomeMap/Package.swift new file mode 100644 index 0000000..791aac9 --- /dev/null +++ b/iOS/Features/HomeMap/Package.swift @@ -0,0 +1,18 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "HomeMap", + platforms: [ + .iOS(.v15) + ], + products: [ + .library(name: "HomeMap", + targets: ["HomeMap"]) + ], + targets: [ + .target(name: "HomeMap") + ] +) diff --git a/iOS/Features/HomeMap/Sources/HomeMap/HomeMap.swift b/iOS/Features/HomeMap/Sources/HomeMap/HomeMap.swift new file mode 100644 index 0000000..08b22b8 --- /dev/null +++ b/iOS/Features/HomeMap/Sources/HomeMap/HomeMap.swift @@ -0,0 +1,2 @@ +// The Swift Programming Language +// https://docs.swift.org/swift-book diff --git a/iOS/Features/JourneyList/.gitignore b/iOS/Features/JourneyList/.gitignore new file mode 100644 index 0000000..0023a53 --- /dev/null +++ b/iOS/Features/JourneyList/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +/.build +/Packages +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/iOS/Features/JourneyList/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/iOS/Features/JourneyList/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/iOS/Features/JourneyList/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/iOS/Features/JourneyList/Package.swift b/iOS/Features/JourneyList/Package.swift new file mode 100644 index 0000000..0920ee1 --- /dev/null +++ b/iOS/Features/JourneyList/Package.swift @@ -0,0 +1,27 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "JourneyList", + platforms: [ + .iOS(.v15) + ], + products: [ + .library(name: "JourneyList", + targets: ["JourneyList"]) + ], + dependencies: [ + .package(name: "MSData", + path: "../../MSData"), + .package(name: "MSUIKit", + path: "../../MSUIKit"), + .package(name: "MSNetworking", + path: "../../MSCoreKit") + ], + targets: [ + .target(name: "JourneyList", + dependencies: ["MSData", "MSUIKit", "MSNetworking"]) + ] +) diff --git a/iOS/Features/JourneyList/Sources/JourneyList/JourneyList.swift b/iOS/Features/JourneyList/Sources/JourneyList/JourneyList.swift new file mode 100644 index 0000000..08b22b8 --- /dev/null +++ b/iOS/Features/JourneyList/Sources/JourneyList/JourneyList.swift @@ -0,0 +1,2 @@ +// The Swift Programming Language +// https://docs.swift.org/swift-book diff --git a/iOS/Features/RecordJourney/.gitignore b/iOS/Features/RecordJourney/.gitignore new file mode 100644 index 0000000..0023a53 --- /dev/null +++ b/iOS/Features/RecordJourney/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +/.build +/Packages +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/iOS/Features/RecordJourney/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/iOS/Features/RecordJourney/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/iOS/Features/RecordJourney/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/iOS/Features/RecordJourney/Package.swift b/iOS/Features/RecordJourney/Package.swift new file mode 100644 index 0000000..ab62c81 --- /dev/null +++ b/iOS/Features/RecordJourney/Package.swift @@ -0,0 +1,18 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "RecordJourney", + platforms: [ + .iOS(.v15) + ], + products: [ + .library(name: "RecordJourney", + targets: ["RecordJourney"]) + ], + targets: [ + .target(name: "RecordJourney") + ] +) diff --git a/iOS/Features/RecordJourney/Sources/RecordJourney/RecordJourney.swift b/iOS/Features/RecordJourney/Sources/RecordJourney/RecordJourney.swift new file mode 100644 index 0000000..08b22b8 --- /dev/null +++ b/iOS/Features/RecordJourney/Sources/RecordJourney/RecordJourney.swift @@ -0,0 +1,2 @@ +// The Swift Programming Language +// https://docs.swift.org/swift-book diff --git a/iOS/Features/RewindJourney/.gitignore b/iOS/Features/RewindJourney/.gitignore new file mode 100644 index 0000000..0023a53 --- /dev/null +++ b/iOS/Features/RewindJourney/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +/.build +/Packages +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/iOS/Features/RewindJourney/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/iOS/Features/RewindJourney/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/iOS/Features/RewindJourney/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/iOS/Features/RewindJourney/Package.swift b/iOS/Features/RewindJourney/Package.swift new file mode 100644 index 0000000..fbd5d5c --- /dev/null +++ b/iOS/Features/RewindJourney/Package.swift @@ -0,0 +1,56 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +// MARK: - Constants + +extension String { + static let package = "RewindJourney" + static let rewindJourney = "RewindJourney" + static let msUIKit = "MSUIKit" + static let msFoundation = "MSFoundation" + static let msDesignsystem = "MSDesignSystem" + static let msLogger = "MSLogger" + + var testTarget: String { + return self + "Tests" + } + + var path: String { + return "../../" + self + } + + var featurePath: String { + return "../Features/" + self + } + +} + +// MARK: - Package + +let package = Package( + name: .package, + platforms: [ + .iOS(.v15) + ], + products: [ + .library(name: .rewindJourney, + targets: [.rewindJourney]) + ], + dependencies: [ + .package(path: .msUIKit.path), + .package(path: .msFoundation.path) + ], + targets: [ + // Codes + .target(name: .rewindJourney, + dependencies: [ + .product(name: .msUIKit, package: .msUIKit), + .product(name: .msDesignsystem, package: .msUIKit), + .product(name: .msLogger, package: .msFoundation) + ]) + + // Tests + ] +) diff --git a/iOS/Features/RewindJourney/Sources/RewindJourney/RewindJourney.swift b/iOS/Features/RewindJourney/Sources/RewindJourney/RewindJourney.swift new file mode 100644 index 0000000..08b22b8 --- /dev/null +++ b/iOS/Features/RewindJourney/Sources/RewindJourney/RewindJourney.swift @@ -0,0 +1,2 @@ +// The Swift Programming Language +// https://docs.swift.org/swift-book diff --git a/iOS/Features/RewindJourney/Tests/RewindJourneyTests/RewindJourneyTests.swift b/iOS/Features/RewindJourney/Tests/RewindJourneyTests/RewindJourneyTests.swift new file mode 100644 index 0000000..b8c4d4a --- /dev/null +++ b/iOS/Features/RewindJourney/Tests/RewindJourneyTests/RewindJourneyTests.swift @@ -0,0 +1,12 @@ +import XCTest +@testable import RewindJourney + +final class RewindJourneyTests: XCTestCase { + func testExample() throws { + // XCTest Documentation + // https://developer.apple.com/documentation/xctest + + // Defining Test Cases and Test Methods + // https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods + } +} diff --git a/iOS/Features/SaveJourney/.gitignore b/iOS/Features/SaveJourney/.gitignore new file mode 100644 index 0000000..0023a53 --- /dev/null +++ b/iOS/Features/SaveJourney/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +/.build +/Packages +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/iOS/Features/SaveJourney/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/iOS/Features/SaveJourney/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/iOS/Features/SaveJourney/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/iOS/Features/SaveJourney/Package.swift b/iOS/Features/SaveJourney/Package.swift new file mode 100644 index 0000000..490cd31 --- /dev/null +++ b/iOS/Features/SaveJourney/Package.swift @@ -0,0 +1,23 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "SaveJourney", + platforms: [ + .iOS(.v15) + ], + products: [ + .library(name: "SaveJourney", + targets: ["SaveJourney"]) + ], + dependencies: [ + .package(name: "MSUIKit", + path: "../../MSUIKit") + ], + targets: [ + .target(name: "SaveJourney", + dependencies: ["MSUIKit"]) + ] +) diff --git a/iOS/Features/SaveJourney/Sources/SaveJourney/SaveJourney.swift b/iOS/Features/SaveJourney/Sources/SaveJourney/SaveJourney.swift new file mode 100644 index 0000000..08b22b8 --- /dev/null +++ b/iOS/Features/SaveJourney/Sources/SaveJourney/SaveJourney.swift @@ -0,0 +1,2 @@ +// The Swift Programming Language +// https://docs.swift.org/swift-book diff --git a/iOS/Features/SelectSong/.gitignore b/iOS/Features/SelectSong/.gitignore new file mode 100644 index 0000000..0023a53 --- /dev/null +++ b/iOS/Features/SelectSong/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +/.build +/Packages +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/iOS/Features/SelectSong/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/iOS/Features/SelectSong/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/iOS/Features/SelectSong/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/iOS/Features/SelectSong/Package.swift b/iOS/Features/SelectSong/Package.swift new file mode 100644 index 0000000..b78d896 --- /dev/null +++ b/iOS/Features/SelectSong/Package.swift @@ -0,0 +1,18 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "SelectSong", + platforms: [ + .iOS(.v15) + ], + products: [ + .library(name: "SelectSong", + targets: ["SelectSong"]) + ], + targets: [ + .target(name: "SelectSong") + ] +) diff --git a/iOS/Features/SelectSong/Sources/SelectSong/SelectSong.swift b/iOS/Features/SelectSong/Sources/SelectSong/SelectSong.swift new file mode 100644 index 0000000..08b22b8 --- /dev/null +++ b/iOS/Features/SelectSong/Sources/SelectSong/SelectSong.swift @@ -0,0 +1,2 @@ +// The Swift Programming Language +// https://docs.swift.org/swift-book diff --git a/iOS/Features/Spot/.gitignore b/iOS/Features/Spot/.gitignore new file mode 100644 index 0000000..0023a53 --- /dev/null +++ b/iOS/Features/Spot/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +/.build +/Packages +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/iOS/Features/Spot/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/iOS/Features/Spot/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/iOS/Features/Spot/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/iOS/Features/Spot/Package.swift b/iOS/Features/Spot/Package.swift new file mode 100644 index 0000000..68e4d11 --- /dev/null +++ b/iOS/Features/Spot/Package.swift @@ -0,0 +1,52 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +// MARK: - Constants + +extension String { + static let package = "Spot" + static let spot = "Spot" + static let msUIKit = "MSUIKit" + static let msFoundation = "MSFoundation" + static let msDesignsystem = "MSDesignSystem" + static let msLogger = "MSLogger" + + var testTarget: String { + return self + "Tests" + } + + var path: String { + return "../../" + self + } + +} + +// MARK: - Package + +let package = Package( + name: .package, + platforms: [ + .iOS(.v15) + ], + products: [ + .library(name: .spot, + targets: [.spot]) + ], + dependencies: [ + .package(path: .msUIKit.path), + .package(path: .msFoundation.path) + ], + targets: [ + // Codes + .target(name: .spot, + dependencies: [ + .product(name: .msUIKit, package: .msUIKit), + .product(name: .msDesignsystem, package: .msUIKit), + .product(name: .msLogger, package: .msFoundation) + ]) + + // Tests + ] +) diff --git a/iOS/Features/Spot/Sources/Spot/Spot.swift b/iOS/Features/Spot/Sources/Spot/Spot.swift new file mode 100644 index 0000000..08b22b8 --- /dev/null +++ b/iOS/Features/Spot/Sources/Spot/Spot.swift @@ -0,0 +1,2 @@ +// The Swift Programming Language +// https://docs.swift.org/swift-book diff --git a/iOS/MSCoreKit/.swiftpm/xcode/xcshareddata/xcschemes/MSCacheStorage.xcscheme b/iOS/MSCoreKit/.swiftpm/xcode/xcshareddata/xcschemes/MSCacheStorage.xcscheme index 1113d29..a20692e 100644 --- a/iOS/MSCoreKit/.swiftpm/xcode/xcshareddata/xcschemes/MSCacheStorage.xcscheme +++ b/iOS/MSCoreKit/.swiftpm/xcode/xcshareddata/xcschemes/MSCacheStorage.xcscheme @@ -28,6 +28,18 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" shouldAutocreateTestPlan = "YES"> + + + + + + + + + + + + + + + + + + + + + + + + Value? - func cleanDisk() throws -} - -public final class MSCacheStorage: KeyValueStorage { - - public typealias Key = NSString - public typealias Cache = NSCache - - // MARK: - Properties - - private let memory: Cache - private let disk: FileManager - - // MARK: - Initializer - - public init(cache: Cache = Cache(), - fileManager: FileManager = .default) { - self.memory = cache - self.disk = fileManager - } - - // MARK: - Functions - - /// ์บ์‹ฑ๋œ ๋ฐ์ดํ„ฐ๋ฅผ ๋ถˆ๋Ÿฌ์˜ต๋‹ˆ๋‹ค. - public func data(forKey key: String, etag: String? = nil) async -> MSCacheableData? { - // Memory Cache - if let memoryData = memory.object(forKey: key as NSString) { // memory hit - // TODO: ์„œ๋ฒ„์™€ ๋ฐ์ดํ„ฐ ๊ฒ€์ฆ ํ•„์š” (etag ํ™œ์šฉ) - return memoryData - } - - // Disk Cache - if let cacheURL = cacheURL(forCache: "\(key).cache"), - let diskData = disk.contents(atPath: cacheURL.path) { // disk hit - // TODO: ์„œ๋ฒ„์™€ ๋ฐ์ดํ„ฐ ๊ฒ€์ฆ ํ•„์š” (etag ํ™œ์šฉ) - let decoder = JSONDecoder() - return try? decoder.decode(MSCacheableData.self, from: diskData) - } - - // Request - // TODO: ์„œ๋ฒ„๋กœ๋ถ€ํ„ฐ ๋ฐ์ดํ„ฐ ์ˆ˜์‹  ๋ฐ ์บ์‹ฑ + return ๊ฐ’ ๋ณ€๊ฒฝ - return nil - } - - public func cleanDisk() throws { - if let path = cacheDirectoryURL?.path { - try disk.removeItem(atPath: path) - } - } - -} - -// MARK: - URLs - -private extension MSCacheStorage { - - var cacheDirectoryURL: URL? { - if #available(iOS 16.0, *) { - return try? disk.url(for: .cachesDirectory, - in: .userDomainMask, - appropriateFor: .cachesDirectory, - create: true) - } else { - return disk - .urls(for: .cachesDirectory, in: .userDomainMask) - .first - } - } - - func cacheURL(forCache cache: String) -> URL? { - if #available(iOS 16.0, *) { - return cacheDirectoryURL? - .appending(path: "MusicSpot", directoryHint: .isDirectory) - .appending(component: cache, directoryHint: .notDirectory) - } else { - return cacheDirectoryURL? - .appendingPathExtension("MusicSpot") - .appendingPathComponent(cache) - } - } - -} diff --git a/iOS/MSCoreKit/Sources/MSCacheStorage/MSCacheableData.swift b/iOS/MSCoreKit/Sources/MSCacheStorage/MSCacheableData.swift deleted file mode 100644 index 4bdf3c8..0000000 --- a/iOS/MSCoreKit/Sources/MSCacheStorage/MSCacheableData.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// MSCacheableData.swift -// MSCoreKit -// -// Created by ์ด์ฐฝ์ค€ on 11/15/23. -// - -import Foundation - -public final class MSCacheableData: Codable { - - struct Metadata: Hashable, Codable { - let etag: String - let lastUsed: Date - } - - // MARK: - Properties - - let data: Data - let metadata: Metadata - - // MARK: - Initializer - - public init(data: Data, etag: String) { - self.data = data - self.metadata = Metadata(etag: etag, lastUsed: .now) - } - -} diff --git a/iOS/MSCoreKit/Sources/MSCacheStorage/MSImageCacheStorage.swift b/iOS/MSCoreKit/Sources/MSCacheStorage/MSImageCacheStorage.swift new file mode 100644 index 0000000..af47f8e --- /dev/null +++ b/iOS/MSCoreKit/Sources/MSCacheStorage/MSImageCacheStorage.swift @@ -0,0 +1,84 @@ +// +// MSImageCacheStorage.swift +// MSCoreKit +// +// Created by ์ด์ฐฝ์ค€ on 11/14/23. +// + +import Foundation + +public final class MSImageCacheStorage: CacheStorage { + + public typealias Cache = NSCache + + // MARK: - Properties + + private let memory: Cache + private let disk: FileManager + + private let decoder = JSONDecoder() + + // MARK: - Initializer + + public init(cache: Cache = Cache(), + fileManager: FileManager = .default) { + self.memory = cache + self.disk = fileManager + } + + // MARK: - Functions + + /// ์บ์‹ฑ๋œ ๋ฐ์ดํ„ฐ๋ฅผ ๋ถˆ๋Ÿฌ์˜ต๋‹ˆ๋‹ค. + public func data(forKey key: NSString) async -> NSData? { + // Memory Cache + if let memoryData = self.memory.object(forKey: key as NSString) { // memory hit + return memoryData + } + + // Disk Cache + if let cacheURL = self.cacheURL(forCache: "\(key).cache"), + let diskData = self.disk.contents(atPath: cacheURL.path) { // disk hit + + } + + return nil + } + + public func cleanDisk() throws { + if let path = self.cacheDirectoryURL?.path { + try self.disk.removeItem(atPath: path) + } + } + +} + +// MARK: - URLs + +private extension MSImageCacheStorage { + + var cacheDirectoryURL: URL? { + if #available(iOS 16.0, *) { + return try? self.disk.url(for: .cachesDirectory, + in: .userDomainMask, + appropriateFor: .cachesDirectory, + create: true) + } else { + return self.disk + .urls(for: .cachesDirectory, in: .userDomainMask) + .first + } + } + + func cacheURL(forCache cache: String) -> URL? { + if #available(iOS 16.0, *) { + return self.cacheDirectoryURL? + .appending(path: "MusicSpot", directoryHint: .isDirectory) + .appending(component: cache, directoryHint: .notDirectory) + } else { + return self.cacheDirectoryURL? + .appendingPathExtension("MusicSpot") + .appendingPathComponent(cache) + } + } + +} diff --git a/iOS/MSCoreKit/Sources/MSCacheStorage/Protocol/CacheStorage.swift b/iOS/MSCoreKit/Sources/MSCacheStorage/Protocol/CacheStorage.swift new file mode 100644 index 0000000..0cf1970 --- /dev/null +++ b/iOS/MSCoreKit/Sources/MSCacheStorage/Protocol/CacheStorage.swift @@ -0,0 +1,22 @@ +// +// CacheStorage.swift +// MSCoreKit +// +// Created by ์ด์ฐฝ์ค€ on 2023.11.28. +// + +import Foundation + +public protocol CacheStorage { + + associatedtype Key: AnyObject = NSString + associatedtype Value: AnyObject + + typealias Cache = NSCache + + // MARK: - Functions + + func data(forKey key: Key) async -> Value? + func cleanDisk() throws + +} diff --git a/iOS/MSCoreKit/Sources/MSNetworking/MSRouter.swift b/iOS/MSCoreKit/Sources/MSNetworking/MSRouter.swift deleted file mode 100644 index 62158bc..0000000 --- a/iOS/MSCoreKit/Sources/MSNetworking/MSRouter.swift +++ /dev/null @@ -1,42 +0,0 @@ -// -// MSRouter.swift -// MSCoreKit -// -// Created by ์ „๋ฏผ๊ฑด on 11/16/23. -// - -import Foundation - -public struct RouterType { - - private var encodable: Encodable? - - //๊ธฐ๋Šฅ๋ณ„ MSRouter - public var getJourney: MSRouter { - MSRouter(baseURL: .none, pathURL: .none, method: .get, body: HTTPBody(content: encodable)) - } - public var getPerson: MSRouter { - MSRouter(baseURL: .none, pathURL: .none, method: .get, body: HTTPBody(content: encodable)) - } - -} - -public struct MSRouter: Router { - - let baseURL: APIbaseURL - let pathURL: APIpathURL - let method: HTTPMethod - var body: HTTPBody - - func asURLRequest() -> URLRequest? { - guard let url = URL(string: baseURL.rawValue + pathURL.rawValue) else { - return nil - } - var request = URLRequest(url: url) - request.httpMethod = method.rawValue - request.httpBody = body.contentToData() - - return request - } - -} diff --git a/iOS/MSData/.gitignore b/iOS/MSData/.gitignore new file mode 100644 index 0000000..0023a53 --- /dev/null +++ b/iOS/MSData/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +/.build +/Packages +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/iOS/MSData/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/iOS/MSData/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/iOS/MSData/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/iOS/MSData/.swiftpm/xcode/xcshareddata/xcschemes/MSData.xcscheme b/iOS/MSData/.swiftpm/xcode/xcshareddata/xcschemes/MSData.xcscheme new file mode 100644 index 0000000..fdac714 --- /dev/null +++ b/iOS/MSData/.swiftpm/xcode/xcshareddata/xcschemes/MSData.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS/MSData/.swiftpm/xcode/xcshareddata/xcschemes/MSDataTests.xcscheme b/iOS/MSData/.swiftpm/xcode/xcshareddata/xcschemes/MSDataTests.xcscheme new file mode 100644 index 0000000..c0fb639 --- /dev/null +++ b/iOS/MSData/.swiftpm/xcode/xcshareddata/xcschemes/MSDataTests.xcscheme @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS/MSData/Package.swift b/iOS/MSData/Package.swift new file mode 100644 index 0000000..bffa772 --- /dev/null +++ b/iOS/MSData/Package.swift @@ -0,0 +1,25 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. +import PackageDescription + +let package = Package( + name: "MSData", + platforms: [ + .iOS(.v15) + ], + products: [ + .library(name: "MSData", + targets: ["MSData"]) + ], + dependencies: [ + .package(name: "MSNetworking", + path: "../MSCoreKit") + ], + targets: [ + .target(name: "MSData", + dependencies: ["MSNetworking"], + resources: [.process("Resources")]), + .testTarget(name: "MSDataTests", + dependencies: ["MSData"]) + ] +) diff --git a/iOS/MSData/Sources/MSData/MSData.swift b/iOS/MSData/Sources/MSData/MSData.swift new file mode 100644 index 0000000..08b22b8 --- /dev/null +++ b/iOS/MSData/Sources/MSData/MSData.swift @@ -0,0 +1,2 @@ +// The Swift Programming Language +// https://docs.swift.org/swift-book diff --git a/iOS/MSData/Tests/MSDataTests/MSDataTests.swift b/iOS/MSData/Tests/MSDataTests/MSDataTests.swift new file mode 100644 index 0000000..18cf9e1 --- /dev/null +++ b/iOS/MSData/Tests/MSDataTests/MSDataTests.swift @@ -0,0 +1,12 @@ +import XCTest +@testable import MSData + +final class MSDataTests: XCTestCase { + func testExample() throws { + // XCTest Documentation + // https://developer.apple.com/documentation/xctest + + // Defining Test Cases and Test Methods + // https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods + } +} diff --git a/iOS/MSFoundation/.swiftpm/xcode/xcshareddata/xcschemes/MSLogger.xcscheme b/iOS/MSFoundation/.swiftpm/xcode/xcshareddata/xcschemes/MSLogger.xcscheme index c44d62d..04b9652 100644 --- a/iOS/MSFoundation/.swiftpm/xcode/xcshareddata/xcschemes/MSLogger.xcscheme +++ b/iOS/MSFoundation/.swiftpm/xcode/xcshareddata/xcschemes/MSLogger.xcscheme @@ -28,6 +28,18 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" shouldAutocreateTestPlan = "YES"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS/MSUIKit/Package.swift b/iOS/MSUIKit/Package.swift index 0e5acca..f100a0e 100644 --- a/iOS/MSUIKit/Package.swift +++ b/iOS/MSUIKit/Package.swift @@ -36,11 +36,7 @@ let package = Package( .process("../MSDesignSystem/Resources") ]), .target(name: .uiKit, - dependencies: ["MSDesignSystem"]), - - // Tests - .testTarget(name: .designSystem.testTarget, - dependencies: ["MSDesignSystem"]) + dependencies: ["MSDesignSystem"]) ], swiftLanguageVersions: [.v5] ) diff --git a/iOS/MSUIKit/Sources/MSDesignSystem/Resources/MSIcon.xcassets/Calender.imageset/Calender.pdf b/iOS/MSUIKit/Sources/MSDesignSystem/Resources/MSIcon.xcassets/Calendar.imageset/Calender.pdf similarity index 100% rename from iOS/MSUIKit/Sources/MSDesignSystem/Resources/MSIcon.xcassets/Calender.imageset/Calender.pdf rename to iOS/MSUIKit/Sources/MSDesignSystem/Resources/MSIcon.xcassets/Calendar.imageset/Calender.pdf diff --git a/iOS/MSUIKit/Sources/MSDesignSystem/Resources/MSIcon.xcassets/Calender.imageset/Contents.json b/iOS/MSUIKit/Sources/MSDesignSystem/Resources/MSIcon.xcassets/Calendar.imageset/Contents.json similarity index 100% rename from iOS/MSUIKit/Sources/MSDesignSystem/Resources/MSIcon.xcassets/Calender.imageset/Contents.json rename to iOS/MSUIKit/Sources/MSDesignSystem/Resources/MSIcon.xcassets/Calendar.imageset/Contents.json diff --git a/iOS/MSUIKit/Sources/MSDesignSystem/Resources/MSIcon.xcassets/Calender.imageset/Calender 1.pdf b/iOS/MSUIKit/Sources/MSDesignSystem/Resources/MSIcon.xcassets/Calender.imageset/Calender 1.pdf deleted file mode 100644 index 8830486..0000000 Binary files a/iOS/MSUIKit/Sources/MSDesignSystem/Resources/MSIcon.xcassets/Calender.imageset/Calender 1.pdf and /dev/null differ diff --git a/iOS/MSUIKit/Tests/MSDesignSystemTests/MSDesignSystemTests.swift b/iOS/MSUIKit/Tests/MSDesignSystemTests/MSDesignSystemTests.swift deleted file mode 100644 index 7eebb79..0000000 --- a/iOS/MSUIKit/Tests/MSDesignSystemTests/MSDesignSystemTests.swift +++ /dev/null @@ -1,10 +0,0 @@ -// -// MSDesignSystemTests.swift -// MSUIKit -// -// Created by ์ด์ฐฝ์ค€ on 11/26/23. -// - -import XCTest - -final class MSDesignSystemTests: XCTestCase { } diff --git a/iOS/MusicSpot.xcworkspace/contents.xcworkspacedata b/iOS/MusicSpot.xcworkspace/contents.xcworkspacedata index 8cad135..63c9482 100644 --- a/iOS/MusicSpot.xcworkspace/contents.xcworkspacedata +++ b/iOS/MusicSpot.xcworkspace/contents.xcworkspacedata @@ -2,21 +2,39 @@ + location = "group:MusicSpot/MusicSpot.xcodeproj"> + + + + + + + + + location = "group:Features/JourneyList"> + location = "group:Features/RewindJourney"> + location = "group:MSData"> + + + + diff --git a/iOS/MusicSpot/MusicSpot.xcodeproj/project.pbxproj b/iOS/MusicSpot/MusicSpot.xcodeproj/project.pbxproj index 2a1c470..7c15359 100644 --- a/iOS/MusicSpot/MusicSpot.xcodeproj/project.pbxproj +++ b/iOS/MusicSpot/MusicSpot.xcodeproj/project.pbxproj @@ -3,14 +3,10 @@ archiveVersion = 1; classes = { }; - objectVersion = 60; + objectVersion = 56; objects = { /* Begin PBXBuildFile section */ - 21B1B63D2B04C7CF00A63287 /* FoundationExt in Frameworks */ = {isa = PBXBuildFile; productRef = 21B1B63C2B04C7CF00A63287 /* FoundationExt */; }; - 21B1B63F2B04C7CF00A63287 /* MSLogger in Frameworks */ = {isa = PBXBuildFile; productRef = 21B1B63E2B04C7CF00A63287 /* MSLogger */; }; - 21B1B6412B04C7CF00A63287 /* MSUserDefaults in Frameworks */ = {isa = PBXBuildFile; productRef = 21B1B6402B04C7CF00A63287 /* MSUserDefaults */; }; - 21B1B6442B04D64A00A63287 /* MSNetwork in Frameworks */ = {isa = PBXBuildFile; productRef = 21B1B6432B04D64A00A63287 /* MSNetwork */; }; DD73F8592B024C4900EE9BF2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD73F8582B024C4900EE9BF2 /* AppDelegate.swift */; }; DD73F85B2B024C4900EE9BF2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD73F85A2B024C4900EE9BF2 /* SceneDelegate.swift */; }; DD73F8622B024C4B00EE9BF2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DD73F8612B024C4B00EE9BF2 /* Assets.xcassets */; }; @@ -32,23 +28,12 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 21B1B63F2B04C7CF00A63287 /* MSLogger in Frameworks */, - 21B1B6412B04C7CF00A63287 /* MSUserDefaults in Frameworks */, - 21B1B63D2B04C7CF00A63287 /* FoundationExt in Frameworks */, - 21B1B6442B04D64A00A63287 /* MSNetwork in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 2137DBFD2B063A1500395C06 /* Frameworks */ = { - isa = PBXGroup; - children = ( - ); - name = Frameworks; - sourceTree = ""; - }; DD73F84C2B024C4900EE9BF2 = { isa = PBXGroup; children = ( @@ -94,10 +79,6 @@ ); name = MusicSpot; packageProductDependencies = ( - 21B1B63C2B04C7CF00A63287 /* FoundationExt */, - 21B1B63E2B04C7CF00A63287 /* MSLogger */, - 21B1B6402B04C7CF00A63287 /* MSUserDefaults */, - 21B1B6432B04D64A00A63287 /* MSNetwork */, ); productName = MusicSpot; productReference = DD73F8552B024C4900EE9BF2 /* MusicSpot.app */; @@ -128,8 +109,6 @@ ); mainGroup = DD73F84C2B024C4900EE9BF2; packageReferences = ( - 21B1B63B2B04C7CF00A63287 /* XCLocalSwiftPackageReference "../MSFoundation" */, - 21B1B6422B04D64A00A63287 /* XCLocalSwiftPackageReference "../MSNetwork" */, ); productRefGroup = DD73F8562B024C4900EE9BF2 /* Products */; projectDirPath = ""; @@ -386,36 +365,6 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ - -/* Begin XCLocalSwiftPackageReference section */ - 21B1B63B2B04C7CF00A63287 /* XCLocalSwiftPackageReference "../MSFoundation" */ = { - isa = XCLocalSwiftPackageReference; - relativePath = ../MSFoundation; - }; - 21B1B6422B04D64A00A63287 /* XCLocalSwiftPackageReference "../MSNetwork" */ = { - isa = XCLocalSwiftPackageReference; - relativePath = ../MSNetwork; - }; -/* End XCLocalSwiftPackageReference section */ - -/* Begin XCSwiftPackageProductDependency section */ - 21B1B63C2B04C7CF00A63287 /* FoundationExt */ = { - isa = XCSwiftPackageProductDependency; - productName = FoundationExt; - }; - 21B1B63E2B04C7CF00A63287 /* MSLogger */ = { - isa = XCSwiftPackageProductDependency; - productName = MSLogger; - }; - 21B1B6402B04C7CF00A63287 /* MSUserDefaults */ = { - isa = XCSwiftPackageProductDependency; - productName = MSUserDefaults; - }; - 21B1B6432B04D64A00A63287 /* MSNetwork */ = { - isa = XCSwiftPackageProductDependency; - productName = MSNetwork; - }; -/* End XCSwiftPackageProductDependency section */ }; rootObject = DD73F84D2B024C4900EE9BF2 /* Project object */; } diff --git a/iOS/MusicSpot/MusicSpot.xcodeproj/xcshareddata/xcschemes/MusicSpot.xcscheme b/iOS/MusicSpot/MusicSpot.xcodeproj/xcshareddata/xcschemes/MusicSpot.xcscheme new file mode 100644 index 0000000..7eb04dc --- /dev/null +++ b/iOS/MusicSpot/MusicSpot.xcodeproj/xcshareddata/xcschemes/MusicSpot.xcscheme @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS/commit b/iOS/commit index 144cec4..2355a98 100755 --- a/iOS/commit +++ b/iOS/commit @@ -1,7 +1,7 @@ #!/bin/sh LINTPATH='.swiftlint.yml' -declare -a PATHS=("MSCoreKit" "MSFoundation" "MSUIKit" "MusicSpot") +declare -a PATHS=("MSCoreKit" "MSFoundation" "MSUIKit" "MSData" "MusicSpot" "Features") failures="" for path in "${PATHS[@]}"; do