Arm64 in excluded architectures - how to use?

I've created a framework which I want to build as an XCFramework. If I don't add arm64 to the excluded architectures i will get an error when building for simulator - something like "undefined symbols for..."

If I add the arm64 to the excluded architectures it will build correctly for simulator but it will create an issue for building for a real device.

So now what I do is - I build once for the simulator with the arm64 flag and I build again for real device without this flag.

What is the correct way of doing this automatically?
Excluding architectures isn't a good idea except in narrow, well-defined situations. arm64 doesn't meet that criteria, because it is a a valid architecture for all of the simulators, as well as all of the devices, on all of Apple's platform — thus, you should never exclude it because it is so widely used.

To really address your issue, go back to the beginning and resolving the first error regarding undefined symbols that you saw when building for the simulator. If the undefined symbol is referring to something in a third-party dependency that you are using, then you need to talk to the maintainers or support team for that dependency to get an update that supports arm64 simulators as the first step.
Arm64 in excluded architectures - how to use?
 
 
Q