无法使用 Xcode 4 进行构建 - 所选的运行目标对此操作无效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5422066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to build using Xcode 4 - The selected run destination is not valid for this action
提问by Geesu
So I'm horribly confused by this error, other threads on Stack Overflow mention I should set the SDK, but I see no option to do this. I'm trying to build:http://wafflesoftware.net/shortcut/
所以我对这个错误感到非常困惑,Stack Overflow 上的其他线程提到我应该设置 SDK,但我看不到这样做的选项。我正在尝试构建:http: //wafflesoftware.net/shortcut/
And I get no options, and I can only choose My Mac 64-bit, and I want it in 32-bit. Really beginning to hate Xcode 4.
我没有选择,我只能选择我的 Mac 64 位,我想要 32 位。真的开始讨厌 Xcode 4。
Here is the screenshot when I try to edit my scheme: http://groovyape.com/scheme.png
这是我尝试编辑我的方案时的屏幕截图:http: //groovyape.com/scheme.png
Thoughts?
想法?
回答by Roger
Firstly, I have observed that when Xcode 4 decides my Mac is 64 bit and all my other schemes have vanished, a restart of Xcode fixes that.
首先,我观察到当 Xcode 4 决定我的 Mac 是 64 位并且我的所有其他方案都消失时,Xcode 的重新启动修复了这个问题。
If you still have the issue after a restart, go to Manage Schemes... (under the Product Menu) and click on Autocreate Schemes now button. Try to delete the other schemes and see if you can run the project now.
如果重新启动后问题仍然存在,请转到管理方案...(在产品菜单下)并单击立即自动创建方案按钮。尝试删除其他方案,看看您现在是否可以运行该项目。
However, if the issue is that you need to set the SDK, that's different:
但是,如果问题是您需要设置 SDK,那就不同了:
- Click on the top-level project icon in the left hand panel
- In the right hand panel that appears, select Build Settings (near the top).
- Select "All" option (instead of Combined)
- Ensure Base SDK is set appropriately, like "OS X 10.7".
- 单击左侧面板中的顶级项目图标
- 在出现的右侧面板中,选择“构建设置”(靠近顶部)。
- 选择“全部”选项(而不是组合)
- 确保 Base SDK 设置正确,例如“OS X 10.7”。
FWIW I'm seriously considering reverting to Xcode 3.2.5 at the moment, 4 seems horrendously buggy.
FWIW 我目前正在认真考虑恢复到 Xcode 3.2.5,4 似乎有可怕的错误。
回答by Terence SO
In xCode 4.4.1
, use Validate Settings
to solve the problem!
在xCode 4.4.1
,Validate Settings
用来解决问题!
I can select either 32bit
or 64bit
now.
我可以选择32bit
或64bit
现在。
回答by Gerry Beauregard
Ran into the same error message ("The selected run destination is not valid for this action") when attempting to use XCode 4 to build/run a tiny Objective-C "Hello, World" project I created in XCode 3.x. Fixed it by choosing to "Manage Schemes..." from the drop-down menu to the right of the Stop button, deletingthe one scheme on the list (click checkbox beside the scheme, then click the "-" button at the bottom left), and then clicking "Autocreate Schemes Now".
尝试使用 XCode 4 构建/运行我在 XCode 3.x 中创建的小型 Objective-C“Hello, World”项目时遇到相同的错误消息(“选定的运行目标对此操作无效”)。通过从停止按钮右侧的下拉菜单中选择“管理方案...”,删除列表中的一个方案来修复它(单击方案旁边的复选框,然后单击底部的“-”按钮左),然后单击“立即自动创建方案”。
I also needed to change the "Base SDK" from 10.5 to 10.6, by clicking on 'folder' icon (beneath the Run button), clicking the root/top of the tree view below it, clicking on the blue icon below "PROJECT" in the pane just to the right, and then finally, choosing "Latest Mac OS X (Mac OS X 10.6)" to the right of that.
我还需要将“基础 SDK”从 10.5 更改为 10.6,方法是单击“文件夹”图标(运行按钮下方),单击其下方树视图的根/顶部,单击“项目”下方的蓝色图标在右侧的窗格中,最后选择右侧的“最新 Mac OS X (Mac OS X 10.6)”。
回答by brianegge
I had this issue today. I found switching Base SDKfrom Latest iOS (4.3)to iOS 4.3fixed everything.
我今天遇到了这个问题。我发现将Base SDK从最新的 iOS (4.3)切换到iOS 4.3 可以解决所有问题。
回答by Charles Garrison
This will happen if XCode believes your mac is a 64-bit machine, when really it's a 32-bit. If this is the case for you, simply click on your project icon from the far-left pane - it's the menu item that displays your project name next to a little blue icon. This should bring up a center pane that says "PROJECT" at the top. Highlight your project name, and the third pane should now show your build settings. The first item is "Architectures" which will allow you to specify if you are building a 32-bit or 64-bit application.
如果 XCode 认为您的 Mac 是 64 位机器,而实际上它是 32 位机器,则会发生这种情况。如果是这种情况,只需单击最左侧窗格中的项目图标 - 它是在蓝色小图标旁边显示项目名称的菜单项。这应该会弹出一个中心窗格,顶部显示“项目”。突出显示您的项目名称,第三个窗格现在应该显示您的构建设置。第一项是“架构”,它允许您指定是构建 32 位还是 64 位应用程序。
回答by SilverSideDown
Kind of amazing that none of the answers here solved the issue for me, but I figured it out. Forget restarting Xcode, or using Autocreate Schemes, still only 64-bit will show up as a valid destination in the scheme.
令人惊讶的是,这里的所有答案都没有为我解决问题,但我想通了。忘记重新启动 Xcode 或使用 Autocreate Schemes,仍然只有 64 位将显示为方案中的有效目标。
The correct solution is to change the Architecture for your project. Go to Build Settings (in the root node of your project), and change Architecture to 32-bit Intel, it's right above the Base SDK setting. Destination will instantly switch to "My Mac 32-bit". HTH somebody.
正确的解决方案是更改项目的架构。转到 Build Settings(在项目的根节点中),将 Architecture 更改为 32-bit Intel,它位于 Base SDK 设置的正上方。目的地将立即切换到“我的 Mac 32 位”。HTH某人。
回答by Thomas
I found a good practice for moving from Xcode 3.2.X to Xcode 4 is, to remove any references to older SDKs (in the case of Mac OS to remove any Base SDK Ref, etc., for Mac OS <= 10.5, in the case of iOS I think you need to remove everything <= 4.3) PRIOR to upgrading to Xcode 4.
我发现从 Xcode 3.2.X 迁移到 Xcode 4 的一个好做法是,删除对旧 SDK 的任何引用(在 Mac OS 的情况下,删除任何 Base SDK Ref 等,对于 Mac OS <= 10.5,在在 iOS 的情况下,我认为您需要在升级到 Xcode 4 之前删除所有 <= 4.3)。
I never experienced any problems for new Projects, created in Xcode 4, only for such that where created with Xcode 3.X or 2.X
对于在 Xcode 4 中创建的新项目,我从未遇到任何问题,仅针对使用 Xcode 3.X 或 2.X 创建的项目
回答by Oliver Collyer
I had this issue and maybe it was a coincidence but when I restarted XC4 but this time didn'tchoose to load my project from the popup window that appears on launch - instead choosing it explicitly from the File menu - the issue didn't occur and the build started ok.
我遇到了这个问题,也许是巧合,但是当我重新启动 XC4 时,但这次没有选择从启动时出现的弹出窗口加载我的项目 - 而是从文件菜单中明确选择它 - 问题没有发生并且构建开始正常。
On the 3 or 4 occasions I had this error, I had chosen to load the project from the popup window that appears when XC4 first loads.
在 3 或 4 次出现此错误的情况下,我选择从 XC4 首次加载时出现的弹出窗口加载项目。
As I say, I might have just got lucky, but I certainly didn't make any other changes to the projects to 'fix' the issue.
正如我所说,我可能只是很幸运,但我当然没有对项目进行任何其他更改来“修复”问题。
回答by Joshua Nozzi
It sounds as if you're trying to run (Cmd-R or run button) the framework (which you can't do - it's not an executable, just a library) rather than simply build it (Cmd-B).
听起来好像您正在尝试运行(Cmd-R 或运行按钮)框架(您不能这样做 - 它不是可执行文件,只是一个库)而不是简单地构建它(Cmd-B)。
回答by Thijs Koerselman
Xcode 4.5. I was trying to compile for 10.6. It seemed to be stuck on 64 bit just because it couldn't find the sdk. I didn't get any message about it not finding the sdk.
Xcode 4.5。我试图为 10.6 编译。它似乎只是因为找不到 sdk 而卡在 64 位上。我没有收到任何关于它找不到 sdk 的消息。
I first tried to put in the correct path to /Developer-3.2.6/SDKs/MacOSX10.6.sdk but xcode didn't want to find it there. Then I copied that folder into 4.5 next to the other OSX Platform sdk (new location I think just look in the bundle).
我首先尝试放入 /Developer-3.2.6/SDKs/MacOSX10.6.sdk 的正确路径,但 xcode 不想在那里找到它。然后我将该文件夹复制到另一个 OSX 平台 sdk 旁边的 4.5(新位置,我认为只需查看捆绑包)。
And magically my 32 bit came back.
神奇的是,我的 32 位又回来了。
So my conclusion is that the 32/64 bit option is really dependent on whether xcode can verify the sdk that you're trying to use. Being stuck at 64 while trying to compile for 32 gives the error without notifying you that its first issue is that the sdk can't be found.
所以我的结论是 32/64 位选项实际上取决于 xcode 是否可以验证您尝试使用的 sdk。在尝试编译 32 时卡在 64 会导致错误,而没有通知您它的第一个问题是找不到 sdk。