简体   繁体   English

Xcode 将在模拟器上运行应用程序但不在设备上

[英]Xcode will run app on simulator but not on device

I receive the following error when trying to run the app on my device.尝试在我的设备上运行该应用程序时收到以下错误。

error: failed to launch '/Users/michael/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos/Word Processor.app/Word Processor' -- No such file or directory (/Users/michael/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos/Word Processor.app/Word Processor)

The app runs fine in the simulator.该应用程序在模拟器中运行良好。 When I try to debug on the device, it appears to copy the app (I can see the icon), but then stalls with the above message.当我尝试在设备上调试时,它似乎复制了应用程序(我可以看到图标),但随后因上述消息而停止。 Xcode says it is running the app on my iPod, but nothing is happening on my iPod. Xcode 说它正在我的 iPod 上运行该应用程序,但我的 iPod 上没有任何反应。

When I click on the app, the app appears to launch, but seems to be missing resources.当我单击该应用程序时,该应用程序似乎已启动,但似乎缺少资源。 Other projects of mine work properly.我的其他项目工作正常。 What setting do I need to change to make this work properly.?我需要更改什么设置才能使其正常工作。? Looking at the error message, it seems to be looking in my mac for the app.查看错误消息,它似乎在我的 mac 中寻找该应用程序。 But this doesn't make sense since I am trying to run it on my 4th gen iPod touch.但这没有意义,因为我试图在我的第 4 代 iPod touch 上运行它。 I am using Xcode 4.3.1 and iOS 5.1我使用的是 Xcode 4.3.1 和 iOS 5.1

With Mountain Lion and the latest version of Xcode (4.4.4F250), none of the suggestions in this thread worked directly (clean, clean project, remove derived data folder, etc).使用 Mountain Lion 和最新版本的 Xcode (4.4.4F250),该线程中的任何建议都不能直接工作(清理、清理项目、删除派生数据文件夹等)。 This sequence did.这个序列做到了。 From DhilipSiva :来自DhilipSiva

  1. Disconnect your device断开您的设备
  2. Delete the app from your device从您的设备中删除该应用程序
  3. Quit Xcode (Don't just simply close the window, quit it)退出 Xcode(不要只是简单地关闭窗口,退出它)
  4. Delete derived data folder rm -fr ~/Library/Developer/Xcode/DerivedData (console)删除派生数据文件夹rm -fr ~/Library/Developer/Xcode/DerivedData (控制台)
  5. Start Xcode,connect device & run the project启动Xcode,连接设备并运行项目

I solve this by going to Targets-> Info -> Required Device capabilities and delete the option with armv7.我通过转到目标-> 信息-> 所需的设备功能并使用 armv7 删除该选项来解决此问题。

Hope this helps!希望这可以帮助!

This is a recurring problem that many developers are having with the current version of Xcode.这是许多开发人员在使用当前版本的 Xcode 时经常遇到的问题。 The temporary workaround has been consistently deleting the DerivedData folder.临时解决方法一直是删除 DerivedData 文件夹。

You can add doing it to a build script or even make it a cron job:您可以将其添加到构建脚本中,甚至可以将其设为 cron 作业:

rm -rf ~/Library/Developer/Xcode/DerivedData

Sad, but true.悲伤,但真实。

For me restarting of Xcode, cleaning DerivedData and restaring device wasn't enough in most cases, until I had figured out that iTunes was also running, and after quitting iTunes everything worked fine!对于我重新启动 Xcode,在大多数情况下清理 DerivedData 和重新启动设备是不够的,直到我发现 iTunes 也在运行,并且在退出 iTunes 后一切正常!

So my steps now are simple:所以我现在的步骤很简单:

1. Quit Xcode. 1. 退出 Xcode。
2. If iTunes is running, quit iTunes. 2. 如果 iTunes 正在运行,请退出 iTunes。
3. Reopen project. 3. 重新打开项目。

No need to remove app from the device, clean project or restart/disconnect device.无需从设备中删除应用程序、清理项目或重启/断开设备。 I think that's because Xcode and iTunes use some common libraries (as you know, Xcode Installer always asks to quit iTunes on installing iOS SDK).我认为这是因为 Xcode 和 iTunes 使用一些公共库(如您所知,Xcode Installer 在安装 iOS SDK 时总是要求退出 iTunes)。

I also had this problem after changing from a lower XCode and iOS version to the current XCode and iOS version.从较低的 XCode 和 iOS 版本更改为当前的 XCode 和 iOS 版本后,我也遇到了这个问题。

I fixed this problem by changing th iOS Depolyment Target to a lower version, since my Device is not updated to the latest iOS yet.我通过将 iOS Depolyment Target 更改为较低版本来解决此问题,因为我的设备尚未更新到最新的 iOS。 You can do this by clicking the project inside the Info tab.您可以通过单击“信息”选项卡内的项目来执行此操作。

Have you looked at the Developer Certs and Distribution Certs if you have.如果您有,您是否查看过开发人员证书和分发证书。 When running in debug mode from Xcode your will need your app assigned with the developer cert and not the distribution cert.当从 Xcode 以调试模式运行时,您需要为您的应用程序分配开发人员证书而不是分发证书。 The distribution certs do not allow for debugging.分发证书不允许调试。

This error will manifest whenever the device capabilities described in the Info.plist do not match those of the device.每当 Info.plist 中描述的设备功能与设备的功能不匹配时,就会出现此错误。

In my case, I was requesting GPS support and location-services support and trying to test on an iPod touch.就我而言,我请求 GPS 支持和位置服务支持,并尝试在 iPod touch 上进行测试。

I struggled with this problem for 2 days and went through all the posts, tried all the options including, restarting Xcode, device, deleting DerivedData folder etc.我在这个问题上挣扎了 2 天,浏览了所有帖子,尝试了所有选项,包括重新启动 Xcode、设备、删除 DerivedData 文件夹等。

Finally, the problem was with the Info.plist file.最后,问题出在 Info.plist 文件上。 In my case, I had improper icon paths in the Info.plist file.就我而言,我在 Info.plist 文件中有不正确的图标路径。 I suggest you to archive the application and then validate it to get the exact problem in you case.我建议您将应用程序存档,然后对其进行验证以解决您遇到的确切问题。 Only when I did that, I was able to find the issue.只有当我这样做时,我才能找到问题所在。

删除了 armv6 支持并重新开始工作

I solved this problem many times with DhilipSiva 's solution.我用DhilipSiva的解决方案多次解决了这个问题。 However, it may not work sometimes.但是,有时它可能不起作用。 If that is the case, consider deleting and re-adding the target.如果是这种情况,请考虑删除并重新添加目标。

I stumbled upon this same problem on several diferent projects, researched a lot on forums and even here on Stack overflow.我在几个不同的项目中偶然发现了同样的问题,在论坛上进行了大量研究,甚至在 Stack Overflow 上也进行了大量研究。 A lot of solutions were given, and some people seemed to get them working, but none of them worked for me.给出了很多解决方案,有些人似乎让他们工作,但没有一个对我有用。 So we tried some pretty obvious course of action, which for some reason we didn't tought about before: I've done a CHMOD -R 777 on the EXACT path indicated by the error message (I copied it directly).所以我们尝试了一些非常明显的行动方案,出于某种原因我们之前没有考虑过:我已经在错误消息指示的 EXACT 路径上执行了 CHMOD -R 777(我直接复制了它)。

Worked like a charm, 100% times!像魅力一样工作,100%!

Hope it helps, guys!希望它有帮助,伙计们!

As Chronos mentiod, the device capabilities might be the reason.正如 Chronos 所说,设备功能可能是原因。 In addition I would say that in my case it was all about the UIRequiresPersistentWiFi key, which (for some unclear reason) didn't let me to install my app on an iPhone4.此外,我会说,在我的情况下,这完全是关于UIRequiresPersistentWiFi密钥,它(出于某种不清楚的原因)不允许我在 iPhone4 上安装我的应用程序。 Hope this helps ones who tried everything else and haven't fixed the problem yet.希望这可以帮助那些尝试过其他所有方法但尚未解决问题的人。

I solve this by going to Targets-> Info -> Required Device capabilities and check id at 0 index if armv7 not in 0 index then remove other things and armv7 set on 0 index and clean app connect device and run.我通过转到目标-> 信息-> 所需的设备功能来解决这个问题,如果 armv7 不在 0 索引中,则检查 0 索引处的 id,然后删除其他内容和设置在 0 索引上的 armv7 并清理应用程序连接设备并运行。

Hope this helps fine!希望这有帮助!

I did these steps:我做了这些步骤:

  1. Delete derived data: rm -rf ~/Library/Developer/Xcode/DerivedData删除派生数据: rm -rf ~/Library/Developer/Xcode/DerivedData
  2. Deep cleaned the project: Shift Key + Option Key + Command Key + letter K key深度清理项目:Shift键+Option键+Command键+字母K键
  3. Quit the project退出项目
  4. Quit XCode退出 XCode
  5. Deleted the app from my device从我的设备中删除了应用程序

When I reopened the Xcode, launched the project, and then launched the app it successively ran on my device当我重新打开 Xcode,启动项目,然后启动它在我的设备上连续运行的应用程序时

For me it was Command Line Tools Go to Xcode -> Preferences -> Locations -> Command Line Tools对我来说是Command Line Tools转到 Xcode -> 首选项 -> 位置 -> 命令行工具

Make sure you select latest Xcode version.确保选择最新的 Xcode 版本。 I selected Xcode 11.0, and everything started working.我选择了 Xcode 11.0,一切都开始工作了。

I get the similar question and has searched via the internet the whole day without solution yet...我得到了类似的问题,并在互联网上搜索了一整天没有解决方案......

Xcode 12, iOS 14.

I'm using a cocoaPods call GCDWebServer , which will open a build-in http service in iOS.我正在使用 cocoaPods 调用GCDWebServer ,它将在 iOS 中打开一个内置的 http 服务。 Now it works fine in simulator and I could open a home page of it in my Mac's browser.现在它在模拟器中运行良好,我可以在我的 Mac 浏览器中打开它的主页。 But I cannot open the home page if running it with real iPhone.但是如果用真正的iPhone运行它,我无法打开主页。 The browser said "Cannot connect to server"浏览器提示“无法连接到服务器”

And in console, everything is same without any errors provided for me.在控制台中,一切都相同,没有为我提供任何错误。 Thus, how could I debug this?因此,我该如何调试呢?

[DEBUG] Did open IPv4 listening socket 3
[DEBUG] Did open IPv6 listening socket 4
[INFO] GCDWebUploader started on port 80 and reachable at http://192.168.1.3/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM