dyld: Library not loaded. Reason : no suitable image found - xcode

I've looked at a bunch of answers here and none have fixed my issue.
I have an Xcode workspace with a custom framework and an iOS app project. The project has been working fine until this morning, now it builds but immediately crashes:
dyld: Library not loaded: #rpath/ONCKit.framework/ONCKit
Referenced from: /private/var/mobile/Containers/Bundle/Application/4DF67A3F-6255-4276-8812-8C742A363995/atero_t.app/atero_t
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/4DF67A3F-6255-4276-8812-8C742A363995/atero_t.app/Frameworks/ONCKit.framework/ONCKit: mmap() error 1 at address=0x100118000, size=0x000B8000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/4DF67A3F-6255-4276-8812-8C742A363995/atero_t.app/Frameworks/ONCKit.framework/ONCKit
/private/var/mobile/Containers/Bundle/Application/4DF67A3F-6255-4276-8812-8C742A363995/atero_t.app/Frameworks/ONCKit.framework/ONCKit: mmap() error 1 at address=0x100280000, size=0x000B8000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/4DF67A3F-6255-4276-8812-8C742A363995/atero_t.app/Frameworks/ONCKit.framework/ONCKit
I've been experimenting with build settings all day and I'm just totally lost.

Incase this helps anyone, none of the solutions I kept finding on the web were working for me. Pulled my hair our for 2 days, and tried everything. I revoked in-house cert, new provisioning profile, added files to embedded, etc.
Could not for the life of me figure out what was wrong until I noticed that in Keychain access my Apple WWDR and iOS Distributions certs were being set to "Always Trust" instead of "Use Systems Default". Switched my certs back to "Use Systems Defaults" and everything went back to working as it should. I have no idea why and how this works but it did.

I came across this issue today and resolved it the same way. Revoke and regenerate code signing solves this issue. But to shed some light on the "why" part of it.
Apple went ahead and changed the certificate contents. To be more precise, it added a new "OU" (organizational unit) field under Subject. By revoking and regenerating the code signing, it added the missing field and the problems went away.

It turns out that Xcode cache some device specific stuff which can get mixed up if you are running your apps on multiple devices. The simple fix is to delete Xcode cache. The following command clean it up for you
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Caches/com.apple.dt.Xcode

Just changing the code signing profile fixed the issue. Go to Target. Then selected a different option in General->Signing->Team

Just for any other people that, like me, come across this problem more recently and are wondering where and how exactly to revoke which code signing entity (it's in Preferences > Account):
Everything was working fine for me, too, in the morning. I read somewhere else about rebooting. So, before going through another lengthy signing-identities-provisioning-profiles session, I just restarted my machine. And that fixed it apparently without any further efforts needed.
Swift, Xcode 7.3 on OS X 10.11.4.

Clean Xcode's derived data
Launch Finder > Go > Go To Folder > Paste the line below
~/Library/Developer/Xcode/DerivedData
Now restart Xcode.

Well, in my case, I'm using cocoapods, and from the pod files, change:
target 'CoreMotionExample' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for CoreMotionExample
pod 'Firebase/Analytics'
to
target 'CoreMotionExample' do
# Comment the next line if you don't want to use dynamic frameworks
# use_frameworks!
# Pods for CoreMotionExample
pod 'Firebase/Analytics'
Then things begin to work... I don't know why

my problem was solved by removing "use_frameworks!" and replacing it with "use_modular_headers!" in Podfile and doing pod update and pod install in terminal.
hope this will help you as it did for me after scratching my head for a week in this problem.

Related

Executable Not Found. xxx.app is not a valid path to an executable file

Details
Executable Not Found
Domain: DVTMachOErrorDomain
Code: 5
Recovery Suggestion: /Users/riber/Library/Developer/Xcode/DerivedData/digitalCurrency-hiyiyrokjaydkiagjimlwohehrtu/Build/Products/Debug-iphonesimulator/digitalCurrency.app is not a valid path to an executable file. Please rebuild the project to ensure that all required executables are created. Check your project settings to ensure that a valid executable will be built.
System Information
macOS Version 11.4 (Build 20F71)
Xcode 12.5 (18205) (Build 12E262)
Timestamp: 2021-06-11T16:34:20+08:00
Check if all files are available.
Targets -> Build Phases -> Compile Sources
If you see faint files, then they need to be removed or added.
Under "Build Settings" - "Architectures" check that you don't have "arm64" excluded under "Excluded architectures" for release, as all new iOS devices use this architecture.
I'm also get the same error. Let me share how I fix it.
I write cpp code on vscode.
I deleted a .cpp/.h file that I didn't need anymore a few days ago.
Everything nice and happy when I working on vscode.
".app is not a valid path" appeared when i switched back to the xcode to verification function.
I was confused.
(I don't immediately remember my delete operation a few days ago)
The key isn't the dialog showed "Executable Not Found",
Switch to "Issue Navigator" and drag to the bottom...
Now the ERROR shows up in front of U:
Finally the solution is :
TARGETS -> Select your ‘Target' -> Build Phases -> Compile Sources :
Select the ".cpp" file that had been delete, then "Remove Items" by click the second "-" button in the lower left corner.
I fixed it by adding x86_64 to VALID_ARCHS. Build Setting search "VALID_ARCHS",check the x86_64 is there or not, add and run.It worked with me .
resolve it using pod install.
as Frank said, I also use RN in my app.
I have tried clean derived data & even reboot, still happening
Check the Executable File in the Info(.plist). It should be named the same as your Product in Products
I have this issue on a react native application and I can resolve it reinstalling cocoaPods.
pod install
Inside the ios folder on your react native project.
Check if you have any other info.plist-s added to project.
I had similar issue when I added some pod sources (MKStoreKit) to the project - it had several info plists for different platforms which interfered with original one. Deleting wrong info plists solved the issue.
I have to delete the 'DerivedData' folder:
$ rm -Rf ~/Library/Developer/Xcode/DerivedData
EDIT: I've found a solution...
The problem in my case was because of project configurations and Pods. In the long life of my project the configuration files for the schemes changed and Xcode, using the new build system, did not like.
To fix it, just go to the Project -> Info tab. Under Configurations change the Based on Configuration value of the Targets and set them to None. Please note that I've changed only the Targets.
Now close Xcode and launch pod install from the Terminal.
reopen Xcode and launch your project.
Old answer:
I may have found a workaround to this issue... not a solution but a workaround.
I have to work on a not really recent project that was built using the Legacy System that, as you may know, is deprecated now.
While I was using Xcode 12 everything was fine. Then I installed the Xcode 13 GM and I upgrated the project to the new building system and I started to experience this issue. I have the same problem with any Xcode 13.x version. With the betas I had not, as far as I can remember.
The strange thing is that "sometimes" (I could not reproduce it sorry), the new build system worked... but just for a while.
The building phase succeeds but then, then the app is installed on simulator OR on a real device, I have that annoying message that we know...
This morning I may have find a solution...
In Xcode go to File -> Workspace Settings, keep the Legacy Build System and check the box "Do not show a diagnostic issue about build system deprecation"
Now the app builds and can be installed.
Honestly I don't know it is an Xcode bug or not... maybe it is.
if you are using git, there's huge chance there might be conflict in .pbxproj due to multiple people adding stuffs together. During the resolution xcode might try to recover those 'lost references' it got confused and unable to resolve the once there references. find those 'recovered references' in project explorer and remove them if they are invalid
Had the same issue. I deleted the simulators and added them again.
Please make sure that your runner isn't missing AppDelegate.swift or Runner-Bridging-Header.h file.
In my case, my AppDelegate.swift file and Runner-Bridging-Header.h files were deleted, so I copy and paste both the files in ios>Runner folder again from some other project (usually both of these files are same in all projects, just need to add the code lines for firebase configurations).

Could not read serialized diagnostics file: Invalid File: Invalid diagnostics signature

I'm getting this weird warning. I'm not sure what could cause it. A .dia file extension supposedly indicates a core digraph graphics file. I did not add one and the app has almost no ui at all.
Could not read serialized diagnostics file: error("Invalid diagnostics signature")
It appears to be an internal issue, the following steps seem to reliably resolve it for me.
Installing my uninstalled dependencies (ie: CocoaPods).
Cleaning the build folder.
Removing derived data.
Restarting Xcode
If that doesn't work restarting my computer makes this go away. 🤦
Here's the zsh script line I use (after navigating to the project's folder):
Note: Uses rm -rfs!
rm -rf ~/Library/Caches/CocoaPods; rm -rf Pods; rm -rf ~/Library/Developer/Xcode/DerivedData/*; pod install;
For me this issue occurred after I updated my Xcode to iOS15. The reason behind my issue was some of my swift packages were no longer up to date. Updating all my swift packages solved this issue. To do this simply do
File > Packages > Update to Latest Package Versions.
I also experienced this issue. The reason in my case was lack of storage space on my laptop so make sure to check that too.
Solution for M1 and M2 Macbook
I'm on a 2020 M1 Apple MacBook and none of these solutions worked for me.
The folder where I had the project created in was named 'Client Works' with a space in-between even throughout folder structure.
Previously folder structure: /Users/ABC/Documents/Client Works/AwesomeProject
Change folder structure to: /Users/ABC/Documents/Client_Works/AwesomeProject
Apparently that had an adverse effect on running the pod install properly. I renamed the folder to 'Client_Works' and ran pod install and everything started working.
Check the file and make sure all the document is linked to the project -> Target Memembership
If you're using a third party library, it might be where this warning or error originates. In my case, I had the same error, it was from a third party library not updated for Xcode 13. I had to go to the library on Github to check if they had an update for this error, and they had. Then, I updated the library's swift package. In my case I had to use the exact commit id at which they fixed the error.
I'm quite sure I know the issue and it is severe if you don't use version control. It happened to me twice with working on two different projects, when my disk space was around 7GB free with Xcode 13/13.1. I could not fix it manually, only removing all and cloning the repo again made it compilable again, and freeing disk space of course.
With Xcode 12 I had this issue around 4GB free space, but I could recover at least.
If you have pods in your project then make sure you are opening the .xcworkspace and not the .xcodeproj
When I removed a library from my Podfile I suddenly received a TON of these messages. The usual clean + clear derived data + restart trick unfortunately didn't seem to work for me this time.
Took me a while to figure this one out, but what did work was upgrading from Xcode 13 to Xcode 14. Doing so provided much better error messages! Turns out I needed to import Foundation, UIKit, or another framework in some of my files.

Xcode internal errors when testing with swift

I started having peculiar problems when using XCode.
Whenever I try to write test with swift, XCode shows an internal error and all the code turns white.
This happens even if I remove the #testable annotation from the code.
I tried reinstalling XCode, but this did not help.
The code builds just fine so I don't have a clue where the problem might lie.
I'm unable to properly develop tests this way, my modules are not recognised, I have no error checking or code completion.
Here is a screenshot of how the problem looks:
Would love to get any guidance on this issue...
So I guess for now there is no good solution to this problem.
It seems to be caused by crashes of SourceKit.
Fortunately the problem is not solved (partially) on my end.
I decided to make this answer a compilation of different things to try when experiencing this:
Restart - try restarting both Xcode and the PC
Clean the project (shift-command-K)
Build your code, I noticed that sometimes it occurs when you just have unrelated build errors somewhere in your project - make sure it builds
Delete the DerivedData folder rm -Rf ~/Library/Developer/Xcode/DerivedData/, but you can also delete it from Xcode
Delete the cache rm -Rf ~/Library/Caches/com.apple.dt.Xcode - Currently this seems to help the most
I will edit and add more solutions if I find any

Packaging error when switching to arm64 (arm5 was OK)

I just plugged in a new iPhone 6, created a provisioning profile and then I launched the app I'm developing on the device. It compiled fine, but at linking stage it errored out with:
ProcessProductPackaging
...
error: class '(null)' of input object does not respond to either selector writeToFile:options:error: or writeToFile:atomically
I cannot find any information of what that is. I do not get any specific code reference to relate it to. Did anyone experience this?
Personally I was able to solve this issue by rebuilding the project a second time. I think I was only experiencing it after revoking and requesting a certificate.
Odd for it to jump at me and disappear though.
I just restarted Xcode then the error was disappeared
I've tried turning the "Automatically managed signing" off and on again, then the issue disappeared. Note: rebuilding didn't help for me, cleaning either.
I removed an external library and related code I had and it's now working.
I just changed some provisioning setting and then restarted the xcode afterwards the error was disappeared and archived and then uploaded successfully
Rebuilding the project does the job for me. Actually I was making changes in capabilities while Xcode was building that makes build failed.
The error occurred after I made manual changes to the Xcode .entitlements and Info.plist files: I removed some entries. None of the above mentioned solution attempts worked for me. Every try to create an archive failed.
The solution was to go to Xcode's Capabilities section and switched everything on and off again.
I had the same problem specifically on an App Extension we used for Push Notifications, and I was using Automatically manage signing but it seems the App Groups in capabilities were failing, so I just had to make sure the App Groups were retrieved correctly and this fix it.
Also if you have .entitlements files, and you have App Groups there, make sure they are the same you are using in the capabilities configuration.
Restarted XCode and enabled and disabled to Automatically manage signing

Xcode 4 - Error Starting Executable

I've been working on a project in Xcode 3.2.5 and today I tried migrating it up to Xcode 4.0. It compiles just fine; I can navigate to and execute the .app without a hitch (as expected). The only thing that is screwy is the fact that Xcode cannot launch the application, and displays the following error when it tries:
"Error starting executable. No executable file specified. Use the "file" or "exec-file" command" (image not available)
I've scoured the Project and Xcode settings and have been googling for half the day, but all I can find are dead ends and people bashing other people about breaking Apple NDA. FYI Xcode 4 has been released, and is no longer under NDA.
Should I just start a new project and copy in my source? Sounds wrong to me, but brute force works when brute force works.
Thanks in advance
At a guess, the schemes it set up for you based on your v3 targets and build settings might not be quite right. From the schemes menu, choose to edit the current scheme, then select the Run action from the list and make sure the appropriate exectuable is selected.
I ran into the same issue this question came up so I spent my time identifying the issue, reproducing the issue, narrowing it down and explaining as best I could how to not make it happen - as well as the general frustration that comes with an issue like this (it hit me on 2 different versions of Xcode in 2 weeks).
If you're going to delete my post then at least take the time to try and answer the question as I had tried to do.
Now, on to the reply that actually tells how this issue may be created and how to avoid that.
I JUST had this happen creating an app for iOS. Why? I renamed my target executable.
Just tested this by checking out a new copy of the source and rebuilding.
The app ran fine on my device.
Went in to Xcode 4.2, renamed the target. Ran the app. "Error starting Executable..."
I changed the filename back. Same error.
Cleaned and ran the app again and it launched.
Renamed the app, cleaned and ran it again. Not so much luck.
Don't rename your app by renaming the target.
This is such a stupid limitation. Apple lets you rename your target app, but by doing so, this prevents your app from launching on the device.
EDIT: I haven't checked in any code, but now I can't check out and build and run any app without this happening. How do you get the device/xCode out of this state once you've gotten it in to it?
Even the app now crashes on launch at int retVal = UIApplicationMain(argc, argv, nil, nil);
This is in Xcode 4.2 on Snow Leopard, but I got into the same state with Xcode 3 on another Machine last week.
Edit 2: Rebooted the device, rebooted my Mac. Built and ran in the simulator first, then on the Gen4 iPod touch. It works.
I had this issue when migrating a project from Xcode 4 to 4.1, and it ended up being due to the Target's "Product Name" being different in the debug and release configurations. A holdover from when I changed the name of the product many versions ago. So check that...
I've downgraded Xcode from 4.2 to 4.1 only to encounter an error at build and run on device: "Error starting executable. Don't know how to run ...". I've cleaned the project (Xcode > Project > Clean) and cleaned the build folder (Xcode > Project > (hold option key) Clean Build Folder). After that I had to build again and it built okay on iPod touch 4g running iOS 5.
Well, it sure sounds like a whole family of bugs behind that error message!
I got the error after loading up an Xcode 3 project under 4.2.x for the first time.
None of the above tips worked for me, however what I eventually did was switching from GDB to LLDB.
That fixed it.
It looked like the new path to the executable wasn't properly recognized by GDB (i.e. once locally at PROJECT/build/Debug/... in Xcode3 but now in the usual temp. folder location with Xcode 4 it was still looking for the executable in the build folder relative to the project sources)
I duplicated the target and rename the copied on to different name, I got this error message. What I did is to clean the project, exit Xcode, restart the Xcode, then it can run on my device.

Resources