在我的WatchKit扩展中引用Objective c类(swift)(Reference a Objective c class in my WatchKit extension (swift))

编程入门 行业动态 更新时间:2024-10-06 20:30:16
在我的WatchKit扩展中引用Objective c类(swift)(Reference a Objective c class in my WatchKit extension (swift))

我的主要项目是在Objective c中 ,我正在开发Swift中的 watchkit 。 现在我的要求是我必须在swift (Watchkit扩展)中访问目标c方法。

我创建了一个并在其中导入了所需的类。

如果它在同一个项目中,我能够在swift文件中访问这个目标c类。 我无法在watchkit扩展中访问它。

我确实在目标成员资格的 watchkit扩展中添加了所需的类.m文件, 并且在将其添加到目标成员资格后我能够访问watchkit扩展中的swift文件

到目前为止还无法解决这个问题。 我该怎么做才能访问Watchkit扩展( Swift )中的主应用目标c类?

My main Project is in Objective c and i am developing watchkit in Swift. Now my requirement is that I have to access objective c methods in swift (Watchkit extension).

I have created a bridge and imported the required class in it.

I was able to access this objective c class in swift file if it is in the same project. I was not able to access it in watchkit extension.

I did added the required class .m file in watchkit extension form the Target Membership with no use and i was able to access swift file in watchkit extension after adding it to target membership

So far not being able to solve this. What should i do to access Main app objective c class in Watchkit extension (Swift)?

最满意答案

我解决了这个问题。 我只需添加我在Apple Watch Target中创建的Bridge。 我一做到了就能够访问Bridge Header中的共享类。

I solved this problem. I just had to add the Bridge i created in the Apple Watch Target as well. As soon as i did i was able to access the shared classes in Bridge Header.

更多推荐

本文发布于:2023-08-07 11:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464064.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:swift   Objective   WatchKit   extension   class

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!