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

Xcode iOS Simulator does not run on M1 Macs #45209

Open
ViktorEvil opened this issue Jan 15, 2021 · 15 comments · Fixed by #45277
Open

Xcode iOS Simulator does not run on M1 Macs #45209

ViktorEvil opened this issue Jan 15, 2021 · 15 comments · Fixed by #45277

Comments

@ViktorEvil
Copy link
Contributor

Godot version:
Godot 3.2.3 stable
Godot 3.2.4 beta 5

OS/device including version:
OS: 11.1 Big Sur
Xcode: 12.3 (12C33)

MacBook Pro 2020 M1

Issue description:
Simulator does not run and displays the error

"Test.a(main.iphone.opt.debug.arm64.o), building for iOS Simulator, but linking in object file built for iOS,"

Steps to reproduce:
try to run any exported Xcode project on an M1 Mac

did manage to get it to run by adding the following into Xcode
Screenshot 2021-01-15 at 13 01 09

but as per #45173
the simulator is still running very slow

@gumaciel
Copy link
Contributor

hey @ViktorEvil , you can solve temporary with this: #44681 (comment)

be sure to remove the Excluded Architectures when you are going to publish your game to App Store

@bruvzg
Copy link
Member

bruvzg commented Jan 15, 2021

you can solve temporary with this: #44681 (comment)

Most likely this won't help, since there's no main library for the arm64 simulator included to run on M1 mac. Right now export templates include only x86-64 simulator and arm64 device libs (as fat static library). And it's not possible to build one without changing Godot build config (currently simulator/device build is selected base on architecture). Also, we'll probably need to ship templates library .xcframework instead of fat .a to include all the libs.

@bruvzg bruvzg self-assigned this Jan 15, 2021
@naithar
Copy link
Contributor

naithar commented Jan 15, 2021

I've tried to create an .xcframework for iOS template. It seems to be working fine, but Godot is constantly logging 'cyclone' is not a recognized processor for this target (ignoring processor).

I've used xcodebuild -create-xcframework -library libgodot.iphone.debug.arm64-device.a -library libgodot.iphone.debug.arm64-simulator.a -output ./godot.xcframework for testing.

Edit:

Also -create-xcframework seems to be working fine with fat simulator and device library, creating a ios-arm64_x86_64-simulator folder inside .xcframework

@mbrlabs
Copy link
Contributor

mbrlabs commented Mar 6, 2021

@akien-mga @bruvzg this issue is still present in 3.2.4rc3

@bruvzg
Copy link
Member

bruvzg commented Mar 6, 2021

this issue is still present in 3.2.4rc3

It is still present, #45480 that fixes it was reverted since osxcross tool chain used for official releases is not capable of building simulator libraries for M1.

@bruvzg bruvzg reopened this Mar 6, 2021
@naithar
Copy link
Contributor

naithar commented Mar 6, 2021

@mbrlabs you should be able to manually change .a files in Xcode project to .xcframework from this page: https://s3.eu-central-1.wasabisys.com/naithar/godot/godot_templates/ios/list.html

@bruvzg I think it might be a good idea to switch to .xcframeworks without arm64 simulator support from .a. At least this way custom templates could support M1 simulator if used.

@BlooRabbit
Copy link

I have a similar problem, building with a MacBook Air (M1), using Godot 3.4.2 and a project under GL2. The project exports via cable to a physical iphone 6 (and works). But the simulators do not work: xCode says 'build failed" and "building for iOS Simulator-arm64 but attempting to link with file built for iOS Simulator-x86_64".

Using the trick of excluding "arm64" from simulators SDKs works (see above), but I cannot archive the project and use it with Testflight.

@bruvzg
Copy link
Member

bruvzg commented Jan 28, 2022

But the simulators do not work: xCode says 'build failed" and "building for iOS Simulator-arm64 but attempting to link with file built for iOS Simulator-x86_64".

Official export templates do not have M1 simulator library, since it's impossible to build it on Linux using OSXCROSS.

You have to build a new simulator library from the source using following commands:
Release version:

scons p=iphone tools=no target=release arch=arm64 ios_simulator=yes
scons p=iphone tools=no target=release arch=x86_64 ios_simulator=yes
lipo -create bin/libgodot.iphone.opt.x86_64.simulator.a bin/libgodot.iphone.opt.arm64.simulator.a -output bin/libgodot.a

Debug version:

scons p=iphone tools=no target=release_debug arch=arm64 ios_simulator=yes
scons p=iphone tools=no target=release_debug arch=x86_64 ios_simulator=yes
lipo -create bin/libgodot.iphone.x86_64.simulator.a bin/libgodot.iphone.arm64.simulator.a -output bin/libgodot.a

And replace {project_name}.xcframework/ios-arm64_x86_64-simulator/libgodot.a in the exported project folder with the new library.

@BlooRabbit
Copy link

BlooRabbit commented Jan 28, 2022

Many thanks, I never compiled a template - I guess it is time to learn. Would be useful if someone who knows how this works could do it and post that template on the official website, so everybody can use it without having to learn compiling :-) If I succeed, I will try to post it somewhere.

Edited : in the situation I described, even without compiling a new template, testflight worked when plugging in an iphone and archiving for that iphone rather than for "all devices" (in my case, using this method with a physical iphone 6, xcode archived the build and testflight worked for all arm64 devices)

@BZ1234567890
Copy link
Contributor

But the simulators do not work: xCode says 'build failed" and "building for iOS Simulator-arm64 but attempting to link with file built for iOS Simulator-x86_64".

Official export templates do not have M1 simulator library, since it's impossible to build it on Linux using OSXCROSS.

You have to build a new simulator library from the source using following commands: Release version:

scons p=iphone tools=no target=release arch=arm64 ios_simulator=yes
scons p=iphone tools=no target=release arch=x86_64 ios_simulator=yes
lipo -create bin/libgodot.iphone.opt.x86_64.simulator.a bin/libgodot.iphone.opt.arm64.simulator.a -output bin/libgodot.a

Debug version:

scons p=iphone tools=no target=release_debug arch=arm64 ios_simulator=yes
scons p=iphone tools=no target=release_debug arch=x86_64 ios_simulator=yes
lipo -create bin/libgodot.iphone.x86_64.simulator.a bin/libgodot.iphone.arm64.simulator.a -output bin/libgodot.a

And replace {project_name}.xcframework/ios-arm64_x86_64-simulator/libgodot.a in the exported project folder with the new library.

Followed these steps but I get EXC_BAD_ACCESS error and crash on the simulator shortly after load. What could be the reason for that?

@MrZak-dev
Copy link

MrZak-dev commented Jul 30, 2022

But the simulators do not work: xCode says 'build failed" and "building for iOS Simulator-arm64 but attempting to link with file built for iOS Simulator-x86_64".

Official export templates do not have M1 simulator library, since it's impossible to build it on Linux using OSXCROSS.
You have to build a new simulator library from the source using following commands: Release version:

scons p=iphone tools=no target=release arch=arm64 ios_simulator=yes
scons p=iphone tools=no target=release arch=x86_64 ios_simulator=yes
lipo -create bin/libgodot.iphone.opt.x86_64.simulator.a bin/libgodot.iphone.opt.arm64.simulator.a -output bin/libgodot.a

Debug version:

scons p=iphone tools=no target=release_debug arch=arm64 ios_simulator=yes
scons p=iphone tools=no target=release_debug arch=x86_64 ios_simulator=yes
lipo -create bin/libgodot.iphone.x86_64.simulator.a bin/libgodot.iphone.arm64.simulator.a -output bin/libgodot.a

And replace {project_name}.xcframework/ios-arm64_x86_64-simulator/libgodot.a in the exported project folder with the new library.

Followed these steps but I get EXC_BAD_ACCESS error and crash on the simulator shortly after load. What could be the reason for that?

I am running into the same issue, i have built Godot library for ios simulator and replaced the libgodot.a with the new generated one .

Xcode now build succeeded for simulator but the game is crashing once it is launched , using a new empty Godot 3.4.4.stable project.

@akien-mga akien-mga modified the milestones: 4.0, 4.x Feb 22, 2023
@itsMuaazAhmed
Copy link

1-Quit XCode
2-Go to Finder > Application > X code App
3-Get info
4- there is check box, "Open using rosetta"

Then Open your xcode, This works like a megic for me

@AlexBowring
Copy link

Is this issue still known to be present @bruvzg? I have compiled the iOS export templates with simulator using the instructions here

Device/Project info:
Godot v4.2.stable - macOS 14.1.2 - integrated Apple M1 - Apple M1 (8 Threads)

When i build my project to my device it works fine, but when I use the simulators on Xcode, the project builds but then crashes on opening, with the errors:

USER ERROR: AudioOutputUnitStart failed, code: -50
   at: start (drivers/coreaudio/audio_driver_coreaudio.cpp:251)
USER ERROR: AudioOutputUnitStart failed, code: -50
   at: start (drivers/coreaudio/audio_driver_coreaudio.cpp:251)
Godot Engine v4.2.stable.custom_build - https://godotengine.org
Godot Engine v4.2.stable.custom_build - https://godotengine.org
Vulkan API 1.2.231 - Forward Mobile - Using Vulkan Device #0: Apple - Apple iOS simulator GPU
Vulkan API 1.2.231 - Forward Mobile - Using Vulkan Device #0: Apple - Apple iOS simulator GPU
USER ERROR: Condition "err != OK" is true. Returning: ERR_CANT_CREATE
   at: _window_create (drivers/vulkan/vulkan_context.cpp:1837)
USER ERROR: Failed to create Vulkan window.
   at: DisplayServerIOS (platform/ios/display_server_ios.mm:88)
USER ERROR: Unable to create DisplayServer, all display drivers failed.
   at: setup2 (main/main.cpp:2395)
*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [UIAlertController shouldAutorotate] is returning YES'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000018048d8a8 __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x000000018008409c objc_exception_throw + 56
	2   CoreFoundation                      0x000000018048d7b8 -[NSException initWithCoder:] + 0
	3   UIKitCore                           0x0000000184bb0a44 -[UIViewController __supportedInterfaceOrientations] + 804
	4   UIKitCore                           0x0000000184bb0e60 -[UIViewController __withSupportedInterfaceOrientation:apply:] + 44
	5   UIKitCore                           0x0000000184bb136c -[UIViewController setInterfaceOrientation:] + 84
	6   UIKitCore                           0x0000000184ba23fc -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 264
	7   UIKitCore                           0x00000001857c6908 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1124
	8   UIKitCore                           0x00000001857bc0d0 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 120
	9   CoreAutoLayout                      0x00000001ca3ad690 -[NSISEngine withBehaviors:performModifications:] + 76
	10  UIKitCore                           0x00000001857bbffc -[UIView _postMovedFromSuperview:] + 448
	11  UIKitCore                           0x00000001857c8c10 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 2192
	12  UIKitCore                           0x00000001847ec86c -[_UIAlertControllerPresentationController presentationTransitionWillBegin] + 144
	13  UIKitCore                           0x0000000184ab95d0 __80-[UIPresentationController _initViewHierarchyForPresentationSuperview:inWindow:]_block_invoke + 1864
	14  UIKitCore                           0x0000000184ab78cc __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_3 + 292
	15  UIKitCore                           0x0000000185773060 -[_UIAfterCACommitBlock run] + 64
	16  UIKitCore                           0x0000000185773470 -[_UIAfterCACommitQueue flush] + 160
	17  libdispatch.dylib                   0x0000000107f0c0f0 _dispatch_call_block_and_release + 24
	18  libdispatch.dylib                   0x0000000107f0d93c _dispatch_client_callout + 16
	19  libdispatch.dylib                   0x0000000107f1d5e4 _dispatch_main_queue_drain + 1228
	20  libdispatch.dylib                   0x0000000107f1d108 _dispatch_main_queue_callback_4CF + 40
	21  CoreFoundation                      0x00000001803ee1b4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
	22  CoreFoundation                      0x00000001803e88cc __CFRunLoopRun + 1936
	23  CoreFoundation                      0x00000001803e7d28 CFRunLoopRunSpecific + 572
	24  GraphicsServices                    0x000000018e7cdbc0 GSEventRunModal + 160
	25  UIKitCore                           0x00000001852bafdc -[UIApplication _run] + 868
	26  UIKitCore                           0x00000001852bec54 UIApplicationMain + 124
	27  index                               0x00000001029e7610 main + 120
	28  dyld                                0x0000000106f79558 start_sim + 20
	29  ???                                 0x000000010701a0e0 0x0 + 4412514528
	30  ???                                 0x8915800000000000 0x0 + 9877942095195406336
)
libc++abi: terminating due to uncaught exception of type NSException
USER ERROR: Condition "err != OK" is true. Returning: ERR_CANT_CREATE
   at: _window_create (drivers/vulkan/vulkan_context.cpp:1,837)
USER ERROR: Failed to create Vulkan window.
   at: DisplayServerIOS (platform/ios/display_server_ios.mm:88)
USER ERROR: Unable to create DisplayServer, all display drivers failed.
   at: setup2 (main/main.cpp:2,395)

@ViktorEvil
Copy link
Contributor Author

I get the same error whilst trying to run in the iOS simulator. it gets as far as the splash screen then crashes with the below

Exception NSException * "Supported orientations has no common orientation with the application, and [UIAlertController shouldAutorotate] is returning YES" 0x0000600000d9f780

I have the game set to just run in portrait mode

@MartijnTijsma
Copy link

MartijnTijsma commented Aug 13, 2024

I get the same error whilst trying to run in the iOS simulator. it gets as far as the splash screen then crashes with the below

Exception NSException * "Supported orientations has no common orientation with the application, and [UIAlertController shouldAutorotate] is returning YES" 0x0000600000d9f780

I have the game set to just run in portrait mode

@ViktorEvil I have the exact same error. Did you ever figure it out?

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.