diff --git a/movie/movie.xcodeproj/project.pbxproj b/movie/movie.xcodeproj/project.pbxproj new file mode 100644 index 0000000..6e1d095 --- /dev/null +++ b/movie/movie.xcodeproj/project.pbxproj @@ -0,0 +1,401 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXBuildFile section */ + A4FEF61E2EF26F7600576371 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = A4FEF61D2EF26F7600576371 /* SnapKit */; }; + A4FEF6212EF26F8000576371 /* Then in Frameworks */ = {isa = PBXBuildFile; productRef = A4FEF6202EF26F8000576371 /* Then */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + A4FEF5E22EF197D300576371 /* movie.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = movie.app; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ + A4FEF5F42EF197D500576371 /* Exceptions for "movie" folder in "movie" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + Info.plist, + ); + target = A4FEF5E12EF197D300576371 /* movie */; + }; +/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + A4FEF5E42EF197D300576371 /* movie */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + A4FEF5F42EF197D500576371 /* Exceptions for "movie" folder in "movie" target */, + ); + path = movie; + sourceTree = ""; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + +/* Begin PBXFrameworksBuildPhase section */ + A4FEF5DF2EF197D300576371 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + A4FEF61E2EF26F7600576371 /* SnapKit in Frameworks */, + A4FEF6212EF26F8000576371 /* Then in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + A4FEF5D92EF197D300576371 = { + isa = PBXGroup; + children = ( + A4FEF5E42EF197D300576371 /* movie */, + A4FEF5E32EF197D300576371 /* Products */, + ); + sourceTree = ""; + }; + A4FEF5E32EF197D300576371 /* Products */ = { + isa = PBXGroup; + children = ( + A4FEF5E22EF197D300576371 /* movie.app */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + A4FEF5E12EF197D300576371 /* movie */ = { + isa = PBXNativeTarget; + buildConfigurationList = A4FEF5F52EF197D500576371 /* Build configuration list for PBXNativeTarget "movie" */; + buildPhases = ( + A4FEF5DE2EF197D300576371 /* Sources */, + A4FEF5DF2EF197D300576371 /* Frameworks */, + A4FEF5E02EF197D300576371 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + A4FEF5E42EF197D300576371 /* movie */, + ); + name = movie; + packageProductDependencies = ( + A4FEF61D2EF26F7600576371 /* SnapKit */, + A4FEF6202EF26F8000576371 /* Then */, + ); + productName = movie; + productReference = A4FEF5E22EF197D300576371 /* movie.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + A4FEF5DA2EF197D300576371 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 2600; + LastUpgradeCheck = 2600; + TargetAttributes = { + A4FEF5E12EF197D300576371 = { + CreatedOnToolsVersion = 26.0.1; + }; + }; + }; + buildConfigurationList = A4FEF5DD2EF197D300576371 /* Build configuration list for PBXProject "movie" */; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = A4FEF5D92EF197D300576371; + minimizedProjectReferenceProxies = 1; + packageReferences = ( + A4FEF61C2EF26F7600576371 /* XCRemoteSwiftPackageReference "SnapKit" */, + A4FEF61F2EF26F8000576371 /* XCRemoteSwiftPackageReference "Then" */, + ); + preferredProjectObjectVersion = 77; + productRefGroup = A4FEF5E32EF197D300576371 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + A4FEF5E12EF197D300576371 /* movie */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + A4FEF5E02EF197D300576371 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + A4FEF5DE2EF197D300576371 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + A4FEF5F62EF197D500576371 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = A4FEF5E42EF197D300576371 /* movie */; + baseConfigurationReferenceRelativePath = Config.xcconfig; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 6B47X24XTW; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = movie/Info.plist; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.movie; + PRODUCT_NAME = "$(TARGET_NAME)"; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + A4FEF5F72EF197D500576371 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = A4FEF5E42EF197D300576371 /* movie */; + baseConfigurationReferenceRelativePath = Config.xcconfig; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 6B47X24XTW; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = movie/Info.plist; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.movie; + PRODUCT_NAME = "$(TARGET_NAME)"; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + A4FEF5F82EF197D500576371 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = A4FEF5E42EF197D300576371 /* movie */; + baseConfigurationReferenceRelativePath = Config.xcconfig; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + 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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + 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; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = 6B47X24XTW; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + 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 = 26.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + A4FEF5F92EF197D500576371 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = A4FEF5E42EF197D300576371 /* movie */; + baseConfigurationReferenceRelativePath = Config.xcconfig; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + 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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + 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; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = 6B47X24XTW; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + 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 = 26.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + A4FEF5DD2EF197D300576371 /* Build configuration list for PBXProject "movie" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A4FEF5F82EF197D500576371 /* Debug */, + A4FEF5F92EF197D500576371 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A4FEF5F52EF197D500576371 /* Build configuration list for PBXNativeTarget "movie" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A4FEF5F62EF197D500576371 /* Debug */, + A4FEF5F72EF197D500576371 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + A4FEF61C2EF26F7600576371 /* XCRemoteSwiftPackageReference "SnapKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SnapKit/SnapKit.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.7.1; + }; + }; + A4FEF61F2EF26F8000576371 /* XCRemoteSwiftPackageReference "Then" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/devxoul/Then"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 3.0.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + A4FEF61D2EF26F7600576371 /* SnapKit */ = { + isa = XCSwiftPackageProductDependency; + package = A4FEF61C2EF26F7600576371 /* XCRemoteSwiftPackageReference "SnapKit" */; + productName = SnapKit; + }; + A4FEF6202EF26F8000576371 /* Then */ = { + isa = XCSwiftPackageProductDependency; + package = A4FEF61F2EF26F8000576371 /* XCRemoteSwiftPackageReference "Then" */; + productName = Then; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = A4FEF5DA2EF197D300576371 /* Project object */; +} diff --git a/movie/movie.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/movie/movie.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/movie/movie.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/movie/movie/AppDelegate.swift b/movie/movie/AppDelegate.swift new file mode 100644 index 0000000..cce2829 --- /dev/null +++ b/movie/movie/AppDelegate.swift @@ -0,0 +1,36 @@ +// +// AppDelegate.swift +// movie +// +// Created by sun on 12/16/25. +// + +import UIKit + +@main +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/movie/movie/Assets.xcassets/AccentColor.colorset/Contents.json b/movie/movie/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/movie/movie/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/movie/movie/Assets.xcassets/AppIcon.appiconset/Contents.json b/movie/movie/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..2305880 --- /dev/null +++ b/movie/movie/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,35 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "tinted" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/movie/movie/Assets.xcassets/Contents.json b/movie/movie/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/movie/movie/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/movie/movie/Base.lproj/LaunchScreen.storyboard b/movie/movie/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/movie/movie/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/movie/movie/Info.plist b/movie/movie/Info.plist new file mode 100644 index 0000000..f39e297 --- /dev/null +++ b/movie/movie/Info.plist @@ -0,0 +1,27 @@ + + + + + KOBIS_API_KEY + $(KOBIS_API_KEY) + BASE_URL + $(BASE_URL) + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + + + + + + diff --git a/movie/movie/Network/Base/BaseResponseBody.swift b/movie/movie/Network/Base/BaseResponseBody.swift new file mode 100644 index 0000000..777b1bf --- /dev/null +++ b/movie/movie/Network/Base/BaseResponseBody.swift @@ -0,0 +1,14 @@ +// +// BaseResponseBody.swift +// movie +// +// Created by sun on 12/17/25. +// + +import Foundation + +struct BaseResponseBody: ResponseModelType { + let code: Int + let message: String + let data: T +} diff --git a/movie/movie/Network/Base/BaseService.swift b/movie/movie/Network/Base/BaseService.swift new file mode 100644 index 0000000..e62fd27 --- /dev/null +++ b/movie/movie/Network/Base/BaseService.swift @@ -0,0 +1,87 @@ +// +// BaseService.swift +// movie +// +// Created by sun on 12/17/25. +// + +import Foundation + +class BaseService { + let provider = NetworkProvider() + + func request(with target: Target) async throws -> BaseResponseBody { + + let urlRequest = try provider.makeRequest(target) + + NetworkLogger.logRequest(urlRequest, target: target) + + do { + let (data, response) = try await URLSession.shared.data(for: urlRequest) + + NetworkLogger.logResponse(data: data, response: response, target: target) + + guard let httpResponse = response as? HTTPURLResponse else { + throw NetworkError.responseError + } + + let statusCode = httpResponse.statusCode + + guard 200..<300 ~= statusCode else { + if statusCode == 404 { + throw NetworkError.notFoundError + } else if statusCode == 500 { + throw NetworkError.internalServerError + } else { + throw NetworkError.responseError + } + } + + do { + return try JSONDecoder().decode(BaseResponseBody.self, from: data) + } catch { + throw NetworkError.responseDecodingError + } + + } catch { + NetworkLogger.logError(error) + throw error + } + } +} + +extension BaseService { + + func requestRaw(with target: Target) async throws -> T { + let urlRequest = try provider.makeRequest(target) + + NetworkLogger.logRequest(urlRequest, target: target) + + do { + let (data, response) = try await URLSession.shared.data(for: urlRequest) + + NetworkLogger.logResponse(data: data, response: response, target: target) + + guard let httpResponse = response as? HTTPURLResponse else { + throw NetworkError.responseError + } + + let statusCode = httpResponse.statusCode + guard 200..<300 ~= statusCode else { + if statusCode == 404 { throw NetworkError.notFoundError } + if statusCode == 500 { throw NetworkError.internalServerError } + throw NetworkError.responseError + } + + do { + return try JSONDecoder().decode(T.self, from: data) + } catch { + throw NetworkError.responseDecodingError + } + + } catch { + NetworkLogger.logError(error) + throw error + } + } +} diff --git a/movie/movie/Network/Base/Environment.swift b/movie/movie/Network/Base/Environment.swift new file mode 100644 index 0000000..a143810 --- /dev/null +++ b/movie/movie/Network/Base/Environment.swift @@ -0,0 +1,16 @@ +// +// Environment.swift +// movie +// +// Created by sun on 12/17/25. +// + +import Foundation + +enum Environment { + static let baseURL: String = + Bundle.main.object(forInfoDictionaryKey: "BASE_URL") as! String + + static let kobisAPIKey: String = + Bundle.main.object(forInfoDictionaryKey: "KOBIS_API_KEY") as! String +} diff --git a/movie/movie/Network/Base/ModelType.swift b/movie/movie/Network/Base/ModelType.swift new file mode 100644 index 0000000..03f27be --- /dev/null +++ b/movie/movie/Network/Base/ModelType.swift @@ -0,0 +1,14 @@ +// +// ModelType.swift +// movie +// +// Created by sun on 12/17/25. +// + +import Foundation + +/// 요청 DTO용 +protocol RequestModelType: Encodable {} + +/// 응답 DTO용 +protocol ResponseModelType: Decodable {} diff --git a/movie/movie/Network/Base/NetworkError.swift b/movie/movie/Network/Base/NetworkError.swift new file mode 100644 index 0000000..2d20868 --- /dev/null +++ b/movie/movie/Network/Base/NetworkError.swift @@ -0,0 +1,37 @@ +// +// NetworkError.swift +// movie +// +// Created by sun on 12/17/25. +// + +import Foundation + +enum NetworkError: Error, CustomStringConvertible { + case invalidURLComponents + case invalidURLString + case requestEncodingError + case responseDecodingError + case responseError + case notFoundError + case internalServerError + + var description: String { + switch self { + case .invalidURLComponents: + return "URL 구성을 만들 수 없습니다." + case .invalidURLString: + return "잘못된 URL입니다." + case .requestEncodingError: + return "요청 인코딩에 실패했습니다." + case .responseDecodingError: + return "응답 디코딩에 실패했습니다." + case .responseError: + return "서버로부터 에러 응답을 받았습니다." + case .notFoundError: + return "요청한 리소스를 찾을 수 없습니다. (404)" + case .internalServerError: + return "서버 내부 오류입니다. (500)" + } + } +} diff --git a/movie/movie/Network/Base/NetworkLogger.swift b/movie/movie/Network/Base/NetworkLogger.swift new file mode 100644 index 0000000..75cac21 --- /dev/null +++ b/movie/movie/Network/Base/NetworkLogger.swift @@ -0,0 +1,69 @@ +// +// NetworkLogger.swift +// movie +// +// Created by sun on 12/17/25. +// + +import Foundation + +enum NetworkLogger { + + static func logRequest(_ request: URLRequest, target: TargetType) { + guard let url = request.url?.absoluteString else { + print("--> 유효하지 않은 요청") + return + } + + let method = request.httpMethod ?? "메소드값이 nil입니다." + var log = """ + ---------------------------------------------------- + 1️⃣[\(method)] \(url) + ---------------------------------------------------- + 2️⃣API: \(target) + """ + + if let headers = request.allHTTPHeaderFields, !headers.isEmpty { + log.append("\nheader: \(headers)") + } + + if let body = request.httpBody, + let bodyString = String(data: body, encoding: .utf8) { + log.append("\n\(bodyString)") + } + + log.append("\n------------------- END \(method) -------------------") + print(log) + } + + static func logResponse(data: Data, response: URLResponse, target: TargetType) { + guard let httpResponse = response as? HTTPURLResponse else { return } + let url = httpResponse.url?.absoluteString ?? "nil" + let statusCode = httpResponse.statusCode + + var log = """ + ------------------- Response가 도착했습니다. ------------------- + 3️⃣[\(statusCode)] \(url) + API: \(target) + Status Code: [\(statusCode)] + URL: \(url) + response: + """ + + if let body = String(data: data, encoding: .utf8) { + log.append("\n4️⃣\(body)") + } + + log.append("\n------------------- END HTTP -------------------") + print(log) + } + + static func logError(_ error: Error) { + let log = """ + ❌ 네트워크 오류 발생 + <-- \(error.localizedDescription) + <-- END HTTP + """ + print(log) + } +} diff --git a/movie/movie/Network/Base/NetworkProvider.swift b/movie/movie/Network/Base/NetworkProvider.swift new file mode 100644 index 0000000..54f55a0 --- /dev/null +++ b/movie/movie/Network/Base/NetworkProvider.swift @@ -0,0 +1,71 @@ +// +// NetworkProvider.swift +// movie +// +// Created by sun on 12/17/25. +// + +import Foundation + +struct NetworkProvider { + func makeRequest(_ target: Target) throws -> URLRequest { + + // MARK: - URL Path + + let path = target.baseURL + target.path + guard var urlComponents = URLComponents(string: path) else { + throw NetworkError.invalidURLComponents + } + + // MARK: - Task + + var body: Data? + var url: URL? + + let task = target.task + switch task { + case .requestPlain: + url = urlComponents.url + + case .requestParameters(let parameters, let encoding): + switch encoding { + case .queryString: + let queryItemArray = parameters.map { + URLQueryItem(name: $0.key, value: $0.value as? String) + } + urlComponents.queryItems = queryItemArray + url = urlComponents.url + } + + case .requestJSONEncodable(encodable: let encodable): + url = urlComponents.url + do { + let JSONEncoder = JSONEncoder() + let requestBody = try JSONEncoder.encode(encodable) + body = requestBody + } catch { + throw NetworkError.requestEncodingError + } + } + + guard let url else { + throw NetworkError.invalidURLString + } + + // MARK: - HTTP Method + + var request = URLRequest(url: url) + request.httpMethod = target.method.rawValue + request.httpBody = body + + // MARK: - Header + + if let headerField = target.headers.keyValue { + headerField.forEach { key, value in + request.addValue(value, forHTTPHeaderField: key) + } + } + + return request + } +} diff --git a/movie/movie/Network/Base/TargetType.swift b/movie/movie/Network/Base/TargetType.swift new file mode 100644 index 0000000..8107484 --- /dev/null +++ b/movie/movie/Network/Base/TargetType.swift @@ -0,0 +1,60 @@ +// +// TargetType.swift +// movie +// +// Created by sun on 12/17/25. +// + +import Foundation + +public protocol TargetType { + var baseURL: String { get } + var path: String { get } + var method: HTTPMethod { get } + var sampleData: Data { get } + var task: NetworkTask { get } + var headers: HeaderField { get } +} + +public extension TargetType { + var sampleData: Data { Data() } +} + +// MARK: - HTTP Method + +public enum HTTPMethod: String { + case get = "GET" + case post = "POST" + case patch = "PATCH" + case delete = "DELETE" +} + +// MARK: - Network Task + +public enum NetworkTask { + case requestPlain + case requestParameters(parameters: [String : Any], encoding: ParameterEncoding) + case requestJSONEncodable(encodable: Encodable) +} + +// MARK: - Parameter Encoding + +public enum ParameterEncoding { + case queryString +} + +// MARK: - Header Field + +public enum HeaderField { + case contentTypeJSON + case userId(Int) + + var keyValue: [String: String]? { + switch self { + case .contentTypeJSON: + return ["Content-Type": "application/json"] + case .userId(let id): + return ["Content-Type": "application/json", "userId": String(id)] + } + } +} diff --git a/movie/movie/Network/DTO/MovieResponseDTO.swift b/movie/movie/Network/DTO/MovieResponseDTO.swift new file mode 100644 index 0000000..a8be66f --- /dev/null +++ b/movie/movie/Network/DTO/MovieResponseDTO.swift @@ -0,0 +1,30 @@ +// +// MovieDTO.swift +// movie +// +// Created by sun on 12/17/25. +// + +import Foundation + +struct MovieResponseDTO: Codable { + let boxOfficeResult: BoxOfficeResultDTO +} + +struct BoxOfficeResultDTO: Codable { + let dailyBoxOfficeList: [MovieInfoDTO] +} + +struct MovieInfoDTO: Codable { + let rank: String + let movieNm: String + let audiAcc: String +} + +extension MovieInfo { + init(dto: MovieInfoDTO) { + self.rank = Int(dto.rank) ?? 0 + self.title = dto.movieNm + self.audienceAccumulated = dto.audiAcc + } +} diff --git a/movie/movie/Network/Entity/MovieInfo.swift b/movie/movie/Network/Entity/MovieInfo.swift new file mode 100644 index 0000000..f8bdf2e --- /dev/null +++ b/movie/movie/Network/Entity/MovieInfo.swift @@ -0,0 +1,14 @@ +// +// MovieInfo.swift +// movie +// +// Created by sun on 12/17/25. +// + +import Foundation + +struct MovieInfo { + let rank: Int + let title: String + let audienceAccumulated: String +} diff --git a/movie/movie/Network/Service/MovieService.swift b/movie/movie/Network/Service/MovieService.swift new file mode 100644 index 0000000..7cc2860 --- /dev/null +++ b/movie/movie/Network/Service/MovieService.swift @@ -0,0 +1,17 @@ +// +// MovieService.swift +// movie +// +// Created by sun on 12/17/25. +// + +import Foundation + +final class MovieService: BaseService { + + func fetchDailyBoxOffice(targetDate: String) async throws -> [MovieInfoDTO] { + let dto: MovieResponseDTO = try await requestRaw(with: .dailyBoxOffice(targetDate: targetDate)) + return dto.boxOfficeResult.dailyBoxOfficeList + } +} + diff --git a/movie/movie/Network/TargetType/MovieTarget.swift b/movie/movie/Network/TargetType/MovieTarget.swift new file mode 100644 index 0000000..07ea3bc --- /dev/null +++ b/movie/movie/Network/TargetType/MovieTarget.swift @@ -0,0 +1,41 @@ +// +// MovieTarget.swift +// movie +// +// Created by sun on 12/17/25. +// + +import Foundation + +enum MovieTarget { + case dailyBoxOffice(targetDate: String) +} + +extension MovieTarget: TargetType { + + var baseURL: String { Environment.baseURL } + + var path: String { + switch self { + case .dailyBoxOffice: + return "/boxoffice/searchDailyBoxOfficeList.json" + } + } + + var method: HTTPMethod { .get } + + var task: NetworkTask { + switch self { + case .dailyBoxOffice(let targetDate): + return .requestParameters( + parameters: [ + "key": Environment.kobisAPIKey, + "targetDt": targetDate + ], + encoding: .queryString + ) + } + } + + var headers: HeaderField { .contentTypeJSON } +} diff --git a/movie/movie/Presentation/MovieCell.swift b/movie/movie/Presentation/MovieCell.swift new file mode 100644 index 0000000..3717462 --- /dev/null +++ b/movie/movie/Presentation/MovieCell.swift @@ -0,0 +1,24 @@ +// +// MovieCell.swift +// movie +// +// Created by sun on 12/17/25. +// + +import UIKit + +final class MovieCell: UITableViewCell { + static let reuseId = "MovieCell" + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: .subtitle, reuseIdentifier: reuseIdentifier) + selectionStyle = .none + } + + required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } + + func configure(_ movie: MovieInfo) { + textLabel?.text = "\(movie.rank). \(movie.title)" + detailTextLabel?.text = "누적 관객수: \(movie.audienceAccumulated)" + } +} diff --git a/movie/movie/Presentation/MovieViewController.swift b/movie/movie/Presentation/MovieViewController.swift new file mode 100644 index 0000000..19d6c8a --- /dev/null +++ b/movie/movie/Presentation/MovieViewController.swift @@ -0,0 +1,124 @@ +// +// MovieViewController.swift +// movie +// +// Created by sun on 12/17/25. +// + +import UIKit +import Combine + +import SnapKit +import Then + +final class MovieViewController: UIViewController { + + // MARK: - Properties + + private let viewModel = MovieViewModel() + private var cancellables = Set() + + private let targetDateString = "20251216" + private let displayDateString = "2025.12.16" + + // MARK: - UI Components + + private let headerStackView = UIStackView().then { + $0.axis = .vertical + $0.spacing = 4 + $0.alignment = .leading + } + + private let dateLabel = UILabel().then { + $0.font = .systemFont(ofSize: 14, weight: .medium) + $0.textColor = .secondaryLabel + } + + private let titleLabel = UILabel().then { + $0.font = .systemFont(ofSize: 22, weight: .bold) + $0.textColor = .label + $0.text = "어제 박스오피스 TOP 10" + } + + private let tableView = UITableView(frame: .zero, style: .plain).then { + $0.tableFooterView = UIView() + } + + // MARK: - Life Cycle + + override func viewDidLoad() { + super.viewDidLoad() + title = "박스오피스" + view.backgroundColor = .systemBackground + + setupUI() + bind() + + dateLabel.text = displayDateString + viewModel.fetch(targetDate: targetDateString) + } + + // MARK: - UI + + private func setupUI() { + headerStackView.addArrangedSubview(dateLabel) + headerStackView.addArrangedSubview(titleLabel) + + tableView.dataSource = self + tableView.register(MovieCell.self, forCellReuseIdentifier: MovieCell.reuseId) + + view.addSubview(headerStackView) + view.addSubview(tableView) + + headerStackView.snp.makeConstraints { + $0.top.equalTo(view.safeAreaLayoutGuide).offset(12) + $0.leading.equalToSuperview().offset(16) + $0.trailing.equalToSuperview().inset(16) + } + + tableView.snp.makeConstraints { + $0.top.equalTo(headerStackView.snp.bottom).offset(12) + $0.leading.trailing.bottom.equalToSuperview() + } + } + + // MARK: - Bind + + private func bind() { + viewModel.$movies + .receive(on: DispatchQueue.main) + .sink { [weak self] _ in + self?.tableView.reloadData() + } + .store(in: &cancellables) + + viewModel.$errorMessage + .compactMap { $0 } + .sink { message in + print("❌ 에러난다:", message) + } + .store(in: &cancellables) + } +} + +// MARK: - UITableViewDataSource + +extension MovieViewController: UITableViewDataSource { + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + viewModel.movies.count + } + + func tableView( + _ tableView: UITableView, + cellForRowAt indexPath: IndexPath + ) -> UITableViewCell { + let cell = tableView.dequeueReusableCell( + withIdentifier: MovieCell.reuseId, + for: indexPath + ) as! MovieCell + cell.configure(viewModel.movies[indexPath.row]) + return cell + } +} + diff --git a/movie/movie/Presentation/MovieViewModel.swift b/movie/movie/Presentation/MovieViewModel.swift new file mode 100644 index 0000000..331ac0d --- /dev/null +++ b/movie/movie/Presentation/MovieViewModel.swift @@ -0,0 +1,41 @@ +// +// MovieViewModel.swift +// movie +// +// Created by sun on 12/17/25. +// + +import Combine +import Foundation + +final class MovieViewModel { + + @Published private(set) var movies: [MovieInfo] = [] + @Published private(set) var errorMessage: String? = nil + + private let service = MovieService() + private var cancellables = Set() + + func fetch(targetDate: String) { + Future<[MovieInfo], Error> { [service] promise in + Task { + do { + let dto = try await service.fetchDailyBoxOffice(targetDate: targetDate) + promise(.success(dto.map { MovieInfo(dto: $0) })) + } catch { + promise(.failure(error)) + } + } + } + .receive(on: DispatchQueue.main) + .sink { [weak self] completion in + if case .failure(let error) = completion { + self?.errorMessage = error.localizedDescription + } + } receiveValue: { [weak self] movies in + self?.errorMessage = nil + self?.movies = movies + } + .store(in: &cancellables) + } +} diff --git a/movie/movie/SceneDelegate.swift b/movie/movie/SceneDelegate.swift new file mode 100644 index 0000000..436d127 --- /dev/null +++ b/movie/movie/SceneDelegate.swift @@ -0,0 +1,57 @@ +// +// SceneDelegate.swift +// movie +// +// Created by sun on 12/16/25. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let windowScene = (scene as? UIWindowScene) else { return } + + let window = UIWindow(windowScene: windowScene) + window.rootViewController = MovieViewController() + window.makeKeyAndVisible() + self.window = window + } + + 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 necessarily 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. + } + + +} +