1

I am working with the AR Drone to develop new application.

I want to establish a dependency between two projects. So when I compile one, I hope Xcode will help compile the another one automatically. I had searched with Google for this question. The solutions found are quite old and not applicable for Xcode 4.

Right now, I have two project, namely, ARDroneEngine.xcodeproj and FreeFlight.xcodeproj.

ARDroneEngine is a library for FreeFlight. Here comes the screenshot.

enter image description here

If I compile FreeFlight with iPhone / iPad simulator, it is fine since the ARDroneEngine is last compiled with the same setting. This is where the question lies. To test my application, I want to compile and run FreeFlight in my iPhone. So when I change the setting to "FreeFlight > xxx's iPhone" and compile, the error occurs: "Apple Mach-O Linker Error".

I think the problem is rooted from the Target Dependencies between two projects. A quick workaround will be: Compile the ARDroneEngine again with the new Scheme "ARDroneEngine > xxx's iPhone" and launch FreeFlight in Xcode for my iPhone.

But I want a more complete solution with the dependencies between projects. If more information is required to solve the problem, I can always provide new info.

Thanks, Steven

LKS
  • 673
  • 2
  • 10
  • 21
  • So what I hope to achieve: If I compile FreeFlight with the new Scheme(for example, my iPhone), it will re-compile ARDroneEngine with the new Scheme and update the file libARDroneEngine.a – LKS Mar 17 '12 at 20:36

1 Answers1

1

Xcode's solution to cases like this is to use a Workspace that encompasses both projects: then, when one project has a target that references the build product of another, it automagically works out the dependencies and builds them in order.

  1. Create a new Workspace (File > New > Workspace); name it and save it anywhere you like (though putting it in a parent folder to both project directories might be a good idea).
  2. Add both projects (drag the xcodeproj files from the Finder into the navigator pane, or use File > Add Files).
  3. Expand the Products group of your library project so you can see the (placeholder for the) built library (libARDroneEngine.a).
  4. Select the app project (FreeFlight) in the navigator and its app target in the editor -- you should be looking at the Summary pane for the target (the one with bundle identifier, deployment info, entitlements, and most importantly, the "Linked Frameworks & Libraries" list).
  5. Drag the library (libARDroneEngine.a) from the navigator (where you made it visible in step 3) into the Linked Frameworks & Libraries list.

That's it! Now you can choose the FreeFlight > xxx scheme and it'll automatically build the library project before building the app.

You can probably get a more complete summary of these instructions (with screenshots and all) in the Xcode help for Workspaces.

rickster
  • 124,678
  • 26
  • 272
  • 326
  • I think your solution may work but right now, the libARDroneEngine.a is in red color so I guess the file is not successfully located? Do you have any idea how I can add it back? Thanks! – LKS Mar 17 '12 at 21:29
  • In my projects that do this, the library shows up red in the Linked Frameworks & Libraries list, but it still gets built & linked. Chalk it up to Xcode weirdness, I guess. (Or maybe their docs have a better way?) – rickster Mar 17 '12 at 21:37
  • It appears red in the FreeFlight's "Linked Frameworks & Libraries list". Then I try it by changing the Scheme. It fails as those two projects are still unlinked :( – LKS Mar 17 '12 at 21:45
  • Actually, it worked out before without any modification. For my previous AR Drone project, when I launch FreeFlight, the ARDrone Engine will also be re-built as shown from the status bar in Xcode. Xcode is weird for this time. – LKS Mar 17 '12 at 21:50
  • Hm. It's been awhile since I set up one of my projects this way, so maybe I'm not correctly inferring what I did to set the workspace up from looking at its current state. Sorry! [There's another question on this](http://stackoverflow.com/questions/5534235/) whose answers might be more helpful. – rickster Mar 17 '12 at 21:58
  • 2
    I figured in some versions of Xcode, I had to restart Xcode to make sure that projects are properly loaded. Thought it might be a good tip for people trying to fight Xcode and wasting hours. – user210504 May 13 '12 at 00:54
  • This comment saved my life. – marzapower Mar 07 '13 at 10:51