Peter-Schorn / SpotifyAPIExampleApp

An Example App that demonstrates the usage of SpotifyAPI.
23 stars 8 forks source link

Example App Only runs on iPhone when launched from xCode debugger #2

Closed williamrct closed 3 years ago

williamrct commented 3 years ago

Curious to know if this is expected behavior. I build and run the example app from within xCode IDE with my iPhone tethered, If I try to launch the example app on the iPhone directly the app launches and quickly closes.

Peter-Schorn commented 3 years ago

That is how apps installed through Xcode work.

williamrct commented 3 years ago

Peter .... you must have misunderstood my question... see I have over 100 apps and they behave normal.... example I deploy app on the iPhone and I can launch the app without it being tethered and it runs. But then again you know that.... Peter-Schorn... i will post a video explaining why yours and only yours does not... then again you can let everyone know too...

Peter-Schorn commented 3 years ago

I would be interested in the reason why my app does not launch without the device being connected to the computer running Xcode. All the apps I've used required this in order to launch.

williamrct commented 3 years ago

Ok Peter .... because

private static let clientId: String = { return "" / if let clientId = ProcessInfo.processInfo .environment["client_id"] { return clientId } fatalError("Could not find 'client_id' in environment variables") / }()

private static let clientSecret: String = {
    return "<clientSecret>"
    /*
    if let clientSecret = ProcessInfo.processInfo
            .environment["client_secret"] {
        return clientSecret
    }
    fatalError("Could not find 'client_secret' in environment variables")*/
}()

So you've gone on record with your answer and I have with mine.

Peter-Schorn commented 3 years ago

That does explain why the app only launches from Xcode. You can fix this if you want by hardcoding the client id and client secret into the source code. Just be careful not to expose it publicly.