Compiling swift source files stuck - swift

I have been working on my project when suddenly I have not compiled anymore, it stays waiting in Compile swift source files ... I cleaned the project, the folder, deleted the app and nothing. Is there any way to know what is happening?

Is there any way to know what is happening?
Yes. Go into the Report Navigator which is the one selected by the little speech bubble at the top right of the navigator pane. It will give you a list of all the actions you have performed like builds and tests and runs. The current build will be at the top of the pane. Click on it.
In the main editor you will see some buttons at the top and maybe some messages. Click the All Messages button and it will show you a tree view of the current build. The bottom line will be what the build system is doing now. If it is not changing (i.e. new lines appearing) the build is stuck.
Almost certainly the bottom line will be something like Compile SomeFile.swift. Assuming it is, you can now triage the problem. The Swift compiler usually gets stuck on inferring types for complicated expressions. The way to triage this is to comment out the entire file and then add lines back until the problem reappears. Make sure that you always add enough back so that the file compiles without error.
Obviously, the last line you added back will be the one causing the problem. Usually it's an expression that concatenates strings together with non strings that causes the problem.

The problem is in dictionary [String:Any] when I change the dictionary to [String:String] the problem is resolved . Is very strange..

Related

Vscode terminal collapse build errors or jump from one to the other

When I run a build e.g. of an Angular app in the vscode terminal and I get a bunch of errors, I would like to quickly go through each, fix it and move to the next. Currently I have to scroll through the list without being sure of what has already been fixed or not. I am thinking either a collapsible view (i.e. collapse build errors which have already been fixed) or a way to split/group the errors in sections and move from one to the next would be ideal.
Is there a way or an extension to do this?

Eclipse won't compile SWT file properly after SFTP transfer

I was coding earlier today using Textastic 9 on my iPhone today using files I had downloaded over SFTP. I sent them back to my computer (the whole project transferred to my phone), and now three of the four work. They compile correctly, and the colour coding works perfectly. The last one, however, only colour codes specific keywords and strings. It won't accept variable names and anything from a separate library/file, say org.eclipse.swt.SWT.
Here's a screenshot of that file:
Here's another file that also went through SFTP that's working perfectly:
I'm also getting the error Syntax error on tokens, SimpleName expected on a return; statement. I've also tried pasting the code in Notepad, deleting the file, and pasting it into a new file. That doesn't work.
Thanks to #Ros5292
It turns out the display() method had parameters with incorrect capitalisation. I fixed this, clicked on the Design tab, selected the root method, and it compiles. It still doesn't allow me to use other files, color code, etc.
Thanks to #Ros5292
It turns out the display() method had parameters with incorrect capitalisation. I fixed this, clicked on the Design tab, selected the root method, and it works. The colour coding and stuff were messed up due to a few errors because the file was technically new, and it hadn't compiled properly for the first time ever.

Xcode 9.1 Refactoring not available

The refactoring menu in Xcode 9.1 is completely greyed out. I wanted to extract a method from existing swift code and got the following screen:
Do I have to enabled something special to get access to the new refactoring features?
Try cleaning your Xcode. Also try clearing out derived data and restart Xcode.
Clean Build --> (Command-Option-Shift-K)
Delete DerivedData folder in ~/Library/Developer/Xcode/DerivedData
Refactor option hides if you select version editor.
Thanks #paul
I had to change to the Active Schema to the one that matched the Target Membership of the file I was editing.
In other words:
In Project Navigator, select the file you're editing
Show the Inspectors panel on the right
Show the File Inspector
Observe the Target Membership values and set the Active Schema (at the top, by the Build and Stop buttons) to match.
Select text, right click, select Refactor
Observe all the Refactor options are now enabled.
This happened to me too and I could not find anything on it so...
My first post is born.
Mike T. hit on a small portion above (incomplete syntax).
Nothing is wrong. Xcode is amazing! It seems the Refactor/Extract feature is pretty smart. The option is not available if it does not make sense to extract a method.
It may not make sense to extract a method for many reasons. Xcode disables the feature when it encounters them in the selection. A few that I noticed are:
variable declarations
a solitary print statement
continue statements in the selection but I don't include the for loop container. (i'm impressed)
my guess is that there are a bunch of conditions...
Small thing for me was that the code I was trying to access was inside a closure so when I was selecting it and right clicking to Extract to a Method, it was greyed out. removing self on both instances, I could then select both lines to then extract to method
self?.activityIndicator.stopAnimating()
self?.activityIndicator.removeFromSuperview()
Both lines were inside a closure for a UIAlertAction. So removing self allows you to extract to a method in this case. Then just call self on the extracted method inside the closure and it should work.
self?.hideSpinner() //extracted method name
As other posters have already said, its best to make sure you're able to refactor what you want by selecting the right code.

Tasks in Eclipse not Going Away

I just set up Eclipse for PHP Developers on a new machine, and now I have a problem I haven't experienced before.
Normally, I keep track of short-term work that I want to do by adding TODOs in comments on a file. These show up on the right side of the editing window as little blue rectangles. This helps me find the next thing I need to work on.
That part is working, but when I remove the comment the blue rectangles aren't going away. I have used Eclipse for years and never had this problem before.
Anyone know why this isn't working?
For tasks added in the source file's syntax, you often need to Clean and Build the project again to reprocess the file (those are handled in the relevant compiler). For ones that don't get "compiled", check the General->Editors->Structured Text Editors->Task Tags page and have it try to redetect them from there.

Does Xcode Always Compile from Scratch

I sometimes see that change I made shows up on third or 4th build run. It's as if xcode "cache" old compilation.
How to delete all compiled file and start from scratch
One thing that's particularly frustating is this:
I got a compile warning
for this code:
[self.currentBusiness addCategoriesObject:self.currentCategory];
I know what the problem. The automatically generated core data code do not have
- (void)addDistrictsObject:(District *)value;
- (void)addCategoriesObject:(Category *)value;
on Business.h. The function is defined in Business.m though.
So I added those 2 lines. Guess what, still the same warning. I had this exact same problem several time with no issue. I know the solution. I put the line right there in business.h. Nothing changes.
Yet now I get the same compiler warning even though the method is CLEARLY defined in business.h.
As if xcode do not care about the last change I put.
I am so frustated. I added #import "Business.h" again in my utilities.h. Shouldn't change anything given that "Business.h" is already included through other channel. Guess what, it works.
But then I thought, ah that's the problem. I curiously remove that //#import "Business.h" again so it's back like usual. If that's really the issue then the error should show up again right? Wrong.
The error is gone.
So changes I made do not show results right away. Either the compiler or the precompiler must use some sort of cache.
This is important. There are bugs that are introduced 2-3 builds before that I don't know how to debug. If code changes right after the first build after I make that change I know that something is wrong.
Also that autorestore doesn't seem to work. I create a snapshot, restore the snapshot into another directory and get lots of compile error.
NO, It only compile the file in which any kind of any editing took place.
Xcode does incremental builds. You can do a clean build by going to the Product menu item and select Clean (or press Shift+Cmd+K). That will delete all intermediate files and start from scratch.
Click xcode -> Empty Caches.
Here is a screenshot.