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

[iOS] Fix dotnet export. #84945

Merged
merged 1 commit into from
Nov 16, 2023
Merged

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Nov 15, 2023

Fixes #83628

  • Fixes xcframework build.
  • Fixes location of AOT files in the Xcode project.
  • Fixes embedding settings for frameworks.
  • Fixes exporting .xarchive and .ipa (with "Export Project Only" unchecked).

@bruvzg bruvzg added this to the 4.2 milestone Nov 15, 2023
@bruvzg bruvzg force-pushed the ios_dotnet_export_fix branch from baaa08f to b99b5c4 Compare November 15, 2023 21:39
@bruvzg bruvzg marked this pull request as ready for review November 15, 2023 21:40
@bruvzg bruvzg requested review from a team as code owners November 15, 2023 21:40
Copy link
Member

@raulsntos raulsntos left a comment

Choose a reason for hiding this comment

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

I can't test this since I don't have a macOS device, but the code looks good to me. Maybe @shana can also review this.

@@ -195,7 +195,7 @@ public static void CompileAssembliesForiOS(ExportPlugin exporter, bool isDebug,
bool isSim = arch == "i386" || arch == "x86_64"; // Shouldn't really happen as we don't do AOT for the simulator
string versionMinName = isSim ? "iphonesimulator" : "iphoneos";
string iOSPlatformName = isSim ? "iPhoneSimulator" : "iPhoneOS";
const string versionMin = "10.0"; // TODO: Turn this hard-coded version into an exporter setting
const string versionMin = "12.0"; // TODO: Turn this hard-coded version into an exporter setting
Copy link
Member

Choose a reason for hiding this comment

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

We're not using the AotBuilder class, it's a remnant from Godot 3.

Copy link
Member

Choose a reason for hiding this comment

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

We should probably remove unused classes (not in this PR), they can always be brought back from the Git history if needed in the future.

@@ -194,7 +194,7 @@ private void _ExportBeginImpl(string[] features, bool isDebug, string path, long
BundleOutputs = false,
IncludeDebugSymbols = publishConfig.IncludeDebugSymbols,
RidOS = OS.DotNetOS.iOSSimulator,
UseTempDir = true,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm testing this right now, and the problem is not the temp dir output, the problem is that the xcframework command should not be including the library argument that's pointing to the temp dir. The simulator dylib should be already lipo'd into the non-simulator dylib, so there should be no references to the simulator dylib anymore. This might look like it fixes things, but it's not the correct fix here.

Copy link
Member Author

@bruvzg bruvzg Nov 16, 2023

Choose a reason for hiding this comment

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

The simulator dylib should be already lipo'd into the non-simulator dylib

This is impossible, simulator lib can't be lipoed with non simulator lib since both contain arm64 code, that's the only season xcframeworks exist in a first place (merging libs for the different platform but the same architecture).

Copy link
Contributor

@shana shana Nov 16, 2023

Choose a reason for hiding this comment

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

Sorry, I mispoke, the x64 and arm64 simulator dylibs are lipo'd together, and the lipo result is what we want, not the separate dylibs. This is not where the fix should be, the fix is where the lipo happens for iOS, where the output paths are adjusted for creating the framework.

This is the correct fix for the problem where the xcframework fails to be created properly: https://github.com/godotengine/godot/compare/master...shana:godot:fix-ios-dotnet-export?diff=unified

Could you add a comment on this line that this is a temporary fix with a link to this PR, so we don't forget to fix it up properly?

@akien-mga
Copy link
Member

I made a test build from this PR to help testing, especially if we can find someone who still has Xcode < 15 to verify that makes things work for Xcode 15 didn't break assumptions for older versions:

https://downloads.tuxfamily.org/godotengine/testing/4.2-beta6-pr84945/

It's a build from latest master + this PR, it poses at 4.2-beta6 so that it reuses the nuget packages for it, those should be compatible I think.

@bruvzg
Copy link
Member Author

bruvzg commented Nov 16, 2023

I think I have also found the reason for another issue (#82729 (review)) which is preventing full archive/IPA export from the editor, and only allowing exporting Xcode project. The AOT xcframework have the same name as the main Godot library ({project_name}.xcframework) and it's causing some sort of conflict. Renaming it should fix it (and renaming just the lib will not affect .dylib name, so there's no need to change library loading code).

@bruvzg bruvzg force-pushed the ios_dotnet_export_fix branch from b99b5c4 to a92511f Compare November 16, 2023 13:06
@@ -361,7 +361,7 @@ private void _ExportBeginImpl(string[] features, bool isDebug, string path, long
}

var xcFrameworkPath = Path.Combine(GodotSharpDirs.ProjectBaseOutputPath, publishConfig.BuildConfig,
$"{GodotSharpDirs.ProjectAssemblyName}.xcframework");
$"{GodotSharpDirs.ProjectAssemblyName}_aot.xcframework");
Copy link
Member Author

Choose a reason for hiding this comment

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

For the reference, this is the only changed line in the last push. Added to fix name conflict (#82729 (review)) and should not have any effect on the rest of code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I just ran into the same export problem with the naming conflict, it's an Xcode 15 thing, apparently. This fixes it 👍

@shana
Copy link
Contributor

shana commented Nov 16, 2023

@bruvzg @akien-mga @raulsntos I pushed a more long term fix for the temp paths breaking the xcframework generation (https://github.com/godotengine/godot/compare/master...shana:godot:fix-ios-dotnet-export?diff=unified), but not using temp dirs for any of the iOS exports is a safe fix right now, even if it does generate more garbage, so 👍 for my side.

@bruvzg
Copy link
Member Author

bruvzg commented Nov 16, 2023

I pushed a more long term fix for the temp paths breaking the xcframework generation (https://github.com/godotengine/godot/compare/master...shana:godot:fix-ios-dotnet-export?diff=unified), but not using temp dirs for any of the iOS exports is a safe fix right now, even if it does generate more garbage, so 👍 for my side.

I can confirm this also works fine (in place of UseTempDir change, the rest of the changes are still relevant).

@akien-mga akien-mga merged commit 7e679ea into godotengine:master Nov 16, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks everyone for the quick turnaround!

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.2 Beta 1 iOS Export fails if there are any C# scripts in the project
4 participants