Skip to content

Navigation Menu

Sign in
Sign up

Add Swift project type support #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mindaugasv-unity wants to merge 3 commits into apple:main
base: main
Choose a base branch
Loading
from mindaugasv-unity:feature/add-swift-project-type-support
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -335,6 +334,15 @@ public static string GetPbxProjectPath(BuildTarget buildTarget, string pathToBui
}
}

/// <summary>
/// Utility method for getting the path of the .xcodeproj bundle Unity generated in provided build project path
/// </summary>
public static string GetGeneratedXcodeProjectPath(BuildTarget buildTarget, string pathToBuiltProject)
{
var pbxProjectPath = GetPbxProjectPath(buildTarget, pathToBuiltProject);
return pbxProjectPath == null ? null : Path.GetDirectoryName(pbxProjectPath);
}

/// <summary>
/// Utility method for getting a PBXProject object associated with the provided BuildTarget and built project path
/// </summary>
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#import "UnityAppController.h"

extern "C" {
struct UnityAudioEffectDefinition;
typedef int (*UnityPluginGetAudioEffectDefinitionsFunc)(
Expand All @@ -9,6 +7,41 @@ extern void UnityRegisterAudioPlugin(
extern int UnityGetAudioEffectDefinitions(UnityAudioEffectDefinition*** definitionptr);
} // extern "C"

#if UNITY_XCODE_PROJECT_TYPE_SWIFT

#import <Foundation/Foundation.h>
#import <UnityAPI/UnityAPI-Swift.h>

@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
Expand All @@ -21,3 +54,5 @@ - (void)shouldAttachRenderDelegate

@end
IMPL_APP_CONTROLLER_SUBCLASS(PHASESpatializerAppController);

#endif

AltStyle によって変換されたページ (->オリジナル) /