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

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.

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

Xcode Error: "An internal error occured. Editing functionality may be limited" For all projects

I'm getting the following error:
An internal error occured. Editing functionality may be limited
for all my projects I open with xcode. I've tried the solutions that I've read on here, the only thing I haven't done is restart my Mac, as I am working with macincloud. The error is there for all my old projects. How can I fix this when I'm using macincloud?
This happened to me when I had two versions of Xcode running on the same machine.
The Xcode-select value could be pointing to the wrong version. (For example, if you're running Xcode 9, but it's pointing to an Xcode 8 version that's also installed on your machine, you might run into this)
If this is your issue, then try changing the value to the right directory by using something like this:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
This also, however, happens if files have incorrect permissions or a library/developer file has been manually deleted.
If you have only one version of Xcode installed, try deleting the derived data of the project and force-closing + restarting Xcode, or even reinstalling the IDE. More on deleting derived data here.
Let me know if any of this was helpful!
I recommend shutting down the app and then restarting. If this doesn't work, then it could be that you have to update XCode. You could also use an alternative to MacinCloud, like XCodeClub.com
Hope this helps!
I had this similar issue in my Mac and the issue has been resolved by my self. I had tried all the answers and also some from other links.
At last what I did is, I checked the storyboard that I have been working as, source code. Then removed the last view controller (Scene) that I had created and been working on from that storyboard file. Then cleaned and removed derived data. Restarted Xcode. And then it was looking fyn. I think there were some issues with the constraints on a storyboard that had around 8 scenes, so that Xcode LLVM couldn't load it correctly. Thanks for the response.

Build fails with "Command failed with a nonzero exit code"

When I try to build my app with Xcode, an error interrupts the build process:
Command CompileStoryboard failed with a nonzero exit code
Sometimes, it shows this error instead:
Command CompileSwift failed with a nonzero exit code
I have New Build System turned on.
What can I do to fix this?
Closing Xcode for me didn't have an effect. Instead, I cleaned the project using CommandShiftK.
I also found another reason: I had a storyboard reference to another storyboard which I had removed. The quick fix was deleting this.
I also facing same issue in xcode 10 and tried all the solutions provided but nothing working.
Then I deleted all the files and folders of the following folder :
~/Library/Developer/Xcode/DerivedData
and it worked like a charm.
When you stop building a project when the compiler is in the middle of something "important", this error could appear. In that case, building the project again and letting it finish normally makes this error disappear.
This is a known issue with Swift 4.2 and Xcode 10. I found an article here that fixed it for me: https://github.com/Yummypets/YPImagePicker/issues/236
In short, go to your projects build settings, and add a user defined setting named SWIFT_ENABLE_BATCH_MODE and set its value to NO.
Previously, I tried each of the methods suggested here (rebuild, exit Xcode, clean and rebuild, purge Derived Data files). None of them worked.
Once I added the user define build setting per the article, Swift then told me the true error. In my case, it was a missing }, but it could be any number of problems.
I encountered this error when I was upgrading my project from Swift 4 to 5.
I first updated all my pods to their latest versions. When I built, some pods showed this error.
The following steps resolved this issue for me:
Removed all pods from Podfile
Executed pod install to remove all installed pods
Executed pod deintegrate to remove support for CocoaPods
Deleted Podfile.lock and .xcworkspace from my project so no
CocoaPods anymore
Now my project is a pure Xcode project
Opened my project from the regular .xcodeproj file
Changed Swift Version of my project to Swift 5
Cleaned the project (cmd+shift+K)
Quitted Xcode
Restored all pods to my Podfile
Executed pod install to reintegrate CocoaPods and add my pods
Opened the project from the .xcworkspace file
Cleaned and rebuilt
Some old pods that were still using Swift 4.0
(SlideMenuControllerSwift in my case) were set to Swift 5.0, caused
many build errors in their code. I corrected it back to Swift 4.0
by opening the Pods project and selecting its target.
Cleaned again, rebuilt.
Now I have only errors in my own project code related with difference in Swift version I made. My job now is to fix them.
This error happened to me when I forgot to change entity Properties before creating NSManagedObject subclass. Solved by:
delete Entity+CoreDataClass.swift and Entity+CoreDataProperties.swift.
under "class" of the entity model inspector, change "module" to Current Product Module and "codegen" to Manual/None.
recreate the NSManagedObject.
I had the error Command LinkStoryboards failed with a nonzero exit code, and found that I was using a reference to a non-existent storyboard. I had recently changed the name of a storyboard file, so changing the reference from the 'old' name to the 'new' name solved it for me.
You may not have exactly the same error as me, but an easy way to find a more detailed explanation of the error is to:
Show the issue navigator (while the build time error is showing)
Click the error:
Then, you should see more about your error:
I hope this helps. Please, I am aware that I am answering from experience of a different error than this question was asked about, but I believe this advice should help you conquer similar problems!
For me cleaning the project (Command + Shift + K) and restarting xCode worked for me
If you have multiple targets, where two or more targets have files with the same name, check the target membership of those files in Files inspector. The error occurs when multiple instances of the equally named file have set the target membership for the same target.
Since this issue looks to have dozens of possible solutions and the root cause could be very vague, I'll throw my situation into the ring. Half of my pods were failing with some sort of CompileSwiftSource failure, but only on archive. I was still able to build for device and simulator just fine. I tried a lot (if not all) of the solutions suggested here with no luck. One of the pods had a slightly different error before the CompileSwiftSource error so I went to updating and trying to fix that single pod. It was the Cache library for iOS which hadn't been updated in a while. There was a fork that resolved the issue with updating to Xcode 10.2 that I was able to update to and after that, all of the other issues took care of themselves. So look for a single outlier in your pods if you're getting a bunch of them erroring out and start there.
Switching to the legacy build system fixed the issue for me
In my case, I was clean build folder then restart my mac then it's work.
I had the JSONwebtoken pod installed and that was causing issues. I needed to delete the CommonCrypto folder that is in the JSONWebtoken pod folder. Here is a ->link<- explaining the issue. This started happening in Xcode 10.
In my case it was about having a file named Location. after some digging I find out that it was about having two file with the same name (weird). Cause I don't, however, it's been solved by removing the file and adding another file with a different name.
filenames are used to distinguish private declarations with the same name
This can also occur when you have two swift files with the same name. For example, two ContentView.swift files
In my case, I used too complicated initializations inside a class extension. It suddenly broke my build.
class MyClass { }
extension MyClass {
static var var1 = "", var2 = "", var3 = "", var4 = "", ...., var20 = ""
}
Resolved:
class MyClass { }
extension MyClass {
static var var1 = "",
static var var2 = "",
static var var3 = ""
static var var4 = "", ....,
static var var20 = ""
}
In my case it was empty assets catalog, when I delete it everything was fine again.
Command CompileSwift failed with a nonzero exit code
This error happens when you are migrating your code from Xcode 9 to Xcode 10+. It due to any class name is conflicting with existing apple classes. For Example: State, Event etc.
So first change the class/structure name if any existing in your code like "State" to "StateDetail"
If Info.plist is added in target, remove tick mark from it so it will not copy app bundle (Latest Xcode10 security reason).
Select Info.plist file and uncheck under "Target Membership" in right side Identity inspector
And build code again!!!
In my case, the problem was that I assigned a .swift class to the viewController in the storyboard, while the project was Objective C.
I tried a lot of the options discussed here.
Delete and reinstall pods
Clean Build Folder
Delete Derived Data
Add SWIFT_ENABLE_BATCH_MODE and set its value to NO
Restarting Xcode and Recompiling
Restarting iMac and Recompiling
set Compilation Mode to Incremental
Changed build settings: SWIFT_COMPILATION_MODE = singlefile and SWIFT_OPTIMIZATION_LEVEL = "-O"
Nothing worked. I'm using Xcode Version 11.0 beta (11M336w).
Finally I downloaded a fresh copy and replaced the one I had previously installed. It was the same exact version. That did the trick.
I got this error while trying to run my unit tests in a submodule. What I have done is:
Change the simulator => Clean the project => Build the project => Run unit tests.
After this, my unit tests ran without any issue.
I have the issue like that and my solution is change a little thing in Build Settings:
SWIFT_COMPILATION_MODE = singlefile;
SWIFT_OPTIMIZATION_LEVEL = "-O";
it work to me
Alright, I was having the same problem with Xcode 10. I usually use a storyboard for every view, that way if someone is helping it's easier to fold code in. I needed to make one of the view on one storyboard the initial view Controller.
In my case it was renaming a file to an existing file in other folder(Group) by mistake, just rename it to what it was then the error disappeared
The targets should be specified with related data such as appicon
For me the problem was that on my Podfile I didn't put use_frameworks!. I just uncomment that line, run pod install on the terminal again. And it got fixed.
It was commented since the app was entirely made on Objective-C. Since the app now uses Swift I had to make that change on the Podfile
I had the same error Restarting Xcode and Recompiling Fixed the issue for me.
I got the same error when linking separate storyboards. The error, "Command CompileSwiftSources failed with a nonzero exit code." is shown because I simply forgot to set the view controller inside the second storyboard that I am linking as 'an initial view controller'.
In my use case I had used the function "Refactor to Storyboard" in Xcode 13. It created the new refactored story board fine but failed to add it to bundle resources.
So my fix was to:
Select the target project in Xcode Navigator
Choose the build phases tab
Expand Copy Bundled Resources to see if new storyboard was added. If not, just add it to the list and rebuild.
My app was having Notification Service Extension, and was using Xcode 11. The Extension doesn't have anything to do with pods.
After 1-2 years, I have taken that project into my new m1 chip mac with Xcode 13. But the compilation was failing and showing me the error in pods.
I tried to remove and add all pods, tried clean etc all possible available answers available on internet. Almost spent 4-5 hours to make it run, but nothing worked.
Final Solution that worked:
I removed, notification service extension from the project, its target etc too. And then tried to run the app. Amazingly it worked. After that, i added that extension again(by creating new extension and putting the same code again), and everything is working perfectly fine.
I am still surprised that, was that issue with extension or with pods. But finally it worked for me.
Hopefully, this answer might resolve someone's issue and you can save enough time.

Unable to do refactoring on my Swift file in Xcode 9

I am using Xcode 9 and I am trying to do Refactoring on my Swift based file but every time I am getting below error:
Refactoring engine ranges didn't match initial ranges
Why isn't it matching the initial range?
Workaround: Restart Xcode.
This has not been resolved yet as of January 2018 (Xcode 9.2).
Build your project (Command ⌘ + B) and it will fix the error. After doing it, I could rename my file successfully.
I have Xcode's project created using Xcode8 long time ago. For some reason I have to upgrade to Xcode9 (9.4.1 exactly). Then I experienced that error only on that old project, not the new one created using Xcode9.
So i think that error related to project issue. So I decided to compare the settings between old and new one. There are some differences, and after several tries, by changing Optimization Level for Debug solved refactor issue.
In project editor, select your Target, Build Settings
Set Optimization Level (Debug) = No optimization [-Onone]
Delete DerivedData folder related to your project in /Users/YourMacUsername/Library/Developer/Xcode/DerivedData
Clean project shiftcommandk.
Build project commandb.
Update For some reason, it's not happening for me anymore. I noticed also whenever I don't let indexing finishes before trying to start doing a refactor or tap on refactor many times, still see the error, but not permanent anymore.
I asked an engineer at WWDC 2018 about this issue. This issue was happening for me in only one project in my workspace. Other projects in the same workspace works fine. At the moment, there's no solution to this issue. If you want to help Apple to fix this, you can close your Xcode and run following command in terminal:
SOURCEKIT_SERVICE_LOG=3 /Applications/Xcode.app/Contents/MacOS/Xcode 2>&1 | tee /tmp/sk-log.txt
And then try to reproduce the issue and send them the log file (/tmp/sk-log.txt) so they can narrow it down and hopefully fix it in future Xcode versions.
Notice This is project related issue and won't be fixed with OS updates, Xcode updates, or any number of restarting applications, at least the one that I'm having.
I have the same issue in Xcode 10.3.
Refactoring didn't work when I right clicked → refactor → rename on the class name in the class definition. However it did work when I did the same somewhere in code where I use that class.
Product -> Clean Build Folder -> Quit Xcode -> Reopen Project -> Build
I update to Xcode 10 and finally refactoring now it works again after a year without refactoring
I am on Mac M1 and using Xcode Version 12.5 beta 3.
I was facing the same issue when trying to rename ViewController.
Before renaming it, I moved it to a new group, and my code was in a running state. Not sure if that was the reason for the issue.
But I restarted the Xcode and the issue was resolved for me.
I was experiencing the exact same issue. It turned out that I had my build configuration set to Release mode. Changing it to Debug, cleaning build folder and recompiling fixed the issue for me.
Remove DerivedData
This worked for me for this error and other kind of refactoring errors.
Close Xcode
Remove DerivedData:
rm -rf ~/Library/Developer/Xcode/DerivedData
I experienced this on a Mac M1, using Xcode Version 14.1 (14B47b).
This helped:
Clean project: shift-command-k.
Build project: command-b.

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

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.

Resources