skip to Main Content

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+.

3

Answers


  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 ✅

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
  3. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search