开发者

Integrating a C project in the iPhone SDK

This is my first time doing this sort of project so apologies if the question is silly.

I've got a question about using a C project with a project in the iPhone SDK. I've dragged and dropped the C project into the iPhone project in Xcode (so it appears in the screenshot below).

sjeng.h开发者_开发技巧 is a file inside GameEngine.xcodeproj, but when I try to include the header file, I not only receive an error, but the file it is looking for seems to be capitalized whereas the import statement is not.

Integrating a C project in the iPhone SDK

Does anyone know what the problem might be?

Thanks!


You can add files to an XCode project either by drag & drop, or by the Project/Add to project... command (2 ways of accomplishing the same thing).

The problem appears to be that you have added the "GameEngine.xcodeproj" project file into your "Test" project, but you have not included the files (such as sjeng.h) that actually comprise the "GameEngine" project. That's not going to work.

There are two separate ways you could approach this:

1) add all the .c and .h files from "GameEngine" to "Test", and just compile them as part of the iPhone application directly. This is sometimes the most straightforward way, but it's not exactly best practice in terms of modularity and code reuse.

2) make the "GameEngine" project build a Framework (perhaps it's already set up to build as a framework), then add that Framework to your "Test" project. Obviously, you'll need to build the "GameEngine" Framework using the iPhone SDK with appropriate settings (simulator vs. device) to match how you're building the rest of the application. In this case you would have a 2-step build process: first open the "GameEngine" project and build the Framework, then open your "Test" project and build it.


I believe you need to add the source files to your project (Project/Add to project...), rather than drag and drop the .xcodeproj file. You can uncheck "Copy items into destination group's folder (if needed)" if you just want to reference the files without duplicating them. Be sure to include all the required source files (e.g. sjeng.h etc.).

Make sure the files are added to the right Targets in your iPhone project.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜