iOS模拟器:无法进行硬链接复制。我的文件系统路径有误?

17

我正在使用 Xcode 版本 6.1 (6A1052d)。

我试图在模拟器上启动一个应用程序。

第一次启动总是很顺利的。如果我想再次启动,就会出现错误(请参见下面的日志)。然后在 iOS 模拟器中,“重置内容和设置”,我就可以再次成功启动。

根据错误日志,我认为这一定与路径错误有关。问题是我对 Mac 文件系统和路径链接不熟悉,所以非常需要您的帮助。

编辑: 以下是 info.plist.xml(由 LibGDX 生成,如果有影响)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>${app.name}</string>
    <key>CFBundleExecutable</key>
    <string>${app.executable}</string>
    <key>CFBundleIdentifier</key>
    <string>${app.id}</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${app.name}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>${app.version}</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>${app.build}</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    <key>UIStatusBarHidden</key>
    <true/>
    <key>UIDeviceFamily</key>
    <array>
        <integer>1</integer>
        <integer>2</integer>
    </array>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
        <string>opengles-2</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <!-- <string>UIInterfaceOrientationPortrait</string> -->
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>CFBundleIcons</key>
    <dict>
        <key>CFBundlePrimaryIcon</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>Icon</string>
                <string>Icon-72</string>
            </array>
        </dict>
    </dict>
</dict>
</plist>

我的robovm.xml文件:

app.version=1.0
app.id=<my package name>.IOSLauncher
app.mainclass=<my package name>.IOSLauncher
app.executable=IOSLauncher
app.build=1
app.name=<my app name>

我已经尝试通过Jeremy的建议,在虚拟设备文件夹中的system.log中更精确地识别错误。在崩溃发生时,system.log有很多条目,所以我可能错过了一些内容... 无论如何,我找到了以下潜在错误:

Nov 28 09:03:44 As-MacBook-Pro installd[668]: 0x10e3d0000 createDictFromFile: open failed for /Users/<myname>/Library/Developer/CoreSimulator/Devices/D1C6E4CE-ABF3-4621-B811-913F1705CBE0/data/Containers/Bundle/Application/CA2B6D8C-1A62-4DA6-8433-AA4678D009E1/ManifestCache.plist : No such file or directory

Nov 28 09:03:44 As-MacBook-Pro installd[668]: 0x10e4d6000 writeDictToFile: ==== Successfully wrote Manifest cache to /Users/<myname>/Library/Developer/CoreSimulator/Devices/D1C6E4CE-ABF3-4621-B811-913F1705CBE0/data/Library/Caches/com.apple.mobile.installd.staging/temp.gCGKCY/extracted/ManifestCache.plist

Nov 28 09:03:44 As-MacBook-Pro installd[668]: 0x10e3d0000 validate_stream: Got manifest for version "1 1.0", but expected version "1 "

Nov 28 09:03:44 As-MacBook-Pro installd[668]: 0x10e3d0000 hardlink_copy_hierarchy: Failed to open manifest /Users/<myname>/Library/Developer/CoreSimulator/Devices/D1C6E4CE-ABF3-4621-B811-913F1705CBE0/data/Library/Caches/com.apple.mobile.installd.staging/temp.gCGKCY/extracted/com.apple.deltainstallcommands.<my app.id>

来自Eclipse控制台的原始崩溃日志(设备名称文件夹因为我在多个虚拟设备上测试,所以不同,但错误始终相同)。
11/27/14 9:58:17 AM: [ERROR] Session could not be started: 
Error Domain=LaunchServicesError 
Code=0 "Unable to run app in Simulator" UserInfo=0x7fc8eb900d70 
{Error=PackagePatchFailed, ErrorDescription=Could not hardlink copy 
/Users/<myname>/Library/Developer/CoreSimulator/Devices/055A18BC-73B5-4EA6-A872-488FA69F4750/data/Containers/Bundle/Application/CCF8C472-C48F-41D7-8885-E83830256EE3/IOSLauncher.app 
to 
/Users/<myname>/Library/Developer/CoreSimulator/Devices/055A18BC-73B5-4EA6-A872-488FA69F4750/data/Library/Caches/com.apple.mobile.installd.staging/temp.TsGEn1/extracted/Payload/IOSLauncher.app 
with manifest 
/Users/<myname>/Library/Developer/CoreSimulator/Devices/055A18BC-73B5-4EA6-A872-488FA69F4750/data/Library/Caches/com.apple.mobile.installd.staging/temp.TsGEn1/extracted/com.apple.deltainstallcommands.<pathtomyappexec>, 
NSLocalizedFailureReason=An error was encountered while running 
(Domain = LaunchServicesError, Code = 0), 
NSUnderlyingError=0x7fc8ebb1a500 "The operation couldn’t be completed. 
(LaunchServicesError error 0.)", 
NSLocalizedDescription=Unable to run app in Simulator}

请提供更多信息。具体来说,请查看~/Library/Logs/CoreSimulator/055A18BC-73B5-4EA6-A872-488FA69F4750/system.log,以获取可能描述正在触发此问题的故障错误消息。请在出现错误的时间周围寻找来自installd的消息。 - Jeremy Huddleston Sequoia
你好 @JeremyHuddlestonSequoia,感谢你的回答。我看过你在另一个问题中的回答,它确实接近我的问题。但是我无法在那个问题中提供更多有关我的错误的细节,所以我在这里编辑了我的问题。我可能已经找到了错误的可能来源,希望我挑选了正确的行(日志很长,即使在崩溃时也是如此)。 - Don
您IP地址为143.198.54.68,由于运营成本限制,当前对于免费用户的使用频率限制为每个IP每72小时10次对话,如需解除限制,请点击左下角设置图标按钮(手机用户先点击左上角菜单按钮)。 - Don
是的,这就是如何将设备恢复到默认状态。您也可以像在真实设备上一样删除应用程序(长按主屏幕,然后点击x),或者使用另一篇文章中描述的simctl。 - Jeremy Huddleston Sequoia
嘿@JeremyHuddlestonSequoia,我已经附上了info.plist文件。 - Don
显示剩余4条评论
14个回答

51

在“常规”选项卡上只使用“版本”而将“构建”字段留空时,我遇到了该错误。通过设置一个构建值并重新安装应用程序,错误已消失。


4
需要删除并重新运行。 - Preetam Jadakar
我在Xcode 9中遇到了这个错误,这个答案对我有用! - dev
我对于“Bundle版本”,使用了$(CURRENT_PROJECT_VERSION)。 - cahn

11

我认为,如果你在每个构建之间更改应用程序的 Info.plist(例如修订 CFBundleVersion 或类似内容),这个问题会变得更加严重。如果你这样做了,你应该在每次启动时从模拟器中删除应用程序(通过 SpringBoard 或使用 simctl),或者只擦除模拟器设备。

这个问题在最近的 iOS 模拟器 8.2 beta 版本中已经解决,这些版本包含在 Xcode 6.2 beta 中。我认为这个问题在 beta2 或 beta3 中得到了解决,但我不能确定。


我有一个脚本来递增plist中的构建号。但是我在编译步骤之后意外地执行了该脚本...谢谢。 - Paul Stevenson

6

找到 InfoPlist.strings 文件。 并检查 "CFBundleShortVersionString" 的版本是否与 Info.plist 中应用程序的版本相符合。

InfoPlist.strings


你救了我的命!!!这就是我寻找已久的答案!!谢谢! - tleveque
我必须取消链接 InfoPlist.strings。 - Peter Lapisu

6
这确实是由于应用程序Info.plist文件中某些键的顺序触发,并且似乎是iOS模拟器的installd进程中存在的错误。 installd有时似乎无法读取CFBundleShortVersionString和CFBundleVersion值。 我发现,如果RoboVM确保始终首先移动这些值到它写出的Info.plist中,我们就可以防止触发installd中的错误。 我们现在已经在RoboVM中实现了此解决方法(请参见问题#771),并且它将在下一个夜间构建(20150222版本)和下一个版本中提供。
可以从http://download.robovm.org下载RoboVM的夜间构建。 要安装Eclipse插件的夜间构建,请使用更新站点。
http://download.robovm.org/nightlies/eclipse/site.xml

RoboVM Maven和Gradle插件的每夜快照版本已推送到Maven Central。


1
你好 @ntherning,感谢你的回答。所以如果我理解正确,我应该手动将 info.plist 中的 CFBundleShortVersionString 和 CFBundleVersion 上移并进行测试? - Don
是的,请尝试一下。将这两个键(当然还有它们的值)移动到 Info.plist.xml 文件的顶部。从 RoboVM 的下一个版本开始,您就不必再这样做了。此外,您应该最后执行“重置内容和设置”,以摆脱任何已安装的错误应用程序。 - ntherning
它完美地工作了。感谢@ntherning。能够简单重建而不是每次都重置模拟器真是一大快事。生产力已经升级到3级 :) - Don

5

我在使用Xcode 8.2.1时遇到了相同的错误。在Info.plist中更改项目顺序在我的情况下没有帮助,但是它确实引导我找到了解决方案。我已将CFBundleShortVersionString和CFBundleVersion从3.0.0更改为3.0.1,但我忘记在本地化和基础InfoPlist.strings文件中也更改为3.0.1。这样做可以解决问题。


2

选项-1: 1.点击左侧边栏上的项目名称,进入“通用设置”。 2.将Bundle Identifier名称更改为“com.release.ABC”(ABC可以替换为您的APP名称)。 3.现在运行它并享受。

选项-2: 1.打开模拟器。 2.删除用户安装的所有应用程序。 3.运行您的应用程序并享受。 注:缺点是每次清理模拟器后,您需要重新加载您的应用程序。


1

1
我也长期存在这个问题。我尝试了大部分解决方案,我相信它们对某些人有效,但对我无效... 然后我注意到如果你进入项目设置 -> 构建阶段 -> 嵌入框架,有一个标记为仅在安装时复制的选项... 我打了勾,问题就解决了。

0

我在一个多目标项目中遇到了这个问题。在复制目标后,我忘记更改“产品包标识符”。一旦我将此参数更改为唯一值(请参见“构建设置”选项卡),错误就消失了。

编辑

更改“产品包标识符”后,您必须从模拟器中删除所有内容和设置,并在Xcode中清除构建文件夹(Cmd + Shift + K)。

我正在使用Xcode 10.1。


0

当我复制一个目标并忘记将新目标添加到Pods文件中时,就会发生这种情况。

所以我的解决方法是编辑podfile以包括新目标,并运行'pod install'。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接