godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
84.59k stars 18.56k forks source link

Exporting an iOS plugin with debug configuration causes symbol not found compile error #91583

Closed webair closed 1 week ago

webair commented 1 week ago

Tested versions

v4.2.1.stable.official [b09f793f5]

System information

Godot v4.2.1.stable - macOS 14.4.0 - Vulkan (Mobile) - integrated Apple M2 - Apple M2 (8 Threads)

Issue description

I'm creating an iOS plugin for Godot based on the project godot-ios-inapp-review-plugin as template. I managed to build the plugin successfully using the 'release' configuration. But unfortunately i am not able to compile the resulting xcode project when exporting with 'debug' configuration. i receive following error:

Undefined symbol: ClassDB::bind_methodfi(unsigned int, MethodBind*, bool, char const*, Variant const**, int)
Linker command failed with exit code 1 (use -v to see invocation)

I tried to resolve the issue but i am a little lost. Has anyone a hint for me?

Steps to reproduce

Minimal reproduction project (MRP)

N/A

TheOathMan commented 1 week ago

Same issue.

Official ios Plugins was tested with Godot v4.2.2.stable.official, and asset store ones (share plugin)

System: MacBook Air (13-inch, 2017) Mac version 12.6.2 Xcode version: Version 14.2

The build failed while building archive in Godot. In Xcode, failed during build (when 'Export Project only' is Enabled from Godot export settings).

The following build commands failed: Ld /Users/main/Library/Developer/Xcode/DerivedData/testingg-gvofzswuhtpjdaeytstoiuocytua/Build/Intermediates.noindex/ArchiveIntermediates/testingg/InstallationBuildProductsLocation/Applications/testingg.app/testingg normal (in target 'testingg' from project 'testingg') (1 failure)

This is while building on Godot. But Xcode gave extra details:

clang: error: no such file or directory: '/Users/main/Desktop/Godot_Builds/forXcode/testingg/ios/plugins/SharePlugin.release.a'

webair commented 1 week ago

@TheOathMan I think the share plugin has an other issue. According to the error message it seems like that the static library for SharePlugin.release.a is missing.

Since I am currently focusing on the iOS plugin build process, I may be able to help resolving the issue here.

TheOathMan commented 1 week ago

@TheOathMan I think the share plugin has an other issue. According to the error message it seems like that the static library for SharePlugin.release.a is missing.

Since I am currently focusing on the iOS plugin build process, I may be able to help resolving the issue here.

The issue you have and the issue I have are exactly the same but the error messages isn't clear. When we try to build an ios plugin, we usually include Godot headers. These headers include c++ debug or deprecated declarations that are not implemented in the final build. Specifically from object.h (maybe from other headers as well). So when we include the plugin, and we start the export, the linker starts to look for the implementation for these included declarations but doesn't find them.

Right now, I was able to solve your issues by declaring these macros right before I include object.h:

#define DISABLE_DEPRECATED
#define DEBUG_METHODS_ENABLED

#include "core/object/object.h"

Which will exclude deprecated and include debug declarations. That will solve

Undefined symbol: ClassDB::bind_methodfi(unsigned int, MethodBind*, bool, char const*, Variant const**, int) Which is a debug method declaration

webair commented 1 week ago

@TheOathMan Thanks for clarification! This actually led me to the solution. ;) I simply needed to add the variable GCC_PREPROCESSOR_DEFINITIONS="DEBUG_ENABLED=1" in the xcodebuild commands for the debug builds. So my xcodebuild for debug framework looks like this now:

    xcodebuild clean archive \
        -project "${xcodeproj_dir}" \
        -scheme "${plugin_name}" \
        -archivePath "${out_lib_dir}/ios_debug.xcarchive" \
        -sdk iphoneos \
        SKIP_INSTALL=NO \
        GCC_PREPROCESSOR_DEFINITIONS="DEBUG_ENABLED=1"

Thanks again and hope this helps to resovle your issue.