One problem I had tonight trying to set up an Xcode project for my previous post was in trying to set up the embedded framework.
The instructions on Apple’s Web site, Creating a Framework: Creating a Private Embedded Framework, are good as far as they go.
They say to add your embedded framework to two build phases in your application’s target. First, the Frameworks & Libraries phase, which makes sure the framework gets linked properly. And second, the Copy Files phase that copies the framework into the application bundle.
Now, the instructions emphasize that, for step one, you have to drag from the Products node, not the Target node. But they don’t emphasize the same thing for step two. I tried to accomplish step two by dragging the framework icon that was now in the Frameworks & Libraries phase into the Copy Files phase.
What I was expecting this to do was put a second representation of the framework in Copy Files. What it actually did was move the framework representation from Frameworks & Libraries to Copy Files. This gave me the impression you could only have one framework representation in your build phases – maybe putting it in the Copy Files phase was enough, it would automatically link it? (Nope.)
It turns out that if I’d dragged the framework from the Products node again, I would’ve gotten the framework representation duplicated in both phases. But what I also found, from playing around with it, is that starting the drag from Frameworks & Libraries, then holding down the Option key, turned the drag into a copy drag (cursor turns into a green plus sign), which has the same effect.
A copy-drag?? I complained here about using a single tree to represent a series of unlike objects. But this is even worse; unlike objects that look exactly the same. The same framework icon appears under the project sub-tree and the Targets sub-tree, but it represents two fundamentally different things – an actual file versus a build phase value. Which means different drag behavior. Even though they look exactly the same.