在原始 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: