Repository navigation
Explain how a provisioning profile is selected - #202
Conversation
GetMobileProvision used to load the first file named '<profile name>.mobileprovision' it found, without looking at any other profiles. A hand-copied profile in the old ~/Library/MobileDevice/Provisioning Profiles directory would then hide a newer profile with the same name in Xcode's current ~/Library/Developer/Xcode/UserData/Provisioning Profiles directory, even if the hand-copied one had expired. Nothing in the build log showed that this happened. Now all profiles in both directories are checked: * A profile matches if its name, UUID or file name matches. * Expired profiles are skipped, unless every matching profile has expired (then the newest one is used, like before). * The newest matching profile is used. * Every profile is logged, with its full path and the reason it was or wasn't used. Also add the full path to the messages from GetMobileProvisions, and rebuild the profile index when a profile file is overwritten (this doesn't change the modification date of the directory). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f60b31f7-1c81-4100-858f-6b1c5b96f610
|
@dalexsoto review |
There was a problem hiding this comment.
🟡 Changes recommended
Profile lookup can miss repaired files excluded from the index and differently cased filenames on case-insensitive filesystems.
2 open issues
What changed in this PR
This PR makes provisioning-profile selection in Xamarin.MacDev easier to diagnose and prevents an older, expired profile from hiding a newer valid match.
Changes:
- Scan both profile directories for name, UUID, or filename matches, preferring the newest unexpired profile.
- Include full profile paths and selection reasons in diagnostic logs.
- Detect overwrites of indexed profiles and add selection and expired-fallback tests.
| File | Description |
|---|---|
Xamarin.MacDev/MobileProvisionIndex.cs |
Updates profile selection, cache invalidation, and diagnostic logging. |
tests/TestMobileProvisionIndex.cs |
Adds profile fixtures and tests for newest-valid selection and expired fallback. |
Review effort: Balanced
Track profile files that could not be parsed in the provisioning-profile index. If one is repaired in place, its changed modification time now invalidates the index so the profile can be loaded on the next lookup. Also compare profile filenames without regard to case, matching the previous file-system lookup behavior on case-insensitive volumes. Add regression tests for both cases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f60b31f7-1c81-4100-858f-6b1c5b96f610
dalexsoto
left a comment
There was a problem hiding this comment.
Reviewed 30d09f1f against main at 8ed5915d (that's also the merge base). This was a static, read-only review of both changed files, the other code that calls them, and the dotnet/macios DetectSigningIdentity caller.
The new selection logic does what the description says. Profiles match by name, UUID or file name. Expired profiles are skipped unless every match has expired, and then the newest one by CreationDate is used, the same as the old index lookup. Both earlier review comments are fixed and have regression tests:
- A profile that failed to parse is now tracked in
UnindexedProfileFilesand gets re-read after it's repaired in place. - File-name and extension matching are now case-insensitive.
Changing IndexVersion to 2 makes both old and new code rebuild an index written by the other version. A corrupted or truncated index falls through to OpenIndex's catch, which rebuilds it. The changes in the GetMobileProvisions overloads only affect log text, and all the new messages are logged at normal importance. The public GetMobileProvision signature is unchanged.
Not blocking: the GetMobileProvisions overloads still compare the file extension case-sensitively, so a profile with an upper-case extension is skipped there. It was skipped before this PR too, so you could handle it in a follow-up if you want everything to be consistent.
Update Xamarin.MacDev to include the fix from dotnet/macios-devtools#203. The parser now reads complete `<true></true>` and `<false></false>` elements, keeping all following entries when converting plist resources to binary. The dependency update also includes: * dotnet/macios-devtools#198: add plist-loading overloads that return errors. * dotnet/macios-devtools#200: use LF line endings in XML plist headers. * dotnet/macios-devtools#201: update CI. * dotnet/macios-devtools#202: check all profiles in both provisioning-profile folders when selecting one. Add a regression test that converts plists with both boolean values to binary and checks that no entries are lost. Fixes #27414 🤖 Pull request created by Copilot --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Rolf Bjarne Kvinge <rokvin@microsoft.com>

GetMobileProvision used to load the first file named
'.mobileprovision' it found, without looking at any other
profiles. A hand-copied profile in the old
~/Library/MobileDevice/Provisioning Profiles directory would then hide
a newer profile with the same name in Xcode's current
~/Library/Developer/Xcode/UserData/Provisioning Profiles directory, even
if the hand-copied one had expired. Nothing in the build log showed
that this happened.
Now all profiles in both directories are checked:
expired (then the newest one is used, like before).
or wasn't used.
Also add the full path to the messages from GetMobileProvisions, and
rebuild the profile index when a profile file is overwritten (this
doesn't change the modification date of the directory).
🤖 Pull request created by Copilot