xCode: Linking with existing project, Importing files from this project
I have an iOS app project ProjA in xCode 4, and a separate C++ dynamic library project ProjB. I wish to import specific files from the ProjB for use within ProjA.
Here's what I've done:
- Right-click on ProjA.xcodeproj within project navigator on left, selected "Add files开发者_运维百科 to ProjA..", then selected ProjB.xcodeproj in file browser.
- Left-click on ProjA.xcodeproj and under 'Build Phases' added ProjB.dylib in both Target Dependencies and Link Binary With Libraries.
I now wish to import MyClass from ProjB within ProjA. Thus in a ProjA class I have tried:
#include "MyClass.h"
#import "MyClass.h"
..but neither of these locates MyClass within ProjB.
Could someone please tell me what I'm doing wrong? It's very frustrating! I've googled around and it seems I'm importing the project correctly, so perhaps it's just my include/import which needs adjusting.
Many thanks for your time.
Well I haven't figured out how to do a neat import.. so for now I've just done a relative path that backtracks to the other project location.
I had compilation troubles after this, XCode wouldn't parse the cpp in my other project. The problem was due to importing the cpp files into a .m file. I renamed this .m file to .mm and everything compiled fine! So follow the steps I did, then rename whichever Obj-C file MyFile.m you're importing .cpp/.mm files into to be MyFile.mm
精彩评论