###前提・実現したいこと
Swift4とxcode9.0でSpotifyのAPIを使ってみるアプリ("SpotifyStudy")を開発しています。
このアプリが起動するとSpotifyのログイン画面が立ち上がり、自分のアカウントでログインすると楽曲が再生されるという仕組みです。
Spotifyの公式チュートリアルがObjective-C用だったのでSwiftで使うためにBridge Headerを自分なりに調べて書いていたのですが以下のような2つのエラーが解決できません。
###発生している問題・エラーメッセージ
/Users/[私のユーザネーム]/Desktop/SpotifyStudy/SpotifyStudy/SpotifyStudy/SpotifyStudy-Bridging-Header.h:13:9: error: 'SpotifyAuthentication/SpotifyAuthentication.h' file not found #import <SpotifyAuthentication/SpotifyAuthentication.h>
<unknown>:0: error: failed to emit precompiled header '/Users/[私のユーザネーム]/Library/Developer/Xcode/DerivedData/SpotifyStudy-aasqdpuzvhmgwneqbieddvtsoiam/Build/Intermediates.noindex/PrecompiledHeaders/SpotifyStudy-Bridging-Header-swift_RTWEOMNR105G-clang_149BTWH3ZJQG5.pch' for bridging header '/Users/[私のユーザネーム]/Desktop/SpotifyStudy/SpotifyStudy/SpotifyStudy/SpotifyStudy-Bridging-Header.h'
###該当のソースコード
Swift
1// 2// AppDelegate.swift 3// SpotifyStudy 4// 5// Created by [私のユーザネーム] on 2017/10/04. 6// Copyright © 2017年 [私のユーザネーム]. All rights reserved. 7// 8 9import UIKit 10 11@UIApplicationMain 12class AppDelegate: UIResponder, UIApplicationDelegate, SPTAudioStreamingDelegate { 13 14 var window: UIWindow? 15 16 let kClientId = "[私のClient ID]" 17 let kRedirectUri = NSURL(string: "[私のRedirect URI]") 18 19 var session: SPTSession? 20 var player: SPTAudioStreamingController? 21 22 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 23 // Override point for customization after application launch. 24 25 // set up Spotify 26 SPTAuth.defaultInstance().clientID = kClientId 27 SPTAuth.defaultInstance().redirectURL = kRedirectUri 28 SPTAuth.defaultInstance().requestedScopes = [SPTAuthStreamingScope] as [AnyObject] 29 let loginUrl = SPTAuth.defaultInstance().loginURL 30 application.openURL(loginUrl) 31 32 return true 33 } 34 35 // handle auth 36 func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool{ 37 38 if SPTAuth.defaultInstance().canHandleURL(url){ 39 40 SPTAuth.defaultInstance().handleAuthCallbackWithTriggeredAuthURL(url, callback: { error, session in 41 42 if error != nil{ 43 print("*** Auth error: (error)") 44 } 45 46 // Call the -loginUsingSession: method to login SDK 47 self.loginUsingSession(session) 48 }) 49 50 return true 51 } 52 53 return false 54 } 55 56 func loginUsingSession(session: SPTSession){ 57 58 // Get the player Instance 59 player = SPTAudioStreamingController.sharedInstance() 60 61 if let player = player { 62 63 player.delegate = self 64 65 // Start the player (will start a thread) 66 try! player.startWithClientId(kClientId) 67 68 // Login SDK before we can start playback 69 player.loginWithAccessToken(session.accessToken) 70 } 71 } 72 73 // MARK: SPRAudioStreamingDelegate. 74 75 func audioStreamingDidLogin(audioStreaming: SPTAudioStreamingController!){ 76 77 let urlStr = "spotify:track:6ZSvhLZRJredt15aJiBQqv" // track available in Japan 78 player!.playSpotifyURL(urlStr, startingWithIndex: 0, startingWithPosition: 0, callback: { error in 79 80 if error != nil { 81 82 print("*** failed to play: (error)") 83 return 84 } else { 85 print("play") 86 } 87 }) 88 89 } 90 91 func applicationWillResignActive(_ application: UIApplication) { 92 // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 93 // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 94 95 } 96 97 func applicationDidEnterBackground(_ application: UIApplication) { 98 // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 99 // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 100 } 101 102 func applicationWillEnterForeground(_ application: UIApplication) { 103 // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 104 } 105 106 func applicationDidBecomeActive(_ application: UIApplication) { 107 // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 108 } 109 110 func applicationWillTerminate(_ application: UIApplication) { 111 // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 112 } 113 114 115} 116
Objective
1// 2// AppDelegate.h 3// SpotifyStudy 4// 5// Created by [私のユーザネーム] on 2017/10/04. 6// Copyright © 2017年 [私のユーザネーム]. All rights reserved. 7// 8 9#ifndef AppDelegate_h 10#define AppDelegate_h 11 12#import <SpotifyAuthentication/SpotifyAuthentication.h> 13#import <SpotifyAudioPlayback/SpotifyAudioPlayback.h> 14#import <SafariServices/SafariServices.h> 15#import <SpotifyStudy-Bridging-Header.h> 16 17#endif /* AppDelegate_h */
###試したこと
以下のサイトのことは全て試しました。
http://www.hawk-a.com/exception_code/archives/906
https://qiita.com/titoi2/items/abe7b58a9e644b29e8c3
https://qiita.com/mokemokechicken/items/6716193cfcbd0a4d8b84
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。