[mtouch] Fix building watch extensions with the watchOS 6.0 SDK.
The watchOS 6.0 SDK renames/moves a few symbols, so some magic is required to make things work on both watchOS 6.0 and earlier versions.
This commit is contained in:
Родитель
00ba38035f
Коммит
9b32d682b6
|
@ -17,6 +17,7 @@ namespace Xamarin.Utils
|
|||
public HashSet<string> LinkWithLibraries; // X, added to Inputs
|
||||
public HashSet<string> ForceLoadLibraries; // -force_load X, added to Inputs
|
||||
public HashSet<string> OtherFlags; // X
|
||||
public List<string> InitialOtherFlags; // same as OtherFlags, only that they're the first argument(s) to clang (because order matters!). This is a list to preserve order (fifo).
|
||||
public HashSet<string> Defines; // -DX
|
||||
public HashSet<string> UnresolvedSymbols; // -u X
|
||||
public HashSet<string> SourceFiles; // X, added to Inputs
|
||||
|
@ -99,6 +100,13 @@ namespace Xamarin.Utils
|
|||
AddOtherFlag ("-stdlib=libc++");
|
||||
}
|
||||
|
||||
public void AddOtherInitialFlag (string flag)
|
||||
{
|
||||
if (InitialOtherFlags == null)
|
||||
InitialOtherFlags = new List<string> ();
|
||||
InitialOtherFlags.Add (flag);
|
||||
}
|
||||
|
||||
public void AddOtherFlag (string flag)
|
||||
{
|
||||
if (OtherFlags == null)
|
||||
|
@ -221,6 +229,16 @@ namespace Xamarin.Utils
|
|||
{
|
||||
Prepare ();
|
||||
|
||||
if (InitialOtherFlags != null) {
|
||||
var idx = 0;
|
||||
foreach (var flag in InitialOtherFlags) {
|
||||
args.Insert (idx, flag);
|
||||
idx += flag.Length;
|
||||
args.Insert (idx, " ");
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
ProcessFrameworksForArguments (args);
|
||||
|
||||
if (LinkWithLibraries != null) {
|
||||
|
|
|
@ -1551,6 +1551,12 @@ namespace Xamarin.Bundler
|
|||
if (App.IsWatchExtension) {
|
||||
mainlib = "libwatchextension.a";
|
||||
linker_flags.AddOtherFlag (" -e _xamarin_watchextension_main");
|
||||
if (App.SdkVersion.Major >= 6) {
|
||||
// watchOS 6.0's WatchKit contains a WKExtensionMain function, and that's the entry point for Xcode-compiled watch extensions.
|
||||
// To make watch extensions work on earlier watchOS versions, there's a libWKExtensionMainLegacy.a library with a
|
||||
// a WKExtensionMain function that does what's needed (Xcode links with this library when deployment target < 6.0).
|
||||
linker_flags.AddOtherInitialFlag ("-lWKExtensionMainLegacy");
|
||||
}
|
||||
} else if (App.IsTVExtension) {
|
||||
mainlib = "libtvextension.a";
|
||||
} else if (App.IsExtension) {
|
||||
|
|
|
@ -672,6 +672,14 @@ namespace Xamarin.Bundler
|
|||
sw.WriteLine ("\txamarin_register_modules = xamarin_register_modules_impl;");
|
||||
sw.WriteLine ("}");
|
||||
|
||||
if (app.Platform == ApplePlatform.WatchOS && app.SdkVersion.Major >= 6) {
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("extern \"C\" { int WKExtensionMain (int argc, char* argv[]); }");
|
||||
sw.WriteLine ("int main (int argc, char *argv[])");
|
||||
sw.WriteLine ("{");
|
||||
sw.WriteLine ("\treturn WKExtensionMain (argc, argv);");
|
||||
sw.WriteLine ("}");
|
||||
}
|
||||
}
|
||||
WriteIfDifferent (main_source, sb.ToString (), true);
|
||||
} catch (MonoTouchException) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче