Skip to content

Commit

Permalink
[release/7.0.2xx] Fix WatchKit stub copy error when using native watc…
Browse files Browse the repository at this point in the history
…hOS app (#17626)

Modified the FindWatchOS2AppBundleTaskBase and Xamarin.iOS.Common.targets so that it only tries to copy the WatchKit stub into the IPA file if the watch app bundle includes the folder.

This should fix the error that was found in #10070 by @ivanicin 


Backport of #17004

Co-authored-by: Jack Butler <[email protected]>
Co-authored-by: Jack Aardal <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
  • Loading branch information
4 people committed Mar 3, 2023
1 parent aee429e commit 189a1b8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions msbuild/Xamarin.iOS.Tasks/Tasks/ValidateAppBundleTaskBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ void ValidateWatchApp (string path, string mainBundleIdentifier, string mainShor
{
var name = Path.GetFileNameWithoutExtension (path);
var info = Path.Combine (path, "Info.plist");
var isSingleProject = false;
if (!File.Exists (info)) {
Log.LogError (7014, path, MSBStrings.E7014, name);
return;
Expand Down Expand Up @@ -162,26 +163,32 @@ void ValidateWatchApp (string path, string mainBundleIdentifier, string mainShor
Log.LogError (7019, info, MSBStrings.E7019, name, wkCompanionAppBundleIdentifier, mainBundleIdentifier);

PBoolean watchKitApp;
if (!plist.TryGetValue ("WKWatchKitApp", out watchKitApp) || !watchKitApp.Value)
Log.LogError (7020, info, MSBStrings.E7020, name);
if (plist.TryGetValue ("WKWatchKitApp", out watchKitApp)) {
if (!watchKitApp.Value)
Log.LogError (7020, info, MSBStrings.E7020, name);
} else {
isSingleProject = true;
}

if (plist.ContainsKey ("LSRequiresIPhoneOS"))
Log.LogError (7021, info, MSBStrings.E7021, name);

var pluginsDir = Path.Combine (path, "PlugIns");
if (!Directory.Exists (pluginsDir)) {
if (!Directory.Exists (pluginsDir) && !isSingleProject) {
Log.LogError (7022, path, MSBStrings.E7022, name);
return;
}

int count = 0;
foreach (var plugin in Directory.EnumerateDirectories (pluginsDir, "*.appex")) {
ValidateWatchExtension (plugin, bundleIdentifier, shortVersionString, version);
count++;
}
if (!isSingleProject) {
int count = 0;
foreach (var plugin in Directory.EnumerateDirectories (pluginsDir, "*.appex")) {
ValidateWatchExtension (plugin, bundleIdentifier, shortVersionString, version);
count++;
}

if (count == 0)
Log.LogError (7022, pluginsDir, MSBStrings.E7022_A, name);
if (count == 0)
Log.LogError (7022, pluginsDir, MSBStrings.E7022_A, name);
}
}

void ValidateWatchExtension (string path, string watchAppBundleIdentifier, string mainShortVersionString, string mainVersion)
Expand Down
2 changes: 1 addition & 1 deletion msbuild/Xamarin.iOS.Tasks/Xamarin.iOS.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.

<Copy
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true' And '$(_WatchOS2AppBundle)' != ''"
Condition="'$(IsMacEnabled)' == 'true' And '$(_WatchOS2AppBundle)' != '' And Exists('$(_WatchOS2AppBundle)\_WatchKitStub\WK')"
SourceFiles="$(_WatchOS2AppBundle)\_WatchKitStub\WK"
DestinationFolder="$(DeviceSpecificIntermediateOutputPath)ipa\WatchKitSupport2"
/>
Expand Down

4 comments on commit 189a1b8

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS M1 - Mac Big Sur (11.5) passed 💻

All tests on macOS M1 - Mac Big Sur (11.5) passed.

Pipeline on Agent
Hash: 189a1b82f1e38bf860205d76573cfb4fe54fa8ba [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ API diff for current PR / commit

NET (empty diffs)
  • iOS: (empty diff detected)
  • tvOS: (empty diff detected)
  • MacCatalyst: (empty diff detected)
  • macOS: (empty diff detected)

✅ API diff vs stable

.NET (No breaking changes)
  • iOS: vsdrops gist (No breaking changes)
  • tvOS: (empty diff detected)
  • MacCatalyst: vsdrops gist (No breaking changes)
  • macOS: vsdrops gist (No breaking changes)
  • Microsoft.iOS vs Microsoft.MacCatalyst: vsdrops (could not create gist: file 'D:\a\1\s\change-detection\results\stable-api-comparison\diff\dotnet\iOS-MacCatalyst-diff\Microsoft.iOS.Ref\ref\net7.0\Microsoft.iOS.MacCatalyst.md' does not exist)

✅ Generator diff

Generator diff is empty

Pipeline on Agent
Hash: 189a1b82f1e38bf860205d76573cfb4fe54fa8ba [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📚 [CI Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMMINI-066.Monterey'
Hash: 189a1b82f1e38bf860205d76573cfb4fe54fa8ba [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 [CI Build] Test results 🔥

Test results

❌ Tests failed on VSTS: simulator tests

0 tests crashed, 1 tests failed, 76 tests passed.

Failures

❌ monotouch tests

1 tests failed, 10 tests passed.
  • monotouch-test/iOS Unified 64-bits - simulator/Debug (LinkSdk) [dotnet]: Failed

Html Report (VSDrops) Download

Successes

⚠️ bcl: No tests selected. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests: All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ framework: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 1 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 4 tests passed. Html Report (VSDrops) Download
⚠️ install_source: No tests selected. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 40 tests passed. Html Report (VSDrops) Download
⚠️ mac_binding_project: No tests selected. Html Report (VSDrops) Download
⚠️ mmp: No tests selected. Html Report (VSDrops) Download
⚠️ mononative: No tests selected. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
⚠️ mtouch: No tests selected. Html Report (VSDrops) Download
⚠️ xammac: No tests selected. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: [CI build]

Please sign in to comment.