From f37e12d97da17c93393fb455f6a635597132dd38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mindaugas=20Vai=C4=8Di=C5=ABnas?= Date: Wed, 2 Sep 2026 15:40:43 +0300 Subject: [PATCH 1/3] Get the Xcode project path through PBXProject.GetPBXProjectPath API --- .../Assets/Apple.Core/Editor/AppleBuild.cs | 12 ++++++++++-- .../Assets/Editor/PHASEBuildStep.cs | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Editor/AppleBuild.cs b/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Editor/AppleBuild.cs index 4b8582e6..0bbe620c 100644 --- a/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Editor/AppleBuild.cs +++ b/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Editor/AppleBuild.cs @@ -321,9 +321,8 @@ public static string GetPbxProjectPath(BuildTarget buildTarget, string pathToBui { case BuildTarget.iOS: case BuildTarget.tvOS: - return $"{pathToBuiltProject}/Unity-iPhone.xcodeproj/project.pbxproj"; case BuildTarget.VisionOS: - return $"{pathToBuiltProject}/Unity-VisionOS.xcodeproj/project.pbxproj"; + return PBXProject.GetPBXProjectPath(pathToBuiltProject); case BuildTarget.StandaloneOSX: #if UNITY_2020_1_OR_NEWER return $"{pathToBuiltProject}/{new DirectoryInfo(pathToBuiltProject).Name}.xcodeproj/project.pbxproj"; @@ -335,6 +334,15 @@ public static string GetPbxProjectPath(BuildTarget buildTarget, string pathToBui } } + /// + /// Utility method for getting the path of the .xcodeproj bundle Unity generated in provided build project path + /// + public static string GetGeneratedXcodeProjectPath(BuildTarget buildTarget, string pathToBuiltProject) + { + var pbxProjectPath = GetPbxProjectPath(buildTarget, pathToBuiltProject); + return pbxProjectPath == null ? null : Path.GetDirectoryName(pbxProjectPath); + } + /// /// Utility method for getting a PBXProject object associated with the provided BuildTarget and built project path /// diff --git a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Editor/PHASEBuildStep.cs b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Editor/PHASEBuildStep.cs index e2f3a2fa..7f859df4 100644 --- a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Editor/PHASEBuildStep.cs +++ b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Editor/PHASEBuildStep.cs @@ -32,7 +32,8 @@ public override void OnBeginPostProcess(AppleBuildProfile appleBuildProfile, Bui project.WriteToFile(projectPath); } - var xcSettingsPath = $"{pathToBuiltProject}/Unity-iPhone.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings"; + var xcodeProjectPath = AppleBuild.GetGeneratedXcodeProjectPath(buildTarget, pathToBuiltProject); + var xcSettingsPath = $"{xcodeProjectPath}/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings"; // Change the xcode project to use the new build system. var xcSettingsDoc = new PlistDocument(); if (File.Exists(xcSettingsPath)) From 57137d148494cce5202da39f83d30773183be3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mindaugas=20Vai=C4=8Di=C5=ABnas?= Date: Wed, 2 Sep 2026 16:55:39 +0300 Subject: [PATCH 2/3] Add adio plugin registration for Swift project type --- .../Plugins/PHASESpatializerAppController.mm | 5 + .../PHASESpatializerAppController.mm.meta | 3 + .../PHASESpatializerSwiftRegistration.mm | 43 +++++++++ .../PHASESpatializerSwiftRegistration.mm.meta | 96 +++++++++++++++++++ 4 files changed, 147 insertions(+) create mode 100644 plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm create mode 100644 plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm.meta diff --git a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm index 220695cf..0eb3f9f1 100644 --- a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm +++ b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm @@ -1,3 +1,8 @@ +// ObjC project type counterpart of PHASESpatializerSwiftRegistration.mm. +// +// This file is masked to "XcodeProjectType: ObjectiveC" in its .meta, so exactly one of the two +// registration files is compiled into any given Xcode project. + #import "UnityAppController.h" extern "C" { diff --git a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm.meta b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm.meta index 6a44bc57..88ff28b8 100644 --- a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm.meta +++ b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm.meta @@ -70,6 +70,7 @@ PluginImporter: CPU: AnyCPU CompileFlags: FrameworkDependencies: + XcodeProjectType: ObjectiveC - first: iPhone: iOS second: @@ -79,6 +80,7 @@ PluginImporter: CPU: AnyCPU CompileFlags: FrameworkDependencies: + XcodeProjectType: ObjectiveC - first: tvOS: tvOS second: @@ -88,6 +90,7 @@ PluginImporter: CPU: AnyCPU CompileFlags: FrameworkDependencies: + XcodeProjectType: ObjectiveC userData: assetBundleName: assetBundleVariant: diff --git a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm new file mode 100644 index 00000000..8b22ef0b --- /dev/null +++ b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm @@ -0,0 +1,43 @@ +// Swift project type counterpart of PHASESpatializerAppController.mm. +// +// This file is masked to "XcodeProjectType: Swift" in its .meta, so exactly one of the two +// registration files is compiled into any given Xcode project. + +#import +#import + +extern "C" { +struct UnityAudioEffectDefinition; +typedef int (*UnityPluginGetAudioEffectDefinitionsFunc)( + struct UnityAudioEffectDefinition*** descptr); +extern void UnityRegisterAudioPlugin( + UnityPluginGetAudioEffectDefinitionsFunc getAudioEffectDefinitions); +extern int UnityGetAudioEffectDefinitions(UnityAudioEffectDefinition*** definitionptr); +} // extern "C" + + +@interface PHASESpatializerRegistration : NSObject +@end + +@implementation PHASESpatializerRegistration + +static id sPHASERuntimeInitObserver = nil; + ++ (void)load +{ + sPHASERuntimeInitObserver = + [[NSNotificationCenter defaultCenter] addObserverForName:UnityNotifications.unityDidInitializeRuntime + object:nil + queue:nil + usingBlock:^(NSNotification* note) { + UnityRegisterAudioPlugin(UnityGetAudioEffectDefinitions); + + if (sPHASERuntimeInitObserver != nil) + { + [[NSNotificationCenter defaultCenter] removeObserver:sPHASERuntimeInitObserver]; + sPHASERuntimeInitObserver = nil; + } + }]; +} + +@end diff --git a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm.meta b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm.meta new file mode 100644 index 00000000..2a187e3a --- /dev/null +++ b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm.meta @@ -0,0 +1,96 @@ +fileFormatVersion: 2 +guid: 0816b5750fcb44e09f1ce64fde1b05da +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux64: 1 + Exclude OSXUniversal: 1 + Exclude VisionOS: 0 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + Exclude tvOS: 0 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + VisionOS: VisionOS + second: + enabled: 1 + settings: + AddToEmbeddedBinaries: false + CPU: AnyCPU + CompileFlags: + FrameworkDependencies: + XcodeProjectType: Swift + - first: + iPhone: iOS + second: + enabled: 1 + settings: + AddToEmbeddedBinaries: false + CPU: AnyCPU + CompileFlags: + FrameworkDependencies: + XcodeProjectType: Swift + - first: + tvOS: tvOS + second: + enabled: 1 + settings: + AddToEmbeddedBinaries: false + CPU: AnyCPU + CompileFlags: + FrameworkDependencies: + XcodeProjectType: Swift + userData: + assetBundleName: + assetBundleVariant: From a648fde26fdafcf8d3a229d86290d48bd838924b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mindaugas=20Vai=C4=8Di=C5=ABnas?= Date: Mon, 7 Sep 2026 17:23:58 +0300 Subject: [PATCH 3/3] Fix to support Unity versions older than 6.5 for Audio plugin registration --- .../Plugins/PHASESpatializerAppController.mm | 44 +++++++-- .../PHASESpatializerAppController.mm.meta | 3 - .../PHASESpatializerSwiftRegistration.mm | 43 --------- .../PHASESpatializerSwiftRegistration.mm.meta | 96 ------------------- 4 files changed, 37 insertions(+), 149 deletions(-) delete mode 100644 plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm delete mode 100644 plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm.meta diff --git a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm index 0eb3f9f1..737b9f56 100644 --- a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm +++ b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm @@ -1,10 +1,3 @@ -// ObjC project type counterpart of PHASESpatializerSwiftRegistration.mm. -// -// This file is masked to "XcodeProjectType: ObjectiveC" in its .meta, so exactly one of the two -// registration files is compiled into any given Xcode project. - -#import "UnityAppController.h" - extern "C" { struct UnityAudioEffectDefinition; typedef int (*UnityPluginGetAudioEffectDefinitionsFunc)( @@ -14,6 +7,41 @@ extern void UnityRegisterAudioPlugin( extern int UnityGetAudioEffectDefinitions(UnityAudioEffectDefinition*** definitionptr); } // extern "C" +#if UNITY_XCODE_PROJECT_TYPE_SWIFT + +#import +#import + +@interface PHASESpatializerRegistration : NSObject +@end + +@implementation PHASESpatializerRegistration + +static id sPHASERuntimeInitObserver = nil; + ++ (void)load +{ + sPHASERuntimeInitObserver = + [[NSNotificationCenter defaultCenter] addObserverForName:UnityNotifications.unityDidInitializeRuntime + object:nil + queue:nil + usingBlock:^(NSNotification* note) { + UnityRegisterAudioPlugin(UnityGetAudioEffectDefinitions); + + if (sPHASERuntimeInitObserver != nil) + { + [[NSNotificationCenter defaultCenter] removeObserver:sPHASERuntimeInitObserver]; + sPHASERuntimeInitObserver = nil; + } + }]; +} + +@end + +#else + +#import "UnityAppController.h" + @interface PHASESpatializerAppController : UnityAppController - (void)shouldAttachRenderDelegate; @end @@ -26,3 +54,5 @@ - (void)shouldAttachRenderDelegate @end IMPL_APP_CONTROLLER_SUBCLASS(PHASESpatializerAppController); + +#endif diff --git a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm.meta b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm.meta index 88ff28b8..6a44bc57 100644 --- a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm.meta +++ b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerAppController.mm.meta @@ -70,7 +70,6 @@ PluginImporter: CPU: AnyCPU CompileFlags: FrameworkDependencies: - XcodeProjectType: ObjectiveC - first: iPhone: iOS second: @@ -80,7 +79,6 @@ PluginImporter: CPU: AnyCPU CompileFlags: FrameworkDependencies: - XcodeProjectType: ObjectiveC - first: tvOS: tvOS second: @@ -90,7 +88,6 @@ PluginImporter: CPU: AnyCPU CompileFlags: FrameworkDependencies: - XcodeProjectType: ObjectiveC userData: assetBundleName: assetBundleVariant: diff --git a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm deleted file mode 100644 index 8b22ef0b..00000000 --- a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm +++ /dev/null @@ -1,43 +0,0 @@ -// Swift project type counterpart of PHASESpatializerAppController.mm. -// -// This file is masked to "XcodeProjectType: Swift" in its .meta, so exactly one of the two -// registration files is compiled into any given Xcode project. - -#import -#import - -extern "C" { -struct UnityAudioEffectDefinition; -typedef int (*UnityPluginGetAudioEffectDefinitionsFunc)( - struct UnityAudioEffectDefinition*** descptr); -extern void UnityRegisterAudioPlugin( - UnityPluginGetAudioEffectDefinitionsFunc getAudioEffectDefinitions); -extern int UnityGetAudioEffectDefinitions(UnityAudioEffectDefinition*** definitionptr); -} // extern "C" - - -@interface PHASESpatializerRegistration : NSObject -@end - -@implementation PHASESpatializerRegistration - -static id sPHASERuntimeInitObserver = nil; - -+ (void)load -{ - sPHASERuntimeInitObserver = - [[NSNotificationCenter defaultCenter] addObserverForName:UnityNotifications.unityDidInitializeRuntime - object:nil - queue:nil - usingBlock:^(NSNotification* note) { - UnityRegisterAudioPlugin(UnityGetAudioEffectDefinitions); - - if (sPHASERuntimeInitObserver != nil) - { - [[NSNotificationCenter defaultCenter] removeObserver:sPHASERuntimeInitObserver]; - sPHASERuntimeInitObserver = nil; - } - }]; -} - -@end diff --git a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm.meta b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm.meta deleted file mode 100644 index 2a187e3a..00000000 --- a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Plugins/PHASESpatializerSwiftRegistration.mm.meta +++ /dev/null @@ -1,96 +0,0 @@ -fileFormatVersion: 2 -guid: 0816b5750fcb44e09f1ce64fde1b05da -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - : Any - second: - enabled: 0 - settings: - Exclude Editor: 1 - Exclude Linux64: 1 - Exclude OSXUniversal: 1 - Exclude VisionOS: 0 - Exclude Win: 1 - Exclude Win64: 1 - Exclude iOS: 0 - Exclude tvOS: 0 - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - CPU: AnyCPU - DefaultValueInitialized: true - OS: AnyOS - - first: - Standalone: Linux64 - second: - enabled: 0 - settings: - CPU: AnyCPU - - first: - Standalone: OSXUniversal - second: - enabled: 0 - settings: - CPU: AnyCPU - - first: - Standalone: Win - second: - enabled: 0 - settings: - CPU: AnyCPU - - first: - Standalone: Win64 - second: - enabled: 0 - settings: - CPU: AnyCPU - - first: - VisionOS: VisionOS - second: - enabled: 1 - settings: - AddToEmbeddedBinaries: false - CPU: AnyCPU - CompileFlags: - FrameworkDependencies: - XcodeProjectType: Swift - - first: - iPhone: iOS - second: - enabled: 1 - settings: - AddToEmbeddedBinaries: false - CPU: AnyCPU - CompileFlags: - FrameworkDependencies: - XcodeProjectType: Swift - - first: - tvOS: tvOS - second: - enabled: 1 - settings: - AddToEmbeddedBinaries: false - CPU: AnyCPU - CompileFlags: - FrameworkDependencies: - XcodeProjectType: Swift - userData: - assetBundleName: - assetBundleVariant: