Skip to content

Commit

Permalink
Fix native watchOS app bundling when using newer Xcode 14 single-proj…
Browse files Browse the repository at this point in the history
…ect watchOS app. Should fix xamarin#16142 and progress on xamarin#10070
  • Loading branch information
Jack Butler authored and vs-mobiletools-engineering-service2 committed Feb 27, 2023
1 parent 9c2af79 commit 7f10e0e
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions msbuild/Xamarin.iOS.Tasks/Tasks/ValidateAppBundleTaskBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ void ValidateAppExtension (string path, string mainBundleIdentifier, string main
break;
}
}

void ValidateWatchApp (string path, string mainBundleIdentifier, string mainShortVersionString, string mainVersion)
{
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

0 comments on commit 7f10e0e

Please sign in to comment.