Search code examples
xcodeapp-storemacos-sierra

With XCode 8 How Do I Target My App To Run on macOS also (it already runs on iPhone / iPad)?


Can someone show me what I change in my project in XCode so that my app will also deploy to a Mac?

For example, I'm running a Mac Mini but I cannot seem to run my app on the actual Mac, even though it is a Universal app and runs on both iPhone and iPad platforms. My app is already deployed to the app store ( https://itunes.apple.com/us/app/cyapass/id1183137527?mt=8 ) and I've tried to install it to the Mac that way, but that doesn't work either.

Is this possible through a simple change in the XCode project? Or, do I have to create a new project that targets the Mac specifically?

If you have screenshots from XCode those would be greatly appreciated if the change is made in the XCode project.


Solution

  • Unfortunately, there are some frameworks which are not applicable for OS X that iOS development depend on, such as the UIKit. You can see the full list here.

    Chameleon, once done, can hopefully make the transition from iOS to OS X easier.

    Although, you won't necessarily need to create a new XCode Project, as you can share the common frameworks and logic in-between the two platforms.

    You could essentially structure your code like so (inspired by another SO post)

    - Workspace
        - Shared Code
            - File1.m       Target: iOS and OSX
        - iOS
            - File2.m       Target: iOS
        - OSX
            - File3.m       Target: OSX
    

    It is although important when doing so to set the appropriate targets of each individual file.

    Last but not least, Apple has previously, during WWDC13, given a talk about how to bring iOS Apps to OS X. Note that the talk can only be seen using either the WWDC App or Safari. I have previously found this talk helpful myself once I needed to implement an OS X version of an existing iOS app.