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

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

Open
Alphnite opened this issue Jul 12, 2022 · 15 comments

Comments

@Alphnite
Copy link

Godot version

v3.4.4.stable.official [419e713]

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

@bruvzg
Copy link
Member

bruvzg commented Jul 12, 2022

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

@Alphnite
Copy link
Author

Well, Im trying to compile the export templates and it gives me this error in the terminal when I use the scons platform=iphone tools=no target=debug arch=arm64 ios_simulator=yes:

Detected iOS SDK version older than 13
The following platforms are available:

	osx
	server

Please run SCons again and select a valid platform: platform=<string>

It looks like Im need to update the iOS SDK, but I dont now how (yes, Im new with publishing in App Store and also new with using a Mac)

Also, anybody has published an unoficial export templates with the arm64 binaries? I looked to this site where it has some updated export templates, but it doesn't work giving me the same error

@Calinou
Copy link
Member

Calinou commented Jul 14, 2022

It looks like Im need to update the iOS SDK, but I dont now how (yes, Im new with publishing in App Store and also new with using a Mac)

What macOS version is your Mac running (and what Mac model are you using)? Unfortunately, if your Mac is very old, it may not be able to have a recent enough Xcode version installed (with iOS SDK 13.0 or later).

@Alphnite
Copy link
Author

Alphnite commented Jul 14, 2022

What macOS version is your Mac running (and what Mac model are you using)? Unfortunately, if your Mac is very old, it may not be able to have a recent enough Xcode version installed (with iOS SDK 13.0 or later).

Its a MacBook Air M1 2020 and the MacOS ver. is MacOS Monterey 12.4

I don't think that the problem is the Mac, it's too new, maybe the iOS SDK needs to be updated separately?

Edit: I run the game in the "This Mac" simulator, it worked, now I don't know if its needed to run an iPhone simulation in Xcode before release or if I can send to revision the game even without test it in the simulator, and I don't know if something like that can be a problem (because the missing arm64 binaries)

@jasonallen
Copy link

I'm also encountering this problem on Godot 4alpha12. I followed the steps above and copied godot/bin/libgodot.ios.debug.arm64.simulator.a to the debug xcode folder - but I still get the same error.

@jferdelyi
Copy link

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

@aleksfadini
Copy link

Thank you for offering a workaround. Where do you find the arch list only for simulator?

@zarmath
Copy link

zarmath commented Nov 1, 2022

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

@Naionel
Copy link

Naionel commented Feb 2, 2023

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

May I ask what do you mean by "project column"? Where do I find this excluded architectures section?

@Riordan-DC
Copy link

Screen Shot 2023-03-14 at 11 07 52 am

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

May I ask what do you mean by "project column"? Where do I find this excluded architectures section?

@Naionel

@Naionel
Copy link

Naionel commented Mar 14, 2023

Screen Shot 2023-03-14 at 11 07 52 am

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

May I ask what do you mean by "project column"? Where do I find this excluded architectures section?

@Naionel

This is what I have tried, but it still doesn't work for me.

@Riordan-DC
Copy link

@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:

#62929 (comment)

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

How iOS templates are zipped:

#23956 (comment)

#23956 (comment)

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.

@hamzakashifCL
Copy link

hamzakashifCL commented Jul 27, 2023

Getting same error in my react native project, this error came when I renamed my project from xyz.xcodeworkspace to abc.xcodeworkspace
https://stackoverflow.com/questions/76779024/entry-point-main-undefined-for-architecture-arm64-on-xcode-14

@feelingsonice
Copy link

feelingsonice commented Dec 19, 2023

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 #70662 and @Calinou. I apologize for the buzz in advance.

@CNDW
Copy link

CNDW commented Mar 30, 2024

I'm getting the same error with the same setup:

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

I was able to work around the "No support for image cube arrays." by ensuring that the renderer for mobile is set to gl_compatibility

image

I would note that I was only seeing that failure when running in the emulator, when installing to a device the mobile renderer worked fine. I believe the mobile renderer will have issues with older devices as this failure is coming from missing features that prohibit the Vulkan renderer from starting.

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

No branches or pull requests