Xcode using a Mac with Intel chips versus Xcode using a Mac Mini using Rosetta

Xcode (for Rosetta) on an Intel machine is not producing the same binary as Xcode (for Rosetta) on the M1 machine. Is this just an isolated case, and my bad luck? Ot are there other users that are finding that Xcode 13 on a Mac with Intel will produce an app that crashes when launched on a Mac Mini using Rosetta (even though the option was chosen to produce a Rosetta version)?


In my case the program will compile and run on the Mac using Intel but then that version will not run on the M1 Mac Mini using Rosetta, even though the documentation suggests it should. Yet if I do this in reverse by compiling thee exact same project on the M1 Mac Mini (choosing the Rosetta option) it runs fine (both on the Mac with Intel as well as the M1 Mac mini).


Would have saved much time if this possibility was made more evident (and now hoping some explanation can be made available as to why this can happen).


Does not seem consistent with the documentation.



Posted on Oct 19, 2021 9:05 PM

Reply
18 replies

Oct 21, 2021 8:05 AM in response to gordon_lister

I thought that link indicated how to set up Xcode on an Intel platform to build a universal binary? Here is how it is done on a MacBook Air (Intel) running macOS 11.6 and using the command-line tools for Xcode 13, where swift (or clang) is used as a cross-compiler:



The universal2 binary (pdfmerge_same) created by lipo runs correctly on the Intel and M1 Mac platforms. Not shown in the preceding is the output of lipo -archs confirming that the X86_64 and arm64 binaries are present in the universal2 binary.

Oct 23, 2021 8:50 AM in response to gordon_lister

Perhaps the first step is to learn the correct terminology so that other people know what you are talking about. When you write "XCODE", I know you mean Xcode, so I'm not complaining about that. But it is a good example of why you aren't able to articulate what is going on in a manner that other people can understand.


When you run "under" Xcode, you are simply running the app in a debugger. At a fundamental level, your app, in that state, is completely different from the app when run from the Finder. It doesn't even use the same sequence of instructions. It's a different app - a different binary file altogether. What can go wrong there? Literally anything and everything. You can run in release mode form Xcode, but it usually isn't advisable. It won't help and will only confuse you.


What you are describing is simply a problem with notarization. There is an entire forum on the Developer forums dedicated to notarization. (See https://developer.apple.com/forums/tags/notarization/). I suggest looking for any posts by the Apple engineer known as "eskimo". He periodically creates "how to" posts covering commonly encountered problems. This post seems to be the latest such example, but he has written many, many similar posts. You should also review the documentation and the most recent WWDC video.


Unfortunately, Apple never seems to grasp just how many developers never review any of that documentation and how many are just making it up as they go along. I gave up answering notarization questions in the developer forums out of sheer frustration. I wasn't frustrated with the notarization process. Notarization is one of the easiest things to do. I was frustrated in my attempts to get other developers to read documentation and, at a basic level, understand how apps are constructed. This is not a case of something that I'm saying "should be" easy for developers because it's easy for me. It is easy if you just accept the defaults and take the easiest route. But, invariably it seems, developers who have notarization problems seem to invent unique new ways to construct apps that no one has attempted before. This is a fundamental problem. Other developers, or support engineers from Apple, can't help because all they know about is how to properly construct apps. But when developers in notarization forum finally explain exactly what they are doing, my reaction is always, "Wow. I never thought anyone would try that." Even eskimo seems to have become resigned to the problem. He rarely spends much time explaining anymore. Usually he just asks the developer to file a DTS ticket. That might be a good idea in this case too.


gordon_lister wrote:

My purpose in coming to this forum however was to learn, in particular as to the nature of the class of errors that provide no hint as to their existence when the code is executed running "under" XCODE but which nevertheless crash the program when the binary is run stand alone. We can eliminate issues related to their party libraries

I'm assuming you meant to write "third party libraries". And on that point, I am extremely skeptical.

I do not use anything that is not part of C++ or Objective-C.

That has absolutely nothing to dow with third party libraries.

So generally speaking, now we are getting down to it, do you have other more concrete suggestions to the type of issue that can escape notice in XCODE (no exceptions being thrown) but crash the binary when it is run stand-alone.

As I've said above, you have a standard case of notarization failure. You keep trying to ask some philosophical question about the nature of software development. All software ever made will behave radically differently when run outside of a debugger. Then it will behave radically differently when run on a different account on your machine. Then is will behave radically differently when run on a different computer. Then when you try to run it at scale (with hundreds or thousands of different users), those once-in-a-million crashes become an avalanche of support e-mails.


As I'm rapidly approaching the 5000 character limit here in the forums, I can't engage further on philosophical debates. All I can do is solve your problem, ignoring virtually everything you've said. Most likely your problem is because a third party library either wasn't linked properly, wasn't signed properly, or is doing something illegal. You may be able to adjust your hardened runtime entitlements to compensate, maybe not. Or maybe you are doing something "clever" outside of Xcode that just so happens to work in the debugger. One easy solution is to create a new app project using the Xcode app template. Archive it. Export it. Notarize it. Example how it is constructed and how the process works for that simple app. Now identify the ways that you are doing things differently. Start with those differences.

Oct 20, 2021 2:20 PM in response to woodmeister50

Thank you Woodmeister50.


Indeed I had looked at that page in some detail, but it did not help me. But thank you for pointing it out yet again.


The issue is Xcode13 (no simulator) but I see (according to the release on October 18) that a new Xcode version (13.1RC) is on the way that will help with an Intel machine (at least that is how I read it). Then we will see whether the problem goes away.

Oct 21, 2021 8:23 AM in response to VikingOSX

Hello again Viking OSX


With the Intel machine (not in command line mode) XCODE 13 provides the option for a Universal Binary but then immediately requests a simulator. Since one is not present, one cannot make a Universal binary.


My thought is to wait for the release of XCODE 13.1RC


The question I have is to try to understand why the Intel version of my app will not run on Rosetta on the M1 MacMini. I agree that many apps will not face the problem. I also agree that the Apple documentation makes several useful suggestions as to why an app might not make the transition without being modified. But clearly some apps will require modification and my app is one of them. Bad luck for me (especially as I wrote it using C++ and Objective-C).


However, the thing that I find odd is that I can indeed compile and run the code on the M1 Mac Mini using Rosetta, yet the version I made on the Intel machine will not run on the M1 Mac Mini.


I suppose the difference is that when I compile and run on the M1 Mac Mini XCODE is open and still attached.

Oct 22, 2021 11:55 AM in response to gordon_lister

Your question doesn't make any sense.


Xcode is, itself, a universal app. It does not use Rosetta at all, in any way. When you first run Xcode, it asks if you want to install Rosetta only so you could test Intel-only apps, if you decided to create such a thing, for whatever reason. Rosetta is strictly a run-time library and has nothing to do with Xcode or building software.


Xcode has supported universal binaries for over a year now. If there is something you can't do with the shipping version of Xcode, then you won't have any more luck with any new version.


And that's about all I can say, given how little I understand of what you are asking. I think you are just encountering a crash. That's just a bug in your code. Many developers feel that their code is correct when it doesn't crash. Then they get confused when it crashes after some major platform change. No, chances are, it was wrong from day one. The most likely explanation is some crazy 3rd party library.


Furthermore, it would be helpful to know something about the nature of said crash. A crash log perhaps? Console output during the crash, maybe? It may be just some problem with the signature cased by, ahem, some crazy 3rd party library.



Oct 22, 2021 4:19 PM in response to gordon_lister

I don't know what you mean about Xcode picking up on "hints". Xcode includes a compiler. Compilers are notorious for doing exactly, precisely what the programmer instructed them to do, ignoring any and all "hints" as to what they should have done.


I think you are saying that it works when run inside Xcode on an M1 device, but fails when run outside of Xcode. You want a list of things that can cause that? That's hard to say because "running from outside Xcode" can, itself, mean about 10 different scenarios. Which one applies to you? I have no clue. Generally speaking, these problem are virtually always with 3rd party libraries, as I suggested above. As for specific classes of errors, I could think of general 3rd party library craziness or signature problems, which are often the result of 3rd party library craziness. This is over and above the radical change in environment from an Xcode debugging session to a normal launch.


Of course other developers have encountered similar problems. However, other developers encountered, and solved, these problems over a year ago. What you are asking is if anyone remembers what specific problems they encountered in July and August 2020 and how those might apply to an unspecified SIGBUS error today. But then, "today" is relative. For all I know, you are still using some source code from before 2020 that was making assumptions about low-level platform characteristics on macOS and then broke when those characteristics changed slightly.


My suggestion is to start with specifically where the crash occurs. You should have crash logs. What do they say? If your problem is due to a 3rd party library runtime and/or signature, you will often see messages in the console log that explain the cause. Last and not least, if you have Xcode and an M1, why do you care in the first place? How does the ARM version run? That is the only thing that matters going forward. Apple is going to be abandoning Rosetta in a couple of years anyway. That was always a transition phase. That transition phase is rapidly coming to a close.

Oct 21, 2021 7:23 AM in response to VikingOSX

Yes thank you also VikingOSX


But since you have been so kind to point me to what I can read (although actually I had read this before making the post) perhaps you could explain how one is able to make a Universal MacOS Binary on an Intel machine. The option is provided but no simulator appears to be available. Hence it does not appear to be possible.


An easy question for you and for Woodmeister50 since you both are familiar with the available documentation ...


The point of my question is to ask whether other users have the experience of an app that can be compiled to run on both machines, in one case natively, and in the other case using Rosetta, but the version produced on the Intel machine will not run with Rosetta using the M1 machine.

Oct 21, 2021 9:16 AM in response to gordon_lister

I have limited experience with Xcode (by choice) even though I have Xcode 13 installed. Any command-line tools or visual Cocoa applications that I have written are developed on the command-line in either Objc, Swift, or PyObjc.


You posted a developer-related question in the Mac mini community and you would likely receive better responses from those experienced with Xcode if the post were in the Developer community. Would you like me to request that the Apple hosts move your post to the Developer community?

Oct 22, 2021 2:37 PM in response to etresoft

Thank you etresoft.


The binary runs on an Intel Mac, but it will not run using Rosetta on a M1 Mac Mini.


The documentation provides a list of reasons why this might be the case, all of which are helpful. My question in essence was to ask why XCODE does not pick up any hint that there is going to be a problem, even when the code is compiled and run (with XCODE still attached) on the Mac Mini using Rosetta? Or differently framed, what are the conditions that allow a binary to run when it is attached to XCODE but to fail when the binary is run on its own? Could you provide examples of classes of errors that somehow are invisible to XCODE but which will cause a crash when the binary is run unattached. That would be helpful.


You write that this question does not make any sense, although it seems does seem logical to me. My question, for the record was whether other developers encounter this problem. Your think my code is not "correct" because it crashes after this "major platform change". Indeed, thank you, this matches my own perception. Indeed my code cannot be "correct". Something within it is no longer tolerated, which is of course why it would crash after a major platform change. You also post that there are many confused developers out there. Correct. Definitely confused, which is of course why I run the gamut of daring to ask a question. It would be helpful therefore for you to address the one piece of information that I did provide, since perhaps with the knowledge thereby gained I could attempt to solve my own issue. How is it possible for code to run seamlessly when compiled and run with Xcode (attached) [in this case on the M1 Mac Mini] (using Rosetta) but then for the binary to fail (with a SIGBUS error, and yes, I know the list of options that cause such behaviour).



Oct 23, 2021 1:26 AM in response to etresoft

Thank you etresoft.


I guess my use of the word "hint" mislead you. I meant that the version running "under" XCODE ran without issues, without any hints that there would be a problem running the resultant binary stand-alone. Step one is to "build" and then to "run" under XCODE. No problems. Step two is to "notarize" the build and then to export it. Step three is to run the app, which is when it immediately crashes. By now I have narrowed down the cause to a particular "controller" since the crash occurs in "makeWindowControllers" when I add the controller in question. I will get there, no worries, it is just a matter of time.


Indeed I am using code prior to 2020. Gosh, some of my code was written in the nineties, but now is a combination of C++ and Objective-C using a control-model-view architecture. As far as I am aware I made no low level assumptions, but who knows. Eventually I will track this error down.


My purpose in coming to this forum however was to learn, in particular as to the nature of the class of errors that provide no hint as to their existence when the code is executed running "under" XCODE but which nevertheless crash the program when the binary is run stand alone. We can eliminate issues related to their party libraries, since I do not use anything that is not part of C++ or Objective-C. So generally speaking, now we are getting down to it, do you have other more concrete suggestions to the type of issue that can escape notice in XCODE (no exceptions being thrown) but crash the binary when it is run stand-alone.

Oct 23, 2021 10:31 AM in response to etresoft

Hello etresoft


Sorry, but I did not notice my spell checker making 'corrections'. Similarly, apologies in respect to semantics, but these do change with time. And again, in respect to philosophical debate. This is not a debate, and I see no harm in asking for an example (just one concrete example) of the type of issue that will escape notice in the debug mode, run smoothly and seamlessly on an Intel machine, but cause a crash on the M1 Mac Mini. That does not seem an outrageous question, so perhaps with your wealth of wisdom, could you possibly provide one concrete example [one that depends on nothing more than the code you write]?


It is not a problem caused by signing, or by a third party library. By a "third party" I take that to mean a legal entity that is not Apple. Similarly, in respect to your decision that I have a standard case of notarisation failure. Nope, sorry. The problem depends not at all on notarisation. My guess is that it is a memory allocation error, and perhaps to do with strings.


It would be very helpful to be able to see an example of code that will compile and run in debug mode (with Xcode13) then run successfully as an independent binary on an Intel machine, but then crash on execution on an M1 Mac Mini.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Xcode using a Mac with Intel chips versus Xcode using a Mac Mini using Rosetta

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.