打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Creating a Mac Version of Your iPad App | Apple Developer Documentation

With Xcode 11 and later, you can create a Mac version of your iPad app using Mac Catalyst. Configuring your app for Mac can take just a click in a checkbox, although you may need more steps, depending on the features and frameworks that your app uses.

Configure Your App for Mac

To add support for Mac, open your Xcode project and select the iOS target that you want to configure. In the General tab, under Deployment Info, select the Mac checkbox. (If your app supports iPhone only, the checkbox is unavailable.)

When you enable Mac support, Xcode adds the App Sandbox Entitlement to your project. Xcode only includes this entitlement in the Mac version of your app, not the iOS version. Xcode also adds My Mac to the list of destinations. Select this destination to run your Mac app from Xcode.

At this point, you may be able to build and run the Mac version of your app. To give it a try, select My Mac as the destination and run your project.

Go Beyond the Checkbox

You may find that the Mac version of your app still doesn’t build because:

  • Your project includes incompatible frameworks, libraries, or embedded content.

  • Your source code references unsupported APIs.

When you enable Mac support, Xcode automatically excludes incompatible frameworks and embedded content where possible for Mac builds of your project. Still, you may need to manually exclude other frameworks or content.

To manually exclude an item, open Frameworks, Libraries, and Embedded Content under the General tab for your iOS target. Then select iOS as the platform setting for the item. This setting excludes the item from the Mac version of your app.

If you have source code referencing APIs unavailable to the Mac version of your app, enclose the code in a compilation conditional block that uses the targetEnvironment(): platform condition.

#if !targetEnvironment(macCatalyst)// Code to exclude from Mac.#endif

You can use these same approaches to include a framework and code that are available only in macOS. For a framework, select macOS for the platform setting, and enclose the code with a #if targetEnvironment(macCatalyst) statement.

Make Your App More Like a Mac App

After following these steps, you should be able to run your iPad app on Mac. But before you ship your new app to customers, it needs a few more changes to make it more like a Mac app. To learn more, see Optimizing Your iPad App for Mac.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
ios(iPhone,iPad)开发硬件投入成本指南 | 帝都码农
AppStore新应用上传指南
Delphi XE4 For iOS 真机调试教程
升级Xcode 10后遇到的问题
基于Phonegap的IOS应用下的ios开发环境搭建
在Xcode中从动态库剥离不需要的架构(90008错误)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服