我的主要项目是在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.
更多推荐
发布评论