iPhone building/testing for the device

  • Twitter
  • Facebook
  • Digg
  • Reddit
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
November 1st, 2008 Posted by: - posted under:Articles

Building for the simulator is easy. Building for the device, however, can be troublesome, especially when using version control to share your code with other developers.

Often times, the project.pbxproj file ends up with settings that disable Xcode from building your application for the device. Here is a common and frustrating error:

CodeSign error: a valid provisioning profile is required for product type ‘Application’ in SDK ‘Device – iPhone OS 2.1′

That is not a helpful error message. In my experience, I can change the settings in the “Get Info” window to exactly what they should be without it fixing the problem. Here’s how I hack my project.pbxproj to avoid that problem:

Opening the project.pbxproj file in vim (vim – oh, how I’ve missed you!), I search for “Debug” and find:

1D6012340D05DD3E126BFB12 /* Debug */ = {isa = XCBuildConfiguration;buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CODE_SIGN_IDENTITY = "iPhone Developer: Josh Stephenson"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Josh Stephenson"; COPY_PHASE_STRIP = NO;        GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Sample_Prefix.pch; INFOPLIST_FILE = Info.plist; PRODUCT_NAME = Sample; PROVISIONING_PROFILE = BIG LONG GUID HERE;};name = Debug;};

Delete the PROVISIONING_PROFILE line completely.

Searching for Debug again, I found:

C01FCF4F08A954540054247B /* Debug */ = {isa = XCBuildConfiguration;buildSettings = {    ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CODE_SIGN_IDENTITY = "iPhone Developer: Josh Stephenson"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Josh Stephenson"; GCC_C_LANGUAGE_STANDARD = c99; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = /usr/include/libxml2; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "-lxml2"; PREBINDING = NO; PROVISIONING_PROFILE = BIG LONG GUID HERE; "PROVISIONING_PROFILE[sdk=iphoneos*]" = BIG LONG GUID HERE; SDKROOT = iphoneos2.0;};name = Debug;};

Delete both of the lines.

Now, save the file and go back to Xcode. Click “Read from Disk”:

At this point, everything in your “Get Info” window looks the same, but everything behind the interface is right:

That should do it.

  • shanev

    This was super useful. Thanks!

  • Benjamin

    Thank you. Thank you Thank you.

  • jake

    Saved me hours of digging around, thanks!

  • pmalos

    Thanks so much.

  • alexishinds

    Thanks so much. Just ran into this and was at a loss.

  • Favo Yang 杨仲伟

    But than we can not put the project.pbxproj file into SVN? It’s boring to deal with the conflict.

  • Scott

    Thanks – that did it!

  • Ethical Paul

    Nice post. How is a mortal supposed to figure this out?

  • slothbear

    I wiggled and jiggled my app, but it didn’t work until I found this post. Thanks.

blog comments powered by Disqus