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)) 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: