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 static library export is broken #90173

Closed
piiertho opened this issue Apr 3, 2024 · 0 comments · Fixed by #90379
Closed

iOS static library export is broken #90173

piiertho opened this issue Apr 3, 2024 · 0 comments · Fixed by #90379

Comments

@piiertho
Copy link
Contributor

piiertho commented Apr 3, 2024

Tested versions

  • Reproducible in 4.2.1-stable

System information

macOS 14.0 (M1)

Issue description

It seems this commit broke export plugins adding static libraries.
I'm working on Godot-Kotlin project, we have an export plugin which adds a static library when exporting for iOS (this static library contains kotlin code), see here.
EditorExportPlatformIOS::_export_additional_assets only keeps filename of static libraries:

		Vector<String> project_static_libs = export_plugins[i]->get_ios_project_static_libs();
		for (int j = 0; j < project_static_libs.size(); j++) {
			project_static_libs.write[j] = project_static_libs[j].get_file(); // Only the file name as it's copied to the project
		}
		err = _export_additional_assets(p_out_dir, project_static_libs, true, false, r_exported_assets);

The problem here is in EditorExportPlatformIOS::_export_additional_assets:

Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir, const Vector<String> &p_assets, bool p_is_framework, bool p_should_embed, Vector<IOSExportAsset> &r_exported_assets) {
	for (int f_idx = 0; f_idx < p_assets.size(); ++f_idx) {
		String asset = p_assets[f_idx];
		if (asset.begins_with("res://")) {
			Error err = _copy_asset(p_out_dir, asset, nullptr, p_is_framework, p_should_embed, r_exported_assets);
			ERR_FAIL_COND_V(err, err);
		} else if (ProjectSettings::get_singleton()->localize_path(asset).begins_with("res://")) {
			Error err = _copy_asset(p_out_dir, ProjectSettings::get_singleton()->localize_path(asset), nullptr, p_is_framework, p_should_embed, r_exported_assets);
			ERR_FAIL_COND_V(err, err);
		} else {
			// either SDK-builtin or already a part of the export template
			IOSExportAsset exported_asset = { asset, p_is_framework, p_should_embed };
			r_exported_assets.push_back(exported_asset);
		}
	}

	return OK;
}

The added else if to check if we're doing work on a project resource, using ProjectSettings::get_singleton()->localize_path(asset).begins_with("res://"), is always true with static libraries, as caller function (EditorExportPlatformIOS::_export_additional_assets) only keeps filename.
This leads to a NOT_FOUND error and static library is not added to xcode project.

Before the mentionned commit we were passing in

IOSExportAsset exported_asset = { asset, p_is_framework, p_should_embed };
r_exported_assets.push_back(exported_asset);

Which added the static library to r_exported_assets vector, which was leading to adding static library into xcode project.

Steps to reproduce

Create an export plugin and export a static library when exporting ios using add_ios_project_static_lib, then export project.
Or try to create an ios export of a godot kotlin project.

Minimal reproduction project (MRP)

None to provide but this one: https://github.com/utopia-rise/godot-kotlin-jvm/tree/master/harness/tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants