Skip to content
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

C#: Use Godot's LipO implementation instead of Xcode's lipo command #93230

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

raulsntos
Copy link
Member

This reduces our reliance on Xcode to export C# projects to iOS, we still need Xcode to create the xcframework though so exporting C# projects still requires doing it from a macOS device.

⚠️ I don't have a macOS or iOS device, so I would appreciate someone testing exporting a C# project to iOS to confirm this work as expected.

@bruvzg
Copy link
Member

bruvzg commented Jun 16, 2024

we still need Xcode to create the xcframework though so exporting C# projects still requires doing it from a macOS device.

Is .NET capable of building individual iOS libs on non macOS platforms? Assembling .xcframework is easy, it's just a directory with specific structure and .plist file (subtype of XML, we have code to parse/generate .plists) with some info (list of files and supported architectures).

@raulsntos
Copy link
Member Author

raulsntos commented Jun 16, 2024

Is .NET capable of building individual iOS libs on non macOS platforms?

No. Building on .NET 9.0 uses xcrun to locate the Apple SDK and pass it to the C++ linker with --sysroot.

@bruvzg
Copy link
Member

bruvzg commented Jun 16, 2024

On macOS, editor is crashing on start (not reproducible on current master):

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentException: Unmanaged callbacks size mismatch. (Parameter 'unmanagedCallbacksSize')
   at GodotTools.Internals.Internal.Initialize(IntPtr unmanagedCallbacks, Int32 unmanagedCallbacksSize) in /Volumes/Backup/Projects/godot/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs:line 93
   at GodotTools.GodotSharpEditor.InternalCreateInstance(IntPtr unmanagedCallbacks, Int32 unmanagedCallbacksSize) in /Volumes/Backup/Projects/godot/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs:line 702
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
   at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at GodotPlugins.Main.LoadToolsAssembly(Char* nAssemblyPath, IntPtr unmanagedCallbacks, Int32 unmanagedCallbacksSize) in /Volumes/Backup/Projects/godot/modules/mono/glue/GodotSharp/GodotPlugins/Main.cs:line 190
ERROR: FATAL: Condition "editor_plugin_obj == nullptr" is true.
   at: _editor_init_callback (modules/mono/csharp_script.cpp:1060)

@bruvzg
Copy link
Member

bruvzg commented Jun 16, 2024

On macOS, editor is crashing on start (not reproducible on current master):

Probably new icall is missing from here (not sure how the list is organized):

static const void *unmanaged_callbacks[]{
(void *)godot_icall_GodotSharpDirs_ResMetadataDir,
(void *)godot_icall_GodotSharpDirs_MonoUserDir,
(void *)godot_icall_GodotSharpDirs_BuildLogsDirs,
(void *)godot_icall_GodotSharpDirs_DataEditorToolsDir,
(void *)godot_icall_GodotSharpDirs_CSharpProjectName,
(void *)godot_icall_EditorProgress_Create,
(void *)godot_icall_EditorProgress_Dispose,
(void *)godot_icall_EditorProgress_Step,
(void *)godot_icall_Internal_FullExportTemplatesDir,
(void *)godot_icall_Internal_IsMacOSAppBundleInstalled,
(void *)godot_icall_Internal_GodotIs32Bits,
(void *)godot_icall_Internal_GodotIsRealTDouble,
(void *)godot_icall_Internal_GodotMainIteration,
(void *)godot_icall_Internal_IsAssembliesReloadingNeeded,
(void *)godot_icall_Internal_ReloadAssemblies,
(void *)godot_icall_Internal_EditorDebuggerNodeReloadScripts,
(void *)godot_icall_Internal_ScriptEditorEdit,
(void *)godot_icall_Internal_EditorNodeShowScriptScreen,
(void *)godot_icall_Internal_EditorRunPlay,
(void *)godot_icall_Internal_EditorRunStop,
(void *)godot_icall_Internal_EditorPlugin_AddControlToEditorRunBar,
(void *)godot_icall_Internal_ScriptEditorDebugger_ReloadScripts,
(void *)godot_icall_Internal_CodeCompletionRequest,
(void *)godot_icall_Globals_EditorScale,
(void *)godot_icall_Globals_GlobalDef,
(void *)godot_icall_Globals_EditorDef,
(void *)godot_icall_Globals_EditorDefShortcut,
(void *)godot_icall_Globals_EditorGetShortcut,
(void *)godot_icall_Globals_EditorShortcutOverride,
(void *)godot_icall_Globals_TTR,
(void *)godot_icall_Utils_OS_GetPlatformName,
(void *)godot_icall_Utils_OS_UnixFileHasExecutableAccess,
};

Copy link
Member

@paulloz paulloz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing based on the code only, I don't have any Apple hardware either.

@raulsntos
Copy link
Member Author

Just a rebase to fix the include #include "platform/macos/export/lipo.h" -> #include "editor/export/lipo.h" (it was moved in #92750).

@akien-mga akien-mga merged commit a9eba87 into godotengine:master Aug 19, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

@raulsntos raulsntos deleted the dotnet/ios branch August 19, 2024 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants