Apple Spotlight는 모든 iOS 기기에 내장된 검색 시스템이에요. 사용자가 홈 화면을 아래로 밀고 검색어를 입력하면, Spotlight가 앱, 연락처, 메시지, 파일, 웹을 함께 검색해요. 앱이 콘텐츠를 Spotlight에 색인하면 그 콘텐츠가 검색 결과에 나타나서, 사용자가 앱 안의 해당 콘텐츠로 바로 돌아갈 수 있어요.
Google App Indexing(웹 검색 결과에 콘텐츠를 노출하는 기능)과 달리 Spotlight 색인은 기기 안에서 이루어져요. 색인이 기기에 저장되므로 빠르고, 개인정보를 보호하며, 오프라인에서도 동작해요. 이 가이드에서는 Apple이 제공하는 세 가지 색인 방법과 각각의 구현 방법을 다뤄요. 더 넓은 앱 색인 전략은 모바일 앱의 인덱싱과 SEO에서 다뤄요. Google의 대응 기능은 다음에서 확인하세요: Google App Indexing 설정.
세 가지 색인 방법
Apple은 Spotlight에 앱 콘텐츠를 색인하는 세 가지 상호 보완적인 방법을 제공해요:
| 메서드 | Best For | 범위 | 웹 필요 여부 |
|---|---|---|---|
| CoreSpotlight | 앱 고유 콘텐츠(상품, 글, 메시지) | 기기 내에서만 | 아니요 |
| NSUserActivity | 사용자가 보았거나 상호작용한 콘텐츠 | 기기 내 + Apple 검색 | 예 (공개 색인의 경우) |
| 웹 마크업 | 웹사이트에 있는 콘텐츠 | Apple 검색 (기기 간) | 예 |
최대한 넓게 다루려면 세 가지를 모두 사용하세요. CoreSpotlight는 사용자가 아직 보지 않은 콘텐츠를 색인하고, NSUserActivity는 사용자가 상호작용한 콘텐츠를 색인하며(원하면 공개할 수도 있어요), 웹 마크업은 웹사이트의 콘텐츠를 색인해요.
방법 1: CoreSpotlight
CoreSpotlight를 사용하면 앱 콘텐츠의 검색 가능한 색인을 만들 수 있어요. 색인하는 각 항목에는 제목, 설명, 썸네일, 그리고 사용자를 올바른 콘텐츠로 안내하는 고유 식별자가 있어요.
기본 구현
import CoreSpotlight
import MobileCoreServices
func indexProduct(_ product: Product) {
let attributeSet = CSSearchableItemAttributeSet(contentType: .content)
attributeSet.title = product.name
attributeSet.contentDescription = product.description
attributeSet.thumbnailData = product.thumbnailData
// 선택 사항: 추가 메타데이터 추가
attributeSet.rating = NSNumber(value: product.averageRating)
attributeSet.ratingDescription = "\(product.reviewCount) reviews"
let item = CSSearchableItem(
uniqueIdentifier: "product-\(product.id)",
domainIdentifier: "com.yourapp.products",
attributeSet: attributeSet
)
// 항목은 기본적으로 30일 후에 만료돼요
item.expirationDate = Calendar.current.date(byAdding: .day, value: 30, to: Date())
CSSearchableIndex.default().indexSearchableItems([item]) { error in
if let error = error {
print("Indexing failed: \(error.localizedDescription)")
}
}
}
Spotlight 탭 처리
사용자가 Spotlight 결과를 탭하면 앱이 고유 식별자를 받아요. AppDelegate나 SceneDelegate에서 처리하세요:
// SceneDelegate
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
if userActivity.activityType == CSSearchableItemActionType {
guard let identifier = userActivity.userInfo?[CSSearchableItemActivityIdentifier] as? String else {
return
}
// 식별자를 파싱해서 화면 이동
if identifier.hasPrefix("product-") {
let productId = String(identifier.dropFirst("product-".count))
navigateToProduct(productId)
}
}
}
일괄 색인
대규모 카탈로그라면 항목을 일괄로 색인하세요:
func indexAllProducts(_ products: [Product]) {
let items = products.map { product -> CSSearchableItem in
let attributeSet = CSSearchableItemAttributeSet(contentType: .content)
attributeSet.title = product.name
attributeSet.contentDescription = product.description
return CSSearchableItem(
uniqueIdentifier: "product-\(product.id)",
domainIdentifier: "com.yourapp.products",
attributeSet: attributeSet
)
}
// 100개 단위로 일괄 색인
let batchSize = 100
for batchStart in stride(from: 0, to: items.count, by: batchSize) {
let batchEnd = min(batchStart + batchSize, items.count)
let batch = Array(items[batchStart..<batchEnd])
CSSearchableIndex.default().indexSearchableItems(batch) { error in
if let error = error {
print("Batch indexing failed: \(error.localizedDescription)")
}
}
}
}
항목 삭제
앱에서 콘텐츠를 삭제하면 Spotlight 색인에서도 제거하세요:
// 항목 하나 삭제
CSSearchableIndex.default().deleteSearchableItems(
withIdentifiers: ["product-123"]
) { error in
// 오류 처리
}
// 도메인의 모든 항목 삭제
CSSearchableIndex.default().deleteSearchableItems(
withDomainIdentifiers: ["com.yourapp.products"]
) { error in
// 오류 처리
}
// 모든 항목 삭제
CSSearchableIndex.default().deleteAllSearchableItems { error in
// 오류 처리
}
방법 2: NSUserActivity
NSUserActivity NSUserActivity는 원래 Handoff(Apple 기기 간 작업 이어하기)를 위해 설계됐지만, Spotlight 색인과 Siri 제안에도 쓰여요. 활동을 검색 대상으로 표시하면 Spotlight 결과에 나타나요.
기본 구현
class ProductViewController: UIViewController {
var product: Product!
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let activity = NSUserActivity(activityType: "com.yourapp.viewProduct")
activity.title = product.name
activity.isEligibleForSearch = true
activity.isEligibleForPublicIndexing = true // 모든 사용자에게 노출
// 공개 색인에 필요: 웹 URL과 연결
activity.webpageURL = URL(string: "https://www.yourapp.com/products/\(product.id)")
// 검색 속성
let attributes = CSSearchableItemAttributeSet(contentType: .content)
attributes.contentDescription = product.description
attributes.thumbnailData = product.thumbnailData
activity.contentAttributeSet = attributes
// 검색 키워드
activity.keywords = Set(product.tags)
// 앱 콘텐츠와 연결
activity.userInfo = ["productId": product.id]
self.userActivity = activity
activity.becomeCurrent()
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
userActivity?.invalidate()
}
}
공개 색인
다음과 같은 경우: isEligibleForPublicIndexing 이면 true, 애플이 (콘텐츠를 본 사용자뿐 아니라) 모든 사용자의 검색 결과에 콘텐츠를 포함할 수 있어요. 이는 Google App Indexing에 해당하는 애플의 기능이에요.
공개 인덱싱 조건:
- 액티비티에는
webpageURL이 실제 웹 페이지를 가리켜야 해요. - 웹 페이지에는 일치하는 유니버설 링크 설정을 찾아보세요.
- intent URL의
apple-app-site-association파일이 도메인에 올바르게 설정되어 있어야 해요. - 애플은 콘텐츠의 품질과 관련성을 검증해요.
테스트 과정과 함께 볼 설정 레퍼런스는 유니버설 링크 가이드 전체 설정은 다음을 참고하세요.
NSUserActivity 탭 처리
사용자가 NSUserActivity 기반 Spotlight 결과를 탭하면:
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
switch userActivity.activityType {
case "com.yourapp.viewProduct":
if let productId = userActivity.userInfo?["productId"] as? String {
navigateToProduct(productId)
}
case CSSearchableItemActionType:
// CoreSpotlight 결과 (별도 처리)
break
default:
// 유니버설 링크 확인
if let url = userActivity.webpageURL {
handleUniversalLink(url)
}
}
}
방법 3: 웹 마크업
웹사이트에 콘텐츠가 있다면 애플의 웹 마크업을 사용해 웹 페이지를 앱과 연결할 수 있어요. 앱 코드는 바꿀 필요가 없고 웹사이트만 수정하면 돼요. 단, 유니버설 링크가 설정되어 있어야 해요.
스마트 배너
웹 페이지에 Smart App Banner meta 태그를 추가해요:
<meta name="apple-itunes-app" content="app-id=YOUR_APP_STORE_ID, app-argument=https://www.yourapp.com/products/123">
intent URL의 app-argument 은 사용자가 배너에서 "열기"를 탭할 때 앱이 받는 URL이에요. 앱은 유니버설 링크로 이 URL을 처리해야 해요.
Open Graph와 Schema.org
애플 크롤러는 표준 웹 마크업을 읽어요:
<head>
<meta property="og:title" content="Product Name" />
<meta property="og:description" content="Product description" />
<meta property="og:image" content="https://www.yourapp.com/images/product-123.jpg" />
<meta property="og:url" content="https://www.yourapp.com/products/123" />
</head>
유니버설 링크가 제대로 설정되어 있다면, 이 마크업으로 애플이 웹 콘텐츠를 앱과 연결할 수 있어요.
권장 사항
전략적으로 색인하기
모든 것을 인덱싱하지 마세요. 사용자가 검색할 만한 콘텐츠에 집중하세요:
- 제품 이름과 설명
- 기사 제목과 요약
- 연락처 이름 (메시징 앱용)
- 위치 이름 (지도/여행 앱용)
- 미디어 제목 (엔터테인먼트 앱용)
일시적인 콘텐츠(알림, 로딩 화면, 설정 페이지)는 인덱싱하지 마세요.
색인을 최신 상태로 유지하기
오래된 결과는 사용자를 불편하게 해요. 콘텐츠가 바뀌면 인덱스를 업데이트하세요:
func updateProduct(_ product: Product) {
// 업데이트된 데이터로 다시 인덱싱
indexProduct(product)
}
func deleteProduct(_ productId: String) {
CSSearchableIndex.default().deleteSearchableItems(
withIdentifiers: ["product-\(productId)"]
)
}
풍부한 속성 활용하기
CoreSpotlight는 많은 속성 타입:
let attributes = CSSearchableItemAttributeSet(contentType: .content)
attributes.title = "Restaurant Name"
attributes.contentDescription = "Italian restaurant in downtown"
attributes.thumbnailData = thumbnailData
attributes.rating = 4.5
attributes.ratingDescription = "4.5 stars (230 reviews)"
attributes.phoneNumbers = ["+1-555-123-4567"]
attributes.supportsPhoneCall = true
attributes.latitude = 37.7749
attributes.longitude = -122.4194
풍부한 속성을 설정하면 Spotlight 결과가 더 유익하고 바로 실행할 수 있어요.
실제 기기에서 테스트하기
Spotlight 인덱싱은 실제 기기에서만 작동해요 (일부 기능은 시뮬레이터에서 안 돼요). 다음 순서로 테스트하세요:
- 기기에서 앱 실행
- 인덱싱할 콘텐츠로 이동
- 홈 화면에서 아래로 스와이프해 Spotlight 열기
- 콘텐츠 제목이나 키워드 검색
- 결과를 탭해 이동 확인
Tolinku와 Spotlight 색인
Tolinku Tolinku는 애플 공개 인덱싱을 뒷받침하는 유니버설 링크 인프라를 처리해요. 앱의 커스텀 도메인 Tolinku로 설정하면 플랫폼이 자동으로 apple-app-site-association 파일을 제공해서 유니버설 링크와 웹 기반 Spotlight 인덱싱을 모두 쓸 수 있게 해요.
Google의 대응 기능은 다음을 참고하세요: Google App Indexing 설정. 더 넓은 전략은 다음을 참고하세요 모바일 앱의 인덱싱과 SEO.
딥 링킹 팁을 메일로 받아 보세요
일주일에 한 번만 보내요. 스팸은 없어요.