Duplicate Code Signing on Xcode with Any iOS SDK

Working with Xcode code signing is a pain. You may have encountered a situation where there are more than two code signing identity's in Xcode. This means that you potentially have to change four different code signing settings to update your app, rather than just two. I think this is cruft from upgrading to the newest Xcode version or something. Here's what it looks like and here's how to fix it. It's very annoying when developing and testing with adhoc and app store builds.

 

Code signing in Xcode 4

 

The issue is visible with the "Any iOS SDK" seen as a subitem to the Debug and the Release builds. Things won't work correctly if the two don't match in my experience. So I end up having to change two at a time.

Solution

You can close Xcode or keep it open. It seems to work either way before you start the next steps.

1.Open your project folder in finder. (Right click project in Xcode and choose "Show in Finder")

Show in finder

2. Right click on the Xcode project file in Finder -> "Show Package Contents"

Xcode project Show package contents

3. Right click on the project.pbxproj and choose "Open With" -> "TextEdit"

Xcode project in Textedit

4. Search for "Sign" and delete any lines that look like the following. Xcode will regenerate, so don't worry about deleting them. I believe the first two are the root of the problem.

"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";

"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";

CODE_SIGN_IDENTITY = "iPhone Developer";

Textedit code sign identity

5. Open the project settings in Xcode and see the duplicate "Any iOS SDK" are removed and Xcode regenerated the default Code Sign Identities.

Fixed code sign duplicates

6. Update with your credentials for Debug/Release.

Update code sign

Enjoy.

Objective-C/C++ iPhone Build Failures

If you're working with Objective-C/C++ (i.e. mixing both languages) in an iPhone/Mac application you may come across some strange errors in the build process due to a configuration issue.

error: bits/c++config.h: No such file or directory

[caption id="attachment_1005" align="aligncenter" width="457" caption="Too many build failures"][/caption]

One of my projects, Texture Evolution was a Mac application that referenced a C++ Mac library. About 6 months ago I ran into an issue where my build would fail. It may have been related to an update to Xcode, but I'm not entirely sure. After a lot of time, frustration, Google'ing, and project configuration changes I came across a solution.

Today I ran into the same problem and couldn't quite remember how to fix it for my Doxygen Xcode documentation Target that references the C++ Mac library. I wasted more time trying to figure it out again, so here's the breakdown.

The Problem:

Using iostream.h or other STL from C++ and compiling with the Base SDK set to 10.4 and GCC 4.0.

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk/usr/include/c++/4.0.0/iostream:43:0 /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk/usr/include/c++/4.0.0/iostream:43:28: error: bits/c++config.h: No such file or directory

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk/usr/include/c++/4.0.0/iosfwd:45:0 /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk/usr/include/c++/4.0.0/iosfwd:45:29: error: bits/c++locale.h: No such file or directory

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk/usr/include/c++/4.0.0/iosfwd:46:0 /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk/usr/include/c++/4.0.0/iosfwd:46:25: error: bits/c++io.h: No such file or directory

(11,000+ other errors)

The Solution:

Set the Base SDK to Mac OS X 10.5 and GCC to 4.2. You'll need to make changes to project using the library as well as the libraries Target/Project settings. When you make changes make sure the Target properties displays "All Configurations" (i.e. Debug/Release/Release Adhoc/Release AppStore) so that you fix it for all of your build types. Double check and make sure that your static libraries and your project Targets have matching configurations.

[caption id="attachment_1000" align="aligncenter" width="461" caption="Using Base SDK: Mac OS X 10.5 and GCC 4.2"][/caption]

Why?

It may be a simple configuration issue, but I'm not really sure. For some reason when I use GCC 4.0 it builds against arm and uses the iPhone SDK, but when I use GCC 4.2 it uses the Mac SDK. The library is explicitly targeting Mac OS X 10.4, but it doesn't seem to work when it's targeting GCC 4.0. Here's the comparison build output:

Base SDK Mac OS X 10.4, GCC 4.0

CompileC /Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug-CompileC /Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug-iphoneos/MacEvolutionLib.build/Objects-normal/armv6/Canvas.o ../../source/Canvas.cpp normal armv6 c++ com.apple.compilers.gcc.4_0
cd /Users/paulsolt/dev/ArtworkEvolution/Xcode/ArtworkEvolution
setenv LANG en_US.US-ASCII
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.0 -x c++ -arch armv6 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wunused-variable -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk -mfix-and-continue -gdwarf-2 -mthumb -miphoneos-version-min=3.2 -iquote /Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug-iphoneos/MacEvolutionLib.build/MacEvolutionLib-generated-files.hmap -I/Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug-iphoneos/MacEvolutionLib.build/MacEvolutionLib-own-target-headers.hmap -I/Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug-iphoneos/MacEvolutionLib.build/MacEvolutionLib-all-target-headers.hmap -iquote /Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug-iphoneos/MacEvolutionLib.build/MacEvolutionLib-project-headers.hmap -F/Users/paulsolt/dev/xcode_build_output/Debug-iphoneos -I/Users/paulsolt/dev/xcode_build_output/Debug-iphoneos/include -I/Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug-iphoneos/MacEvolutionLib.build/DerivedSources/armv6 -I/Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug-iphoneos/MacEvolutionLib.build/DerivedSources -fvisibility=hidden -c /Users/paulsolt/dev/ArtworkEvolution/Xcode/ArtworkEvolution/../../source/Canvas.cpp -o /Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug-iphoneos/MacEvolutionLib.build/Objects-normal/armv6/Canvas.o

Base SDK Mac OS X 10.5, GCC 4.2

CompileC /Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug/MacEvolutionLib.build/Objects-normal/x86_64/Canvas.o /Users/paulsolt/dev/ArtworkEvolution/Xcode/ArtworkEvolution/../../source/Canvas.cpp normal x86_64 c++ com.apple.compilers.gcc.4_2
cd /Users/paulsolt/dev/ArtworkEvolution/Xcode/ArtworkEvolution
setenv LANG en_US.US-ASCII
/Developer/usr/bin/gcc-4.2 -x c++ -arch x86_64 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -isysroot /Developer/SDKs/MacOSX10.5.sdk -mfix-and-continue -mmacosx-version-min=10.5 -gdwarf-2 -iquote /Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug/MacEvolutionLib.build/MacEvolutionLib-generated-files.hmap -I/Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug/MacEvolutionLib.build/MacEvolutionLib-own-target-headers.hmap -I/Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug/MacEvolutionLib.build/MacEvolutionLib-all-target-headers.hmap -iquote /Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug/MacEvolutionLib.build/MacEvolutionLib-project-headers.hmap -F/Users/paulsolt/dev/xcode_build_output/Debug -I/Users/paulsolt/dev/xcode_build_output/Debug/include -I/Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug/MacEvolutionLib.build/DerivedSources/x86_64 -I/Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug/MacEvolutionLib.build/DerivedSources -fvisibility=hidden -c /Users/paulsolt/dev/ArtworkEvolution/Xcode/ArtworkEvolution/../../source/Canvas.cpp -o /Users/paulsolt/dev/xcode_build_output/ArtworkEvolution.build/Debug/MacEvolutionLib.build/Objects-normal/x86_64/Canvas.o

Notes:

GCC 4.2 is required for 10.5, if you try and use the Base SDK of 10.4 and GCC 4.2 you'll get this error.

GCC 4.2 is not compatible with the Mac OS X 10.4 SDK