'Executable path is a directory' Xcode popup error
Asked Answered
M

7

17

I have an iOS Xcode project with 3 targets - AppTarget, Lib1 and Lib2.

Hierarchy:

  • AppTarget is dependent on Lib1 and Lib2. It has no code (SceneDelegate, AppDelegate etc. is moved to Lib1).
  • Lib1 is a static library containing the AppDelegate and SceneDelegate (Lets not get into why they were moved here from the AppTarget).
  • Lib2 is a static library, dependent on Lib1. It extends the SceneDelegate class using swift extensions.

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, enter image description here

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.

There's an Apple forum post which describes a similar error (not the same). 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'.

What am I missing here? Any help will be greatly appreciated.

I'm using Xcode 14.0.1 and swift 5+.

Melt answered 3/11, 2022 at 8:17 Comment(1)
I got the same error after editing the info.plistCorvese
D
1

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 i.e. Just a swift file with an empty class should also do the trick.

Deuno answered 14/11, 2022 at 7:5 Comment(0)
H
6

Exclude the arm64 arch when building for the Simulator. The reason is the Simulator is using X86 based architecture. When building for a real device, like an iPhone, you must remove the Architecture exclusion. The iPhone is using arm based arch. See the snapshot here:

Snapshot

Heelpost answered 30/12, 2022 at 1:29 Comment(0)
U
1

What worked for me:

  1. Delete app from simulator
  2. Delete DerivedData folder -> ~/Xcode/DerivedData
  3. Quit Xcode
  4. Restart computer
  5. Launch Xcode, clean project (command + k), clean build folder (shift+command+k)

From there I was able to run my app target successfully ✅

Undergraduate answered 10/11, 2022 at 0:1 Comment(1)
Thank you for the answer, but this didn't work for me. Adding a dummy file in the AppTarget worked.Melt
D
1

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 i.e. Just a swift file with an empty class should also do the trick.

Deuno answered 14/11, 2022 at 7:5 Comment(0)
Z
0

In my case it was a pretty standard syntax error in the code and the compiler not being able to display correct error message. I suspect the binary could not be built and if it could not be built it could not be built and run. I just started doing the standard comment out code until I could find the problem which was a missing end brace "}". BTW, this is a common issue I run into with SwiftUI. The version of Xcode I was running is that latest as of this writing, 14.3.1.

Zoography answered 4/7, 2023 at 18:19 Comment(0)
B
0

I had the similar issue, I was able to resolve it by running the Emulator with Rosetta.

Here is the steps I followed

Open your project with Xcode, Click on Product menu, Click on Destination, Destination Architectures, and select Show Rosetta Destinations

Product > Destination > Destination Architectures > Show Rosetta Destinations

After the above steps, the Simulator was displayed with Rosetta label in brackets and that solved the problem

Brawley answered 10/10, 2023 at 12:12 Comment(0)
O
0

It might be that in your plist.info file some data is wrong, such as the Bundle identifier, the Bundle name or the Executable file. Try fixing those.

Oleoresin answered 9/6 at 11:39 Comment(0)
P
-1

Delete app from simulator Delete DerivedData folder -> ~/Xcode/DerivedData Quit Xcode Restart computer Launch Xcode, clean project (command + k), clean build folder (shift+command+k) From there I was able to run my app target successfully

Before this Please check the Compile sources in Build Phase if it's not there please add it or add the missing file for compile source. It will work 100%

Partition answered 30/5, 2023 at 6:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.