Xcode 12.2 errors when IOS simulator with Cocos2d-x 4.0

My Mac use:
macOS Big Sur - version 11.0.1
Xcode 12.2
Cocos2d-x 4.0
I compile according to the command:
build_ios && cd build_ios
open install_test.xcodeproj
When I simulator - Xcode error message
I have research on the internet, I to replace flies *.dylib with flies *.tbd
But Xcode error message:

Can someone help me to solve this problem

Can no one help me?
Development engineer of cocos2d-x, please help me.

I’m not using Xcode 12 yet. Can you post your build setting and what architectures you are building for.

I searched for X86_64 but couldn’t find it.

At the request of Apple to up the application to the AppleStore. I have to update Xcode to Xcode 12.2

@slackmoehrle Xcode 12.2 works perfectly fine with Cocos2d-x v4, so I think the issue is related to the Xcode project settings.

@JameBook79 The error message is telling you exactly what the problem is. You’re building for iOS simulator, which most likely defaulted to arm64 architecture, yet you’re trying to link with the x86_64 architecture libraries.

To fix the problem, you need to ensure simulator builds are compiled for x86_64 architecture.

1 Like

Thanks. I asked for the OP to post images to confirm they are building for arm instead of x86_64

I should probably upgrade to 12

Yep I see them now, and they confirm the source of the problem.

@JameBook79 Add this to the Apple/iOS section in your project CMakeLists.txt:

        # force x86_64 architecture for iphonesimulator builds
        set_target_properties(${APP_NAME} PROPERTIES
            XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] x86_64
            XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] x86_64

After you re-run cmake, open the project in Xcode, and click the Project Navigator, then on the right click on the executable target, the one with the Cocos icon (whatever your project is called, like in your case “install_test”). Once you do that, it should look like this:

1 Like

Cmake is nothing short of amazing.

I can’t say the same about Xcode. :frowning:

1 Like

I followed the way you instructed but still got the error.

and in bulding setting

the result is

That definitely should not be happening. Any time you change a setting in CMake, make sure you close the Xcode project before re-running CMake, and always do a full clean when you re-open the project in Xcode.

For now, close Xcode, delete the contents of the build_ios folder, and recreate it with the cmake command you used above, cmake .. -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos.

What Mac are you using, one with an Intel x86 CPU or an Apple M1 ARM based CPU?

I have followed all the steps as you instructed, but still got the same error
I use macbook air 2017 - Intel x86 CPU
Did you run compile on xcode 12.2 yet. Previously I compiled on xcode 12.1 is fine
Please, Help me.

I’m all out of ideas for this, but you should check this post in case it has something that may help.

Thank you for your help!
Has anyone successfully simulator iOS Xcode 12.2 yet?

Yes, as I mentioned in an earlier post in this thread, the simulator builds work fine on 12.2. The only difference is that I’m still using MacOS 10.15.

You update to macOS Big Sur - version 11.0.1.
And simulator is possible?
Thank you.

No I can’t do that, since my Mac Mini doesn’t support it, but maybe someone else here has it installed.

Thank you for your help.
Can anyone solve this problem?

Have you seen this SO post, maybe?

It’s a bit strange with x86_64 though. SO has a separate, unresolved topic on this: https://stackoverflow.com/questions/64152923/xcode12-building-for-ios-simulator-but-linking-in-object-file-built-for-macos

If I were you, I would try setting Build Active Architectures Only to NO, AND applying the solution from the first topic , that is, add arm64 to Any Simulator excluded architectures. PLus possibly clean&rebuild. No promises though. Good luck!

EDIT: IF it works and you’re not constantly switching between device and simulator, maybe you could switch Build Active Architectures Only to YES to shorten build time. Or just try the simulator excluded architectures trick first.

1 Like

Having the same issue with both emulator and device. It looks like you can no longer link to .dylib files.