Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
318 views
in Technique[技术] by (71.8m points)

iphone - Xcode won't recognize my new provisioning profile

My app's development provisioning profile expired a couple of weeks ago, so I went to the provisioning portal to get a fresh new one. After obtaining it, I visited the Xcode Organizer, removed the expired profile from my devices as well as my Mac, then imported the new profile. Xcode installs the profile onto my devices immediately, and my app runs again on the devices.

The problem is that while the Organizer is able to see the new profile and install it as normal, the IDE gets confused between the old one and the new one. Every time I try to build the app, it fails immediately. The error console tells me that Xcode can't find the old profile, because the GUID listed belongs to the old one. That's strange; I thought Xcode would've been aware of the new profile by now.

I've tried removing the new profile from my devices and my Mac, then reinstalling the profile. Doesn't work, Xcode is still trying to look for the old one. I've also tried selecting a different profile to make Xcode forget the old one, then selecting the new one. I've even tried manually entering the GUID of the new one in the Other choice. Yet Xcode still insists on looking for the old profile, which by now is already gone from my Mac.

How do I convince Xcode that I've generated a new provisioning profile for my app for it to use?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

tl;dr: turns out I simply had to edit the project file manually to tell Xcode of the new profile. Now, I don't know why I had to manually update the project file. Perhaps I did something wrong during the process of importing the new profile to Xcode, so it didn't realize my new profile had come in. Or the file system choked midway and Xcode wasn't able to update itself. Oh well.

Now for the fun technical part:

IMPORTANT: As with anything else that involves modifying files you shouldn't be modifying: make sure to back up your .xcodeproj bundle and/or your entire Xcode project, or make sure your Xcode project is kept in proper version control. You don't want to mess up and cause Xcode to stop building your project onto your device, without anything to fall back on.

I peeked into the contents of my app's .xcodeproj bundle (Xcode is not running at this time). To view these, open your project folder in Finder, then Control-click on your .xcodeproj file and choose Show Package Contents:

Breeze.xcodeproj/
  Daniel.mode1v3
  Daniel.pbxuser
  project.pbxproj

Then opened project.pbxproj in a text editor (it's text, not binary), and looked around for build configuration information.

There's a section labeled /* Begin XCBuildConfiguration section */ (which you can find using your editor's search function). It's a list of entries, each of which represents a code-signing configuration for a given profile in a given build configuration.

Here's information about the profile I use to sign my binary for development:

1D6058940D05DD3E006BFB54 /* Debug */ = {
    isa = XCBuildConfiguration;
    buildSettings = {
        ALWAYS_SEARCH_USER_PATHS = NO;
        "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Daniel Tan (XXXXXXXXXX)";
        COPY_PHASE_STRIP = NO;
        GCC_DYNAMIC_NO_PIC = NO;
        GCC_OPTIMIZATION_LEVEL = 0;
        GCC_PRECOMPILE_PREFIX_HEADER = YES;
        GCC_PREFIX_HEADER = Breeze_Prefix.pch;
        GCC_VERSION = com.apple.compilers.llvmgcc42;
        INFOPLIST_FILE = "Breeze-Info.plist";
        IPHONEOS_DEPLOYMENT_TARGET = 4.0;
        PRODUCT_NAME = "Breeze";
        "PROVISIONING_PROFILE[sdk=iphoneos*]" = "36F99F3E-805F-47A7-95D4-FF8324711CBE";
        SDKROOT = iphoneos;
    };
    name = Debug;
};

Of note is this line:

"PROVISIONING_PROFILE[sdk=iphoneos*]" = "36F99F3E-805F-47A7-95D4-FF8324711CBE";

That's the GUID reported by the build error; the identifier of my old, expired provisioning profile.

All I had to do was replace it with the GUID of the new profile:

"PROVISIONING_PROFILE[sdk=iphoneos*]" = "E6E6369E-FD58-4886-9C3A-72C9DAE36501";

I open my project in Xcode again, and now my app builds and installs on my devices successfully, using the new provisioning profile.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...