Re: "A build only device cannot be used to run this target" appearing with "Any Mac" scheme
Re: "A build only device cannot be used to run this target" appearing with "Any Mac" scheme
- Subject: Re: "A build only device cannot be used to run this target" appearing with "Any Mac" scheme
- From: Matt Jacobson via Cocoa-dev <email@hidden>
- Date: Mon, 23 Aug 2021 14:44:31 -0400
> On Aug 23, 2021, at 2:20 PM, Gabriel Zachmann <email@hidden> wrote:
>
> Hi Matt,
>
> thanks a lot for your quick response. It clarifies a few things .. but see
> below.
>
>>
>> That pop-up actually has two halves: first, a scheme, and second, a run
>> destination.
>>
>> “Any Mac” and “My Mac” are run destinations, not schemes. But, as you’ve
>> seen, “Any Mac” is a special “build-only” run destination that only supports
>> building, not running.
>>
>> You should be able to pair your scheme with either of those run
>> destinations. (If not, check the ARCHS (“Architectures”) setting of your
>> targets. Normally, it should be set to $(ARCHS_STANDARD) (“Standard
>> Architectures (Apple Silicon, Intel)”) — which is the SDK default anyway.)
>
> That is the case in my Build Settings.
>
>>
>> If you wish to build your scheme with the “My Mac” run destination and make
>> sure you’re building for both architectures, check out the ONLY_ACTIVE_ARCH
>> (“Build Active Architecture Only”) build setting. When YES, Xcode will
>> build only for the architecture of your run destination; when NO, it’ll
>> build for all valid architectures.
>
> This is set to "Yes" in the Debug case, and "No" in the Release case.
>
>
> Do you have any other idea what might be causing this error message ?
> Is there a way to compile & run a universal app from Xcode directly?
> Or do I have to remember to switch to the "Any Mac" destination before I
> distribute an app?
> (I'm talking about macOS apps.)
It’s definitely doable. Let me attempt to summarize:
First, you cannot run against the “Any Mac” destination, by design. (That is
what’s causing the error message. It’s a build-only destination, and you’re
trying to run on it.) You can run against the “My Mac” destination.
Second, let’s think about “My Mac”. Given the settings you described above—a
debug build will be active-architecture-only. If you’re on an Intel Mac, that
means Intel-only; if you’re on an ARM Mac, that means ARM-only.
All together, that means: if you want to run, you must use the “My Mac” run
destination—and if you want the build used for that run to be fat (i.e., both
Intel and ARM), then either of these two things should work:
1. Change your scheme to Release (this usually enables compiler optimizations,
somewhat hampering debuggability)
2. Change ONLY_ACTIVE_ARCH to NO for debug (this makes builds take longer debug
mode, since both architectures must be built — probably not a big deal for
small projects)
===
Additionally—as you suggest—there is a third way. You can use { “My Mac”,
Debug, ONLY_ACTIVE_ARCH=YES } for local development/debugging, and use “Any
Mac” for building the app to distribute.
That includes “distributing” test versions to Macs of the opposite architecture
from you. (Of note here: the “active architecture” of “Any Mac” is considered
to be *both* architectures; in other words, “Any Mac” is essentially unaffected
by ONLY_ACTIVE_ARCH. So a debug build against “Any Mac” will be fat.)
Matt
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden