Skip to content

Commit

Permalink
[Watch] Fix native watchOS app bundling when using newer Xcode 14 wat…
Browse files Browse the repository at this point in the history
…chOS project. Fixes #16142. (#16690)

I've made some small edits to the ValidateWatchApp method to allow for a
native watchOS app that was created in Xcode 14 that uses a single
project instead of an extension to be bundled into a Xamarin app.

Should fix #16142 and progress on #10070

Co-authored-by: Jack Butler <jbutler@glneurotech.com>
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
  • Loading branch information
5 people authored Nov 16, 2022
1 parent ac7a2eb commit 1fb296e
Showing 1 changed file with 17 additions and 10 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

5 comments on commit 1fb296e

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 [CI Build] Build failed 🔥

Build failed for the job 'Detect API changes'

Pipeline on Agent
Hash: [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Unable to find the contents for the comment: D:\a\1\s\change-detection\results\gh-comment.md does not exist :fire

Pipeline on Agent
Hash: 1fb296ee7b4cb97b15f92cd3bc8e672323a6214e [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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) failed ❌

Failed tests are:

  • monotouch-test

Pipeline on Agent
Hash: 1fb296ee7b4cb97b15f92cd3bc8e672323a6214e [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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-054.Monterey'
Hash: 1fb296ee7b4cb97b15f92cd3bc8e672323a6214e [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

✅ All tests passed on VSTS: simulator tests.

🎉 All 223 tests passed 🎉

Tests counts

✅ bcl: All 69 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests: All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 7 tests passed. Html Report (VSDrops) Download
✅ framework: All 8 tests passed. Html Report (VSDrops) Download
✅ generator: All 2 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 7 tests passed. Html Report (VSDrops) Download
✅ install_source: All 1 tests passed. Html Report (VSDrops) Download
✅ introspection: All 8 tests passed. Html Report (VSDrops) Download
✅ linker: All 65 tests passed. Html Report (VSDrops) Download
✅ mac_binding_project: All 1 tests passed. Html Report (VSDrops) Download
✅ mmp: All 2 tests passed. Html Report (VSDrops) Download
✅ mononative: All 12 tests passed. Html Report (VSDrops) Download
✅ monotouch: All 23 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ mtouch: All 1 tests passed. Html Report (VSDrops) Download
✅ xammac: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 8 tests passed. Html Report (VSDrops) Download
✅ xtro: All 2 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: [CI build]

Please sign in to comment.