简体   繁体   English

'Executable path is a directory' Xcode 弹出错误

[英]'Executable path is a directory' Xcode popup error

I have an iOS Xcode project with 3 targets - AppTarget, Lib1 and Lib2.我有一个 iOS Xcode 项目,有 3 个目标 - AppTarget、Lib1 和 Lib2。

Hierarchy:等级制度:

  • AppTarget is dependent on Lib1 and Lib2. AppTarget 依赖于 Lib1 和 Lib2。 It has no code (SceneDelegate, AppDelegate etc. is moved to Lib1).它没有代码(SceneDelegate、AppDelegate 等已移至 Lib1)。
  • Lib1 is a static library containing the AppDelegate and SceneDelegate (Lets not get into why they were moved here from the AppTarget). Lib1 是一个包含 AppDelegate 和 SceneDelegate 的 static 库(先不说为什么它们从 AppTarget 移到这里)。
  • Lib2 is a static library, dependent on Lib1. Lib2是一个static库,依赖于Lib1。 It extends the SceneDelegate class usingswift extensions .它使用swift extensions 扩展SceneDelegate class 。

In order to get the above structure, I had to add, remove file references and set dependencies.为了获得上述结构,我不得不添加、删除文件引用并设置依赖项。

When I run the AppTarget, I get the following popup after build succeeds,当我运行 AppTarget 时,构建成功后出现以下弹出窗口, 在此处输入图像描述

Pasting the above error as a text,将上述错误粘贴为文本,

Details

Executable Path is a Directory
Domain: DVTMachOErrorDomain
Code: 5
Recovery Suggestion: /Users/<user_name>/Library/Developer/Xcode/DerivedData/<project_name>-bnytgzvocmpwyuajjxxjivpkymui/Build/Products/Debug-iphonesimulator/<project_name>.app is not a valid path to an executable file.
User Info: {
    DVTErrorCreationDateKey = "2022-11-03 08:04:49 +0000";
}

I'm not sure why this happened.我不确定为什么会这样。 I didn't mess with the default executable path in Xcode->Preferences->Location tab.我没有弄乱 Xcode->Preferences->Location 选项卡中的默认可执行路径。

There's an Apple forum post which describes a similar error (not the same).有一篇Apple 论坛帖子描述了类似的错误(不相同)。 The solution was to check for references of old files, which are not present now.解决方案是检查现在不存在的旧文件的引用。 I have verified the Target->Build Phases->Compile Sources of all 3 targets and things are as expected....Didn't see any 'faint files'.我已经验证了所有 3 个目标的 Target->Build Phases->Compile Sources,一切都符合预期....没有看到任何“微弱文件”。

What am I missing here?我在这里错过了什么? Any help will be greatly appreciated.任何帮助将不胜感激。

I'm using Xcode 14.0.1 and swift 5+.我正在使用 Xcode 14.0.1 和 swift 5+。

One of the reasons for this can be if there are no sources in the app target.原因之一可能是应用程序目标中没有源。 If there is no code, the executable does not get generated as expected.如果没有代码,则不会按预期生成可执行文件。 See if adding a dummy/sample source code works ie Just a swift file with an empty class should also do the trick.查看添加虚拟/示例源代码是否有效,即只需一个带有空 class 的 swift 文件也应该可以解决问题。

What worked for me:对我有用的是:

  1. Delete app from simulator从模拟器中删除应用程序
  2. Delete DerivedData folder -> ~/Xcode/DerivedData删除DerivedData文件夹 -> ~/Xcode/DerivedData
  3. Quit Xcode退出Xcode
  4. Restart computer重启电脑
  5. Launch Xcode, clean project (command + k), clean build folder (shift+command+k)启动Xcode,清理项目 (command + k),清理构建文件夹 (shift+command+k)

From there I was able to run my app target successfully ✅从那里我能够成功运行我的应用目标 ✅

Exclude the arm64 arch when building for the Simulator.为模拟器构建时排除 arm64 arch。 The reason is the Simulator is using X86 based architecture.原因是模拟器使用的是基于 X86 的架构。 When building for a real device, like an iPhone, you must remove the Architecture exclusion.在为真实设备(如 iPhone)构建时,您必须删除架构排除项。 The iPhone is using arm based arch. iPhone 使用基于 arm 的架构。 See the snapshot here在此处查看快照

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

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