AppleTV Lessons 8: Cross Platform Code

Today, while taking a break from my Swift book, I decided to set things up for Swift dev on the platform. When you live your life with cross-platform code, having to deal with a new platform is…difficult.

For the moment, I’m treating tvOS as a variation of iOS and converting all my statements that look like this:

#if os(iOS)
    #else
#endif

to be flipped on their heads to test for OSX instead. It’s a huge pain in the neck.

In theory there should be a construct like if os(tvOS) but I have yet to figure it out exactly. Grrr.

Update:

 #if os(iOS)
 #elseif os(tvOS)
 #else
 #endif

One Comment