From 40d31c9db2425134fcb4a26a5050382a31804208 Mon Sep 17 00:00:00 2001 From: moral-life Date: Tue, 12 Nov 2024 00:36:09 +0900 Subject: [PATCH 1/8] =?UTF-8?q?chore:=20MusicKit=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=8B=9C=20=EC=82=AC=EC=9A=A9=EC=9E=90=20Media=20=EC=A0=91?= =?UTF-8?q?=EA=B7=BC=20=EA=B6=8C=ED=95=9C=20=EB=B6=80=EC=97=AC=20=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alsongDalsong/Info.plist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/alsongDalsong/Info.plist b/alsongDalsong/Info.plist index 0eb786dc..58e67535 100644 --- a/alsongDalsong/Info.plist +++ b/alsongDalsong/Info.plist @@ -2,6 +2,8 @@ + NSAppleMusicUsageDescription + 알쏭달쏭은 Apple Music을 이용하여 음악을 찾는 것을 돕습니다. UIApplicationSceneManifest UIApplicationSupportsMultipleScenes From 258c73be95689edec04acca18f39ab800c762ceb Mon Sep 17 00:00:00 2001 From: moral-life Date: Tue, 12 Nov 2024 00:38:24 +0900 Subject: [PATCH 2/8] =?UTF-8?q?feat:=20ASMusicAPI=20=EA=B5=AC=EC=A1=B0?= =?UTF-8?q?=EC=B2=B4=20=EC=83=9D=EC=84=B1,=20search=20=ED=95=A8=EC=88=98?= =?UTF-8?q?=20=EB=B0=8F,=20ASSong=20=EC=84=A0=EC=96=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. search를 Songs를 받아오는것, Song을 ASSong으로 변환하는 두가지 작업을 하는데 이를 분리하는 것이 좋을지 2. 위 방식을 택했을 때 MusicKit 예시 앱 처럼 파도타기 (노래 -> 관련 앨범 -> 아티스트 -> 다른앨범 -> ....) 하는 기능을 잃게 될 것 같은데 괜찮은지 --- alsongDalsong/ASMusicAPI.swift | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 alsongDalsong/ASMusicAPI.swift diff --git a/alsongDalsong/ASMusicAPI.swift b/alsongDalsong/ASMusicAPI.swift new file mode 100644 index 00000000..2e8bce12 --- /dev/null +++ b/alsongDalsong/ASMusicAPI.swift @@ -0,0 +1,38 @@ +import MusicKit + +struct ASMusicAPI { + + /// search 결과를 Assong으로 변환 하여 배열로 리턴하는 함수 + /// 노래 검색화면에 기본으로 뜨는 row 개수가 6개이므로 별다른 지정 없으면 기본값 6으로 지정 + func search(for text: String, _ maxCount: Int = 6) async -> [ASSong] { + + let status = await MusicAuthorization.request() + + switch status { + case .authorized: + do { + var request = MusicCatalogSearchRequest(term: text, types: [Song.self]) + request.limit = maxCount + request.offset = 1 + + let result = try await request.response() + let asSongs = result.songs.map { song in + ASSong(title: song.title, artistName: song.artistName) + } + return asSongs + } catch { + print(String(describing: error)) + return [] + } + default: + print("Not authorized to access Apple Music") + return [] + } + } +} + +struct ASSong: Equatable { + let title: String + let artistName: String +} + From dd91756d252b8898cd318b6f7d042b58bdc3a842 Mon Sep 17 00:00:00 2001 From: moral-life Date: Tue, 12 Nov 2024 00:53:18 +0900 Subject: [PATCH 3/8] =?UTF-8?q?feat:=20ASSongs=EC=97=90=20=EC=95=84?= =?UTF-8?q?=ED=8A=B8=EC=9B=8C=ED=81=AC=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=20?= =?UTF-8?q?URL=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 실제 MusicKit에서 Artwork를 관리하는 방법은 다른 것 같아 이부분 논의 필요 --- alsongDalsong/ASMusicAPI.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/alsongDalsong/ASMusicAPI.swift b/alsongDalsong/ASMusicAPI.swift index 2e8bce12..7159e7c6 100644 --- a/alsongDalsong/ASMusicAPI.swift +++ b/alsongDalsong/ASMusicAPI.swift @@ -1,4 +1,5 @@ import MusicKit +import Foundation struct ASMusicAPI { @@ -17,7 +18,8 @@ struct ASMusicAPI { let result = try await request.response() let asSongs = result.songs.map { song in - ASSong(title: song.title, artistName: song.artistName) + let artworkURL = song.artwork?.url(width: 300, height: 300) + return ASSong(title: song.title, artistName: song.artistName, artwork: artworkURL) } return asSongs } catch { @@ -34,5 +36,6 @@ struct ASMusicAPI { struct ASSong: Equatable { let title: String let artistName: String + let artwork: URL? } From a32e402620c5be55df6b71d2068e116031609b08 Mon Sep 17 00:00:00 2001 From: moral-life Date: Tue, 12 Nov 2024 21:58:15 +0900 Subject: [PATCH 4/8] =?UTF-8?q?fix:=20plist=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Font, Media Privacy 관련한 row가 conflict 발생하여 수동으로 resolve 해주었는데 이 과정에서 plist syntax를 어긋나는 문제가 있었음. 다시 수정 하여 현재는 해결함 --- alsongDalsong/Info.plist | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/alsongDalsong/Info.plist b/alsongDalsong/Info.plist index 86c03abd..975bb9a9 100644 --- a/alsongDalsong/Info.plist +++ b/alsongDalsong/Info.plist @@ -2,12 +2,12 @@ - UIAppFonts - + DoHyeon-Regular.ttf + NSAppleMusicUsageDescription - 알쏭달쏭은 Apple Music을 이용하여 음악을 찾는 것을 돕습니다. + 알쏭달쏭은 Apple Music을 이용하여 음악을 찾는 것을 돕습니다 UIApplicationSceneManifest UIApplicationSupportsMultipleScenes From adcbcdc04c75d3d7e4fa2f78dbc3d726b68ec232 Mon Sep 17 00:00:00 2001 From: moral-life Date: Tue, 12 Nov 2024 22:00:13 +0900 Subject: [PATCH 5/8] =?UTF-8?q?remove:=20=EB=AA=A8=EB=93=88=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC=EC=9D=B4=ED=9B=84=20=EC=9B=90=EB=9E=98=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EC=9D=80=20=ED=95=84=EC=9A=94=EC=97=86=EC=96=B4?= =?UTF-8?q?=EC=A7=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alsongDalsong/ASMusicAPI.swift | 41 ---------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 alsongDalsong/ASMusicAPI.swift diff --git a/alsongDalsong/ASMusicAPI.swift b/alsongDalsong/ASMusicAPI.swift deleted file mode 100644 index 7159e7c6..00000000 --- a/alsongDalsong/ASMusicAPI.swift +++ /dev/null @@ -1,41 +0,0 @@ -import MusicKit -import Foundation - -struct ASMusicAPI { - - /// search 결과를 Assong으로 변환 하여 배열로 리턴하는 함수 - /// 노래 검색화면에 기본으로 뜨는 row 개수가 6개이므로 별다른 지정 없으면 기본값 6으로 지정 - func search(for text: String, _ maxCount: Int = 6) async -> [ASSong] { - - let status = await MusicAuthorization.request() - - switch status { - case .authorized: - do { - var request = MusicCatalogSearchRequest(term: text, types: [Song.self]) - request.limit = maxCount - request.offset = 1 - - let result = try await request.response() - let asSongs = result.songs.map { song in - let artworkURL = song.artwork?.url(width: 300, height: 300) - return ASSong(title: song.title, artistName: song.artistName, artwork: artworkURL) - } - return asSongs - } catch { - print(String(describing: error)) - return [] - } - default: - print("Not authorized to access Apple Music") - return [] - } - } -} - -struct ASSong: Equatable { - let title: String - let artistName: String - let artwork: URL? -} - From bc6d5872063cc9f1a0b65c4039ad5ed65849981d Mon Sep 17 00:00:00 2001 From: moral-life Date: Tue, 12 Nov 2024 22:02:54 +0900 Subject: [PATCH 6/8] =?UTF-8?q?feat:=20ASMusicKit=20=ED=94=84=EB=A0=88?= =?UTF-8?q?=EC=9E=84=EC=9B=8C=ED=81=AC=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ASAudioKit.xcodeproj/project.pbxproj | 4 +- ASMusicKit.xcodeproj/project.pbxproj | 344 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + ASMusicKit/ASMusicAPI.swift | 41 +++ ASMusicKit/ASMusicKit.docc/ASMusicKit.md | 13 + alsongDalsong.xcodeproj/project.pbxproj | 32 ++ 6 files changed, 439 insertions(+), 2 deletions(-) create mode 100644 ASMusicKit.xcodeproj/project.pbxproj create mode 100644 ASMusicKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 ASMusicKit/ASMusicAPI.swift create mode 100644 ASMusicKit/ASMusicKit.docc/ASMusicKit.md diff --git a/ASAudioKit.xcodeproj/project.pbxproj b/ASAudioKit.xcodeproj/project.pbxproj index d4b1b8ed..db279732 100644 --- a/ASAudioKit.xcodeproj/project.pbxproj +++ b/ASAudioKit.xcodeproj/project.pbxproj @@ -237,7 +237,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 2G2M8W77TR; + DEVELOPMENT_TEAM = B3PWYBKFUK; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -270,7 +270,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 2G2M8W77TR; + DEVELOPMENT_TEAM = B3PWYBKFUK; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; diff --git a/ASMusicKit.xcodeproj/project.pbxproj b/ASMusicKit.xcodeproj/project.pbxproj new file mode 100644 index 00000000..c11109dc --- /dev/null +++ b/ASMusicKit.xcodeproj/project.pbxproj @@ -0,0 +1,344 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXFileReference section */ + 8D9402EC2CE37DA1009D21C4 /* ASMusicKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = ASMusicKit.framework; path = "/Users/minhalee/BoostCamp/DDDD/alsongDalsong/build/Debug-iphoneos/ASMusicKit.framework"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + 8D4F31732CE3805D00E13720 /* ASMusicKit */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = ASMusicKit; + sourceTree = ""; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D9402E92CE37DA1009D21C4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 8D9402E22CE37DA1009D21C4 = { + isa = PBXGroup; + children = ( + 8D4F31732CE3805D00E13720 /* ASMusicKit */, + ); + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 8D9402E72CE37DA1009D21C4 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 8D9402EB2CE37DA1009D21C4 /* ASMusicKit */ = { + isa = PBXNativeTarget; + buildConfigurationList = 8D9402F42CE37DA1009D21C4 /* Build configuration list for PBXNativeTarget "ASMusicKit" */; + buildPhases = ( + 8D9402E72CE37DA1009D21C4 /* Headers */, + 8D9402E82CE37DA1009D21C4 /* Sources */, + 8D9402E92CE37DA1009D21C4 /* Frameworks */, + 8D9402EA2CE37DA1009D21C4 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + 8D4F31732CE3805D00E13720 /* ASMusicKit */, + ); + name = ASMusicKit; + packageProductDependencies = ( + ); + productName = ASMusicKit; + productReference = 8D9402EC2CE37DA1009D21C4 /* ASMusicKit.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 8D9402E32CE37DA1009D21C4 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1600; + TargetAttributes = { + 8D9402EB2CE37DA1009D21C4 = { + CreatedOnToolsVersion = 16.0; + }; + }; + }; + buildConfigurationList = 8D9402E62CE37DA1009D21C4 /* Build configuration list for PBXProject "ASMusicKit" */; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 8D9402E22CE37DA1009D21C4; + minimizedProjectReferenceProxies = 1; + preferredProjectObjectVersion = 77; + productRefGroup = 8D9402E22CE37DA1009D21C4; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8D9402EB2CE37DA1009D21C4 /* ASMusicKit */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D9402EA2CE37DA1009D21C4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D9402E82CE37DA1009D21C4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 8D9402F52CE37DA1009D21C4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUILD_LIBRARY_FOR_DISTRIBUTION = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = B3PWYBKFUK; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; + PRODUCT_BUNDLE_IDENTIFIER = kr.codesquad.boostcamp9.ASMusicKit; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_INSTALL_OBJC_HEADER = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 8D9402F62CE37DA1009D21C4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUILD_LIBRARY_FOR_DISTRIBUTION = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = B3PWYBKFUK; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; + PRODUCT_BUNDLE_IDENTIFIER = kr.codesquad.boostcamp9.ASMusicKit; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_INSTALL_OBJC_HEADER = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 8D9402F72CE37DA1009D21C4 /* Debug */ = { + isa = XCBuildConfiguration; + 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; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + 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 = 18.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"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 8D9402F82CE37DA1009D21C4 /* Release */ = { + isa = XCBuildConfiguration; + 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; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + 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 = 18.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 8D9402E62CE37DA1009D21C4 /* Build configuration list for PBXProject "ASMusicKit" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8D9402F72CE37DA1009D21C4 /* Debug */, + 8D9402F82CE37DA1009D21C4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 8D9402F42CE37DA1009D21C4 /* Build configuration list for PBXNativeTarget "ASMusicKit" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8D9402F52CE37DA1009D21C4 /* Debug */, + 8D9402F62CE37DA1009D21C4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 8D9402E32CE37DA1009D21C4 /* Project object */; +} diff --git a/ASMusicKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ASMusicKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/ASMusicKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ASMusicKit/ASMusicAPI.swift b/ASMusicKit/ASMusicAPI.swift new file mode 100644 index 00000000..6f386d1a --- /dev/null +++ b/ASMusicKit/ASMusicAPI.swift @@ -0,0 +1,41 @@ +import MusicKit +import Foundation + +public struct ASMusicAPI { + public init() {} + /// MusicKit을 통해 AppleMusic + /// - Parameters: + /// - text: 검색 요청을 보낼 검색어 + /// - maxCount: 검색해서 찾아올 음악의 갯수 기본값 설정은 25 + /// - Returns: ASSong의 배열 + public func search(for text: String, _ maxCount: Int = 25) async -> [ASSong] { + let status = await MusicAuthorization.request() + switch status { + case .authorized: + do { + var request = MusicCatalogSearchRequest(term: text, types: [Song.self]) + request.limit = maxCount + request.offset = 1 + + let result = try await request.response() + let asSongs = result.songs.map { song in + let artworkURL = song.artwork?.url(width: 100, height: 100) + return ASSong(title: song.title, artistName: song.artistName, artwork: artworkURL) + } + return asSongs + } catch { + print(String(describing: error)) + return [] + } + default: + print("Not authorized to access Apple Music") + return [] + } + } +} + +public struct ASSong: Equatable, Sendable { + public let title: String + public let artistName: String + public let artwork: URL? +} diff --git a/ASMusicKit/ASMusicKit.docc/ASMusicKit.md b/ASMusicKit/ASMusicKit.docc/ASMusicKit.md new file mode 100644 index 00000000..682d3f2d --- /dev/null +++ b/ASMusicKit/ASMusicKit.docc/ASMusicKit.md @@ -0,0 +1,13 @@ +# ``ASMusicKit`` + +Summary + +## Overview + +Text + +## Topics + +### Group + +- ``Symbol`` \ No newline at end of file diff --git a/alsongDalsong.xcodeproj/project.pbxproj b/alsongDalsong.xcodeproj/project.pbxproj index e5605fcc..2f1417aa 100644 --- a/alsongDalsong.xcodeproj/project.pbxproj +++ b/alsongDalsong.xcodeproj/project.pbxproj @@ -9,6 +9,8 @@ /* Begin PBXBuildFile section */ 4E8907B42CE2415700D5B547 /* ASAudioKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E8907A52CE240B300D5B547 /* ASAudioKit.framework */; }; 4E8907B52CE2415700D5B547 /* ASAudioKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4E8907A52CE240B300D5B547 /* ASAudioKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 8D4F31772CE3806C00E13720 /* ASMusicKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8D4F316F2CE3804B00E13720 /* ASMusicKit.framework */; }; + 8D4F31782CE3806C00E13720 /* ASMusicKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8D4F316F2CE3804B00E13720 /* ASMusicKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -19,6 +21,13 @@ remoteGlobalIDString = 4E89071E2CE23D1B00D5B547; remoteInfo = ASAudioKit; }; + 8D4F316E2CE3804B00E13720 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 8D4F316A2CE3804B00E13720 /* ASMusicKit.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 8D9402EC2CE37DA1009D21C4; + remoteInfo = ASMusicKit; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -29,6 +38,7 @@ dstSubfolderSpec = 10; files = ( 4E8907B52CE2415700D5B547 /* ASAudioKit.framework in Embed Frameworks */, + 8D4F31782CE3806C00E13720 /* ASMusicKit.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -37,6 +47,7 @@ /* Begin PBXFileReference section */ 4E89079C2CE240B300D5B547 /* ASAudioKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = ASAudioKit.xcodeproj; sourceTree = ""; }; + 8D4F316A2CE3804B00E13720 /* ASMusicKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = ASMusicKit.xcodeproj; sourceTree = ""; }; 8D69A5922CDC5A83006B9075 /* alsongDalsong.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = alsongDalsong.app; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -67,6 +78,7 @@ buildActionMask = 2147483647; files = ( 4E8907B42CE2415700D5B547 /* ASAudioKit.framework in Frameworks */, + 8D4F31772CE3806C00E13720 /* ASMusicKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -88,9 +100,18 @@ name = Frameworks; sourceTree = ""; }; + 8D4F316B2CE3804B00E13720 /* Products */ = { + isa = PBXGroup; + children = ( + 8D4F316F2CE3804B00E13720 /* ASMusicKit.framework */, + ); + name = Products; + sourceTree = ""; + }; 8D69A5892CDC5A83006B9075 = { isa = PBXGroup; children = ( + 8D4F316A2CE3804B00E13720 /* ASMusicKit.xcodeproj */, 4E89079C2CE240B300D5B547 /* ASAudioKit.xcodeproj */, 8D69A5942CDC5A83006B9075 /* alsongDalsong */, 4E8907B32CE2415700D5B547 /* Frameworks */, @@ -164,6 +185,10 @@ ProductGroup = 4E89079D2CE240B300D5B547 /* Products */; ProjectRef = 4E89079C2CE240B300D5B547 /* ASAudioKit.xcodeproj */; }, + { + ProductGroup = 8D4F316B2CE3804B00E13720 /* Products */; + ProjectRef = 8D4F316A2CE3804B00E13720 /* ASMusicKit.xcodeproj */; + }, ); projectRoot = ""; targets = ( @@ -180,6 +205,13 @@ remoteRef = 4E8907A42CE240B300D5B547 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 8D4F316F2CE3804B00E13720 /* ASMusicKit.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = ASMusicKit.framework; + remoteRef = 8D4F316E2CE3804B00E13720 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ From eaf88f688aac3c5644c04275f873757958d88bb4 Mon Sep 17 00:00:00 2001 From: moral-life Date: Wed, 13 Nov 2024 00:37:56 +0900 Subject: [PATCH 7/8] =?UTF-8?q?fix:=20pbxproj=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alsongDalsong.xcodeproj/project.pbxproj | 1 - 1 file changed, 1 deletion(-) diff --git a/alsongDalsong.xcodeproj/project.pbxproj b/alsongDalsong.xcodeproj/project.pbxproj index 2f1417aa..03a1d071 100644 --- a/alsongDalsong.xcodeproj/project.pbxproj +++ b/alsongDalsong.xcodeproj/project.pbxproj @@ -103,7 +103,6 @@ 8D4F316B2CE3804B00E13720 /* Products */ = { isa = PBXGroup; children = ( - 8D4F316F2CE3804B00E13720 /* ASMusicKit.framework */, ); name = Products; sourceTree = ""; From f3b43641839bb6052a76d1ca8722af18dadf5af1 Mon Sep 17 00:00:00 2001 From: moral-life Date: Wed, 13 Nov 2024 15:14:13 +0900 Subject: [PATCH 8/8] =?UTF-8?q?fix:=20switch=20indent=EB=B3=80=EA=B2=BD,?= =?UTF-8?q?=20offset=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80,=20import=20=EC=88=9C=EC=84=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ASMusicKit/ASMusicAPI.swift | 38 ++++++++++++------------- alsongDalsong.xcodeproj/project.pbxproj | 9 ++++++ 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/ASMusicKit/ASMusicAPI.swift b/ASMusicKit/ASMusicAPI.swift index 6f386d1a..c4681827 100644 --- a/ASMusicKit/ASMusicAPI.swift +++ b/ASMusicKit/ASMusicAPI.swift @@ -1,5 +1,5 @@ -import MusicKit import Foundation +import MusicKit public struct ASMusicAPI { public init() {} @@ -8,28 +8,28 @@ public struct ASMusicAPI { /// - text: 검색 요청을 보낼 검색어 /// - maxCount: 검색해서 찾아올 음악의 갯수 기본값 설정은 25 /// - Returns: ASSong의 배열 - public func search(for text: String, _ maxCount: Int = 25) async -> [ASSong] { + public func search(for text: String, _ maxCount: Int = 25, _ offset: Int = 1) async -> [ASSong] { let status = await MusicAuthorization.request() switch status { - case .authorized: - do { - var request = MusicCatalogSearchRequest(term: text, types: [Song.self]) - request.limit = maxCount - request.offset = 1 - - let result = try await request.response() - let asSongs = result.songs.map { song in - let artworkURL = song.artwork?.url(width: 100, height: 100) - return ASSong(title: song.title, artistName: song.artistName, artwork: artworkURL) + case .authorized: + do { + var request = MusicCatalogSearchRequest(term: text, types: [Song.self]) + request.limit = maxCount + request.offset = offset + + let result = try await request.response() + let asSongs = result.songs.map { song in + let artworkURL = song.artwork?.url(width: 100, height: 100) + return ASSong(title: song.title, artistName: song.artistName, artwork: artworkURL) + } + return asSongs + } catch { + print(String(describing: error)) + return [] } - return asSongs - } catch { - print(String(describing: error)) + default: + print("Not authorized to access Apple Music") return [] - } - default: - print("Not authorized to access Apple Music") - return [] } } } diff --git a/alsongDalsong.xcodeproj/project.pbxproj b/alsongDalsong.xcodeproj/project.pbxproj index 03a1d071..484131a9 100644 --- a/alsongDalsong.xcodeproj/project.pbxproj +++ b/alsongDalsong.xcodeproj/project.pbxproj @@ -115,6 +115,7 @@ 8D69A5942CDC5A83006B9075 /* alsongDalsong */, 4E8907B32CE2415700D5B547 /* Frameworks */, 8D69A5932CDC5A83006B9075 /* Products */, + 8D9C31952CE47A8000F6E69C /* Recovered References */, ); sourceTree = ""; }; @@ -126,6 +127,14 @@ name = Products; sourceTree = ""; }; + 8D9C31952CE47A8000F6E69C /* Recovered References */ = { + isa = PBXGroup; + children = ( + 8D4F316F2CE3804B00E13720 /* ASMusicKit.framework */, + ); + name = "Recovered References"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */