开发者

Using a class created in an iOS project in a Mac app

I have a class I created in the iOS app that I want to use in the Mac app. Both projects are in the same workspace. I simply added a file to 开发者_StackOverflow社区Mac app project by selecting the header of the iOS class. This way, the Mac app knows about the class. When I build the Mac app, I get the following linker error:

Symbol(s) not found for architecture x86_64

Any help would be appreciated.

==========================================================

Well, I solved my own problem right after I posted this. Hopefully this will be helpful for anyone else who runs into this issue.

I only added a link to the header file of the iOS class to the Mac app project. When I also added a link to the .m file of the iOS class, that's when everything started working.

It makes sense. The Mac app needs to compile the implementation of the class also.


You need to add the source file along with the header (usually a .m, .mm, or .cpp file.) Otherwise the class does not get compiled in the Mac app. The header declares the class but does not define it, which is why you get an error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜