[msbuild] Fix SceneKit asset compilation. Fixes #3766. (#4851) (#4948)

* [msbuild] Fix SceneKit asset compilation. Fixes #3766.

It seems SceneKit assets must be compiled into a directory whose parent
directory is named like the app.

In addition the `--resource-folder-path` argument is required.

Fixes https://github.com/xamarin/xamarin-macios/issues/3766.

* [msbuild] Use AppBundlePath to get correct .app[ex] variant.

* [msbuild] Fix XM builds.

* [msbuild] Use AppBundleDir instead of AppBundlePath.
This commit is contained in:
Rolf Bjarne Kvinge 2018-10-09 15:26:39 +02:00 коммит произвёл Sebastien Pouliot
Родитель 8d0de1b595
Коммит bc07227ffa
11 изменённых файлов: 228 добавлений и 3 удалений

Просмотреть файл

@ -634,10 +634,11 @@ Copyright (C) 2014 Xamarin. All rights reserved.
<Target Name="_CompileSceneKitAssets" DependsOnTargets="_DetectAppManifest;_DetectSdkLocations;_CoreCompileSceneKitAssets" />
<Target Name="_CoreCompileSceneKitAssets">
<Target Name="_CoreCompileSceneKitAssets" DependsOnTargets="_GenerateBundleName">
<CompileSceneKitAssets
Condition="'$(IsMacEnabled)' == 'true'"
SessionId="$(BuildSessionId)"
AppBundleDir="$(AppBundleDir)"
ToolExe="$(CopySceneKitAssetsExe)"
ToolPath="$(CopySceneKitAssetsPath)"
SceneKitAssets="@(SceneKitAsset)"

Просмотреть файл

@ -18,6 +18,9 @@ namespace Xamarin.MacDev.Tasks
public string SessionId { get; set; }
[Required]
public string AppBundleDir { get; set; }
[Required]
public string IntermediateOutputPath { get; set; }
@ -60,6 +63,10 @@ namespace Xamarin.MacDev.Tasks
#endregion
string AppBundleName {
get { return Path.GetFileName (AppBundleDir); }
}
static string ToolName {
get { return "copySceneKitAssets"; }
}
@ -122,6 +129,7 @@ namespace Xamarin.MacDev.Tasks
args.AddQuotedFormat ("--target-version-{0}={1}", OperatingSystem, SdkVersion);
}
args.AddQuotedFormat ("--target-build-dir={0}", Path.GetFullPath (intermediate));
args.AddQuotedFormat ("--resources-folder-path={0}", AppBundleName);
var startInfo = GetProcessStartInfo (environment, GetFullPathToTool (), args.ToString ());
@ -154,7 +162,7 @@ namespace Xamarin.MacDev.Tasks
public override bool Execute ()
{
var prefixes = BundleResource.SplitResourcePrefixes (ResourcePrefix);
var intermediate = Path.Combine (IntermediateOutputPath, ToolName);
var intermediate = Path.Combine (IntermediateOutputPath, ToolName, AppBundleName);
var bundleResources = new List<ITaskItem> ();
var modified = new HashSet<string> ();
var items = new List<ITaskItem> ();

Просмотреть файл

@ -1276,10 +1276,11 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
<Target Name="_CoreCompileSceneKitAssets"
Inputs="@(SceneKitAsset)"
Outputs="$(_SceneKitCache)"
DependsOnTargets="_BeforeCoreCompileSceneKitAssets">
DependsOnTargets="_BeforeCoreCompileSceneKitAssets;_GenerateBundleName">
<CompileSceneKitAssets
SessionId="$(BuildSessionId)"
AppBundleDir="$(AppBundleDir)"
Condition="'$(IsMacEnabled)' == 'true'"
ToolExe="$(CopySceneKitAssetsExe)"
ToolPath="$(CopySceneKitAssetsPath)"

Просмотреть файл

@ -0,0 +1,30 @@
using Foundation;
using UIKit;
namespace MySceneKitApp {
[Register ("AppDelegate")]
public class AppDelegate : UIApplicationDelegate
{
UIWindow window;
UIViewController dvc;
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
dvc = new UIViewController ();
dvc.View.BackgroundColor = UIColor.Green;
window.RootViewController = dvc;
window.MakeKeyAndVisible ();
return true;
}
static void Main (string [] args)
{
UIApplication.Main (args, null, typeof (AppDelegate));
}
}
}

Просмотреть файл

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>MySceneKitApp</string>
<key>CFBundleIdentifier</key>
<string>com.xamarin.MySceneKitApp.MySceneKitApp</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
<string>11.0</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProjectGuid>{D210EFF2-06EF-4DB0-9F0E-2BFAF873D824}</ProjectGuid>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>MySceneKitApp</RootNamespace>
<AssemblyName>MySceneKitApp</AssemblyName>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>true</MtouchDebug>
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
<MtouchFastDev>true</MtouchFastDev>
<MtouchProfiling>true</MtouchProfiling>
<IOSDebuggerPort>44556</IOSDebuggerPort>
<MtouchLink>None</MtouchLink>
<MtouchArch>x86_64</MtouchArch>
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhone\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchUseLlvm>true</MtouchUseLlvm>
<MtouchFloat32>true</MtouchFloat32>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchArch>ARM64</MtouchArch>
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
<MtouchLink>None</MtouchLink>
<MtouchArch>x86_64</MtouchArch>
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhone\Debug</OutputPath>
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<DeviceSpecificBuild>true</DeviceSpecificBuild>
<MtouchDebug>true</MtouchDebug>
<MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
<MtouchFastDev>true</MtouchFastDev>
<MtouchProfiling>true</MtouchProfiling>
<MtouchFloat32>true</MtouchFloat32>
<IOSDebuggerPort>48889</IOSDebuggerPort>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchArch>ARM64</MtouchArch>
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<SceneKitAsset Include="art.scnassets\texture.png" />
<SceneKitAsset Include="art.scnassets\scene.scn" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppDelegate.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
</Project>

Просмотреть файл

@ -0,0 +1,23 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySceneKitApp", "MySceneKitApp.csproj", "{D210EFF2-06EF-4DB0-9F0E-2BFAF873D824}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhone = Release|iPhone
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D210EFF2-06EF-4DB0-9F0E-2BFAF873D824}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{D210EFF2-06EF-4DB0-9F0E-2BFAF873D824}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{D210EFF2-06EF-4DB0-9F0E-2BFAF873D824}.Release|iPhone.ActiveCfg = Release|iPhone
{D210EFF2-06EF-4DB0-9F0E-2BFAF873D824}.Release|iPhone.Build.0 = Release|iPhone
{D210EFF2-06EF-4DB0-9F0E-2BFAF873D824}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{D210EFF2-06EF-4DB0-9F0E-2BFAF873D824}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
{D210EFF2-06EF-4DB0-9F0E-2BFAF873D824}.Debug|iPhone.ActiveCfg = Debug|iPhone
{D210EFF2-06EF-4DB0-9F0E-2BFAF873D824}.Debug|iPhone.Build.0 = Debug|iPhone
EndGlobalSection
EndGlobal

Двоичные данные
msbuild/tests/MySceneKitApp/art.scnassets/scene.scn Normal file

Двоичный файл не отображается.

Двоичные данные
msbuild/tests/MySceneKitApp/art.scnassets/texture.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 342 KiB

Просмотреть файл

@ -0,0 +1,33 @@
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Diagnostics;
using System.Collections.Generic;
using NUnit.Framework;
using Xamarin.Tests;
namespace Xamarin.iOS.Tasks
{
// [TestFixture ("iPhone")] // Skip this to speed things up a bit.
[TestFixture ("iPhoneSimulator")]
public class CompileSceneKitAssetsTest : ProjectTest
{
public CompileSceneKitAssetsTest (string platform) : base (platform)
{
}
[Test]
public void Compilation ()
{
var csproj = BuildProject ("MySceneKitApp", Platform, "Debug", clean: true);
var appPath = Path.Combine (Path.GetDirectoryName (csproj), "bin", Platform, "Debug", "MySceneKitApp.app");
var scenePath = Path.GetFullPath (Path.Combine (appPath, "art.scnassets", "scene.scn"));
var xml = Configuration.ReadPListAsXml (scenePath);
Assert.That (xml, Is.StringContaining ("<string>art.scnassets/texture.png</string>"), "asset with path");
}
}
}

Просмотреть файл

@ -109,6 +109,7 @@
<Compile Include="ProjectsTests\ProjectWithSpaces.cs" />
<Compile Include="ProjectsTests\ProjectReference.cs" />
<Compile Include="ProjectsTests\ResponseFileArguments.cs" />
<Compile Include="ProjectsTests\CompileSceneKitAssetsTest.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />