godot: Build in Xcode gives the error: ld: entry point (_main) undefined. for architecture arm64

Godot version

v3.4.4.stable.official [419e713a2]

System information

MacBook Air (M1, 2020), MacOS Monterey 12.4

Issue description

When I Try to build and run the simulation in Xcode it keep me showing this error: ld: entry point (_main) undefined. for architecture arm64

Viewing others Issues and people that happened something similar, I made the conclusion that the problem may be in the Godot Export Templates, but Im not sure if this is the case, also, the Xcode log gives me this warning:

ld: warning: ignoring file /Users/personale/Library/Developer/Xcode/DerivedData/GELATO_ESPRESSO_GAME_1.1.0-gdmnsorzziyfncbhrzowwqvzlbus/Build/Products/Release-iphonesimulator/libgodot.a, building for iOS Simulator-arm64 but attempting to link with file built for iOS Simulator-x86_64

Note that last line: building for iOS Simulator-arm64 but attempting to link with file built for iOS Simulator-x86_64

I supused that the problem is in that file, so it can be a problem with the Godot export?

So, my hypothesis is that Godot is exporting the project with a file configured to x86, but not to armv64, giving this error, the Mac that Im using for build the project has an Apple M1, I think that if I try to build it in a Mac with an Intel processor it may work.

So, somebody can help me with this problem? Is this a problem that can be solved in the Xcode configuration? or is a problem with the Godot Export Templates?

Steps to reproduce

  1. Export you project for iOS with the following configuration: image image

  2. Import the project to Xcode

  3. Build the project

Minimal reproduction project

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 7
  • Comments: 15 (2 by maintainers)

Most upvoted comments

I’m not able to get this working. I followed the instructions provided by @Riordan-DC above where I

  1. Exported my project following the standard iOS export instructions here.
  2. Built the simulator binaries from source using scons p=ios target=template_debug ios_simulator=yes arch=arm64.
  3. Copied the resulting binary libgodot.ios.template_debug.arm64.simulator.a from my godot/bin/ folder to this exported Xcode folder and combined the existing libgodot.a binary with this new libgodot.ios.template_debug.arm64.simulator.a with lipo -create libgodot.a libgodot.ios.template_debug.arm64.simulator.a -output libgodot.a.

After that, the build succeeded and Xcode was able to start the simulator but I got a warning about Vulkan:

Screenshot 2023-12-19 at 1 59 17 PM

Even if this worked, I’m probably doing something stupid here because this means I’d have to manually merge the binaries with lipo -create libgodot.a libgodot.ios.template_debug.arm64.simulator.a -output libgodot.a everytime I export my game? Am I suppose to install this libgodot.ios.template_debug.arm64.simulator.a as a template for Godot to use rather than manually combining it?

Anyways, regarding the error in the screenshot. My setup:

  • M2 MBP
  • Simulator to iPhone 15 (iOS 17.2)
  • Game running in “Mobile” mode

Going to tag a related post https://github.com/godotengine/godot/pull/70662 and @Calinou. I apologize for the buzz in advance.

MacBook Air (M1, 2020) When I Try to build and run the simulation in Xcode it keep me showing this error

Official export template does not include ARM64 simulator binaries (it’s built on Linux using OSXCross, which does not support building for ARM64 simulator). You can build ARM64 simulator yourself (~see https://docs.godotengine.org/en/latest/development/compiling/compiling_for_ios.html~) or run device binary directly on M1 mac (select “This Mac” or something like this as a target in Xcode).

Edit: Docs seems to be outdated, correct build flags for ARM64 simulator binary are:

scons platform=iphone tools=no arget=debug arch=arm64 ios_simulator=yes
scons platform=iphone tools=no arget=release arch=arm64 ios_simulator=yes

@Naionel Ive been documenting my build for iOS with Godot 3.5.1. This is what I wrote:

Step 3. Build for Arm64 on MacOS. Godot’s export templates for iOS are built using Linux OSXCross which does NOT support ARM64. Therefore for Arm64 targets you must build the export templates for Godot on a Arm64 Mac. This can be done with the following command inside the Godot repository.

scons platform=iphone tools=no arget=debug arch=arm64 ios_simulator=yes

scons platform=iphone tools=no arget=release arch=arm64 ios_simulator=yes

Fix: If you get an error saying that xcrun cannot find the SDK you need to open Xcode -> Preferences -> Locations -> Command Line Tools -> Then select your tools. Then try the above commands again.

Step 4: Custom Arm64 binaries are added to the Godot framework binaries (.a files)

These custom export templates are then added to the Xcode Framework exported by Godot in the folder: “xcode_mobileapp1.xcframework” where “xcode_mobileapp1” is the name of the exported project, yours will be your own.

Inside we find two folders:

  • ios-arm64
  • ios-arm64_x86_64-simulator

Inside the “ios-arm64_x86_64-simulator” folder we find a libgodot.a file. We are going to combine that with our binary. I will use a debug binary here for testing but the process is the same for release. I copy the Arm64 binary from Step 3 into the folder and make a copy of libgodot.a as a backup. We run the following command to combine them:

lipo -create libgodot.a libgodot.iphone.debug.arm64.simulator.a -output libgodot.a

Now the Xcode Iphone simulator should work! However: When I simulate an Iphone (Often a model 13), every frame I see an Error: 502 and I see a visual glitch on a textured mesh. The simulator also runs poorly at 7 fps. These issues do no present on a Mac build or if ran on my device: Iphone SE (2nd Generation).

References:

https://github.com/godotengine/godot/issues/62929#issuecomment-1181357333

https://docs.godotengine.org/en/3.5/development/compiling/compiling_for_ios.html

How iOS templates are zipped:

https://github.com/godotengine/godot/issues/23956#issuecomment-540124345

https://github.com/godotengine/godot/issues/23956#issuecomment-541291995

Step 5. Running the simulator. (In Progress) Issue: Running the iPhone simulator (13/SE 3rd Gen) displays artifacts in 3D on the only textured surface and I get an error 502 printed each frame. Performance on the simulator is also poor at about 7 fps on my M1 Macbook Air. If I test on my device, the Iphone SE (2nd Gen) the app looks and runs great and there are no visual artifacts. As per this Godot github issue this might be caused by the simulator emulating OpenGL support in a Metal environment. Only testing on an actual SE (3rd Gen) device will resolve this simulator-device discrepancy. Another issue for poor performance may also be the debug version, a release version may run faster but I dont expect that to address the 502 errors. Another suspect is that my Godot export binaries are built from a development version of Godot 3.6 but the exported Xcode project is from the stable release of 3.5.1. I dont expect this to be a major suspect.

I have also solved the problem by excluding the arm64 architecture. Select your App in project column => Excluded architectures => (Debug and Release) Any iOs Simulator SDK

Hi, I have resolved this problem by adding arm64 to the list of excluded architectures (simulator only) on the XCode Build Settings.