This one looks like a bug in Xcode 7.1.1.  It was fixed in Xcode 7.2, but I’m writing it up anyway because the answer was not easy to find.

We were adding a new embedded framework to an app recently. It built on the local Mac just fine, but it failed to build on Jenkins. In fact, Jenkins kept reporting that it failed to build the sub-project’s scheme named “Mac OS X”.  But it was only intended to build the iOS scheme.

At first it seemed like a problem with Jenkins.  We could build the the project just find on Xcode on a developer’s Mac.  But then we found we could reproduce the problem by using xcodebuild in the terminal.

After a lot of aggravation, it turned out to be a problem with Xcode 7.1.x when more than one build product has the same name.  Our sub-project was set to build a framework for either Mac OS X or for iOS.  Both of them had the same name, like “myProject.framework”.

When adding a new embedded framework in the project’s “General” tab, in the “Embedded Frameworks” section with the “+” button, Xcode would see the 2 products of the subproject with the same name and nicely add “Mac” and “iOS” in gray letters.  Unfortunately, Xcode got them exactly backwards.

Every time we thought we were adding the iOS version of the embedded framework, we were actually adding the Mac version, or so it seemed. It was actually more frustrating, because it randomly succeeded in its build, so just when we thought we had fixed it, we would run one more build and it would fail.

Whenever we changed the name of one of the frameworks in the inner project, the outer project would immediately update to show us that it had referenced the Mac framework instead of the iOS framework we thought we had selected.

Just as I thought we had it narrowed down enough to file a bugreporter entry, I tried it on Xcode 7.2 and it worked fine.  OK I won’t file a bug with Apple.  I did find a similar bug on Open Radar so it would probably be redundant. But, I can blog about it here and maybe help someone else some time.

(Its late and I am tired.  I wanted to do a more thorough job on this article, but I need to go to sleep. I may update this later to make it better.)

Update: Even after the bug fix for Xcode 7.2, it still has trouble adding new embedded frameworks to the product.  I tried to add one today and it continually failed.  Even GIT agreed that the project file did not change.

In the end, I found that it would add the framework if I dropped it onto the “Embed Binaries” section of the project from the Finder.