在原始 iOS App 和 App Extension 之间共享代码 [英] Sharing code between original iOS App and App Extension

查看:35
本文介绍了在原始 iOS App 和 App Extension 之间共享代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS 应用和扩展应用之间的共享类

Sharing class between iOS app and extension app

我想在我的应用程序和扩展应用程序中使用自定义类.如果我只在主应用程序文件夹中有该类,则扩展程序不会接受它.我尝试制作它的副本并将其放入扩展文件夹中,但我当然收到了 invalid redeclaration of [my class] 错误.什么是最好的解决方案?这只是一个类,而不是多个资源.

I want to use a custom class in both my app and the extension app. If I just have the class in the main app folder, the extension doesn't pick up on it. I tried making a copy of it and putting it into the extension folder, but I of course get a invalid redeclaration of [my class] error. What's the best solution for this? It's just one class, not multiple resources.

推荐答案

不应复制任何内容.只需添加所需的文件即可为您的扩展编译源代码:

Nothing should be copied. Just add required files to compile sources for your extension:

这篇关于在原始 iOS App 和 App Extension 之间共享代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆