Now I know why people complain about xcode's editing capabilities. I find it impossible to code without touching the mouse for one thing or another and this is very frustrating. Anyway I'm used to Sublime Text so to insert a new indented line after the existing line I simply press Cmd+Return, I can't find a way to do that in xcode. Any suggestions is appreciated as I'm starting to consider appcode but don't really want to do that.
Check out this tutorial -Xcode duplicate line to add custom keyboard shortcuts in Xcode.
Then you can just add a new key-value (of your choosing):
Such as:
Insert New Line Below Current Line: moveToEndOfLine: insertNewline:
in the IDETextKeyBindingSet.plist file.
And then just configure your keybindings to the shortcut you would like (i.e.. shift+Enter, command+Enter)
You can also do this for any of your favourite shortcuts that may have been ingrained into your muscle memory from excessive use of your favourite editor. Good luck :)
Related
When I right click to add a new file (or do File -> New -> File), I don't get a dialogue box asking me which Template I want to use. It just creates a blank file like this:
I tried renaming it to a .swift file and adding in all the necessary code to start off, but two things happen:
First, the autocomplete function is one step behind. So when I've already typed import UIKit and moved on, it starts trying to autocomplete UIKit. And when I've already typed class className: UICollectionViewController {
} and moved on, it starts trying to autcomplete UICollectionViewController
After I manually type in the bare minimum needed to make a swift file into a UICollectionViewController with a colored background, I can't reference it in my other files.
I can only assume this is because of the lack of a template dialogue box, but maybe I'm wrong. Is there any way to toggle this template dialogue box on or off?
This problem is only happening with this particular project since I updated to Xcode 10.1
I can't seem to find anyone else online who's already had this issue. The only similar questions I found online were referring to creating reference folders rather than groups. I didn't find anything regarding the file template dialogue box not showing up.
I fixed this and I'll post the answer in case anyone else comes across this problem.
It was tedious, but I:
Created a new project
Initialized my podfile, added what was in the previous one, and installed it
Opened up the new workspace
Added each file one by one
Maybe there's an easier/quicker way to do it, but after looking through all the settings and not finding anything, I ended up doing this and it worked.
Check that in the left hand pane displaying your project structure you are adding the new file to a folder which comes under your application (identified by a blue Xcode application icon) instead of a general folder as your top level (identified by a blue folder icon). I can't add images yet so please see link.
The old way was to select the Entity, press backspace key.
This no longer works. Instead it crashes Xcode. Tested on a new, empty, default project from Apple's template, with no changes other than creating some Entities and then (trying to) delete them.
Is there another way to achieve this?
Here's what ended up working for me:
Close Xcode (it crashes if you change things while it's open)
Find the project folder, look in there for the "something.xcdatamodeld" thing
It's actually a magic folder, so Alt + RMB = Select ShowPackageContents
Open the relevant datamodel file in TextEdit or similar
...its in a very simplistic XML format, so it's trivial to edit.
Delete the entries, and search/replace for their names and make sure you delete any relationships that pointed to them
I have a question about Xcode (Swift). Sometimes when I write an if statement. Something like this:
if(a == 2){
//do Sth
} else {
//do Sth
}
Xcode throws me an error: "Invalid character in source file"
I know it is no big deal and fixed by clicking on "Fix-it" but I want
to know what is the problem. That doesn't make sense to me...
My Xcode is on 7.2 and I am using Swift - I don't know if this is just a Swift problem.
For me it's the ESC key - it's completely reproducible! If I go to search and hit ESC in the search window I also find the occurrences marked - and can replace those with nothing. But it's not shown even with "Show invisible"!
final solution: Bind ESC keybinding to "Cancel". It's that simple.
I was having this problem. The way I solved it is by 1) copying whatever you have into Sublime Text or another code editor and having a look (you may need to enable viewing hidden characters). Mine had a code in there DC2 which is some sort of ASCII control character. For me it was caused by the fact that I had put the playground into manual execute and bound a keyboard shortcut to it that seemed to be entering that control character every time I executed it using the shortcut. I just changed the shortcut and removed the ASCII characters as I was able to see them in Sublime Text. (The link in the comments to the OP concerning left to right mode made no sense and didn't work for me.)
I encountered this problem when I was using a non-Apple keyboard with my iMac. Probably your case too. They add unnecessary control characters! One way to fix it in Xcode ischoose from the menu Editor>Show Invisibles and see if there are any unwanted characters where the error is being thrown and remove them.
Editor->Show Invisibles did not show the character that was causing a problem for me. No-break-space (u00a0) will be shown as a space with no "dot" indicator. However, that's really hard to see and I completely missed it the first time. Zoom helps.
One way I found to detect invalid characters is to use Visual Studio Code and enable the settings:
"editor.renderControlCharacters": true
"editor.renderWhitespace": "all"
This has the same visibility issue with no-break-space as Xcode, however it does show other special characters.
To make it more obvious and possibly detect more invalid characters, install the extension "ascii-unicode-escape" and follow the instructions.
I don't understand why Xcode allows these invalid characters, inserts them into your source files for no reason, and doesn't even give an option to detect them! I'm trying to write code, not secrets in invisible ink, damnit!! I guess it's less of an issue for compiled code, which will show an error, but not so convenient with shader code.
I'm having the same issue. I found a solution after extensive testing. Hopefully it could save others extensive hours of researching into this terrible Xcode experience.
The problem is I have a FILCO Minila keyboard, which has the 'App' key right next to 'left arrow'. I would accidentally hit 'App' when typing really fast, and it enters a 'DEL'(Data Link Escape, Unicode 0010) invisible character. It could only be seen when copy-pasted to Sublime. It's not even visible under Xcode's own 'Editor -> Show Invisibles'(Talking about good user experience...)
Magically this doesn't happen to Sublime or VSCode, only to Xcode. So no excuses for Xcode I guess?
The fix is to download Karabiner, an advanced keymapper for macOS, and invalidate the 'App' key or map it to something else. Karabiner would also invalidate your keymapping in the system default keyboard config. So you would have to remap stuff like 'cmd', 'alt' if you've customized them. If so, be sure to map both left & right modifier keys in Karabiner, because according to Karabiner's key event viewer, the system default keymap would map left_alt & left_cmd to right_cmd and right_alt... Just annoying as hell...
It took me 2 months to realize this problem and 2 hours to actually find out it's the 'app' key that's the culprit and fix it.
I'm using XCode 10.1.
With Xcode: Xcode does not help even after showing invisibles.
Then you can copy the code to Sublime Text => you will see these invisible characters which are the <0x0f>. Click the image to see in details.
With Sublime Text 3, it works!
=> Then you know where to remove the redundancies. Hope that helps!
Are you using the option ⌥ key for any keyboard shortcuts? This was my issue. It seems combining the option key with other keys can insert hidden characters.
For me, this happened when I used the ⌃+⌥+p shortcut in Xcode to resume the SwiftUI preview canvas. It added a 0x10 character. I discovered this, as other posters have recommended, by pasting the code from Xcode into Sublime Text.
(NB: I should have been using ⌘+⌥+p).
This question already has answers here:
SourceKitService Terminated
(34 answers)
Closed 8 years ago.
I have seen other questions with a similar problem but mine looks a bit more serious. Xcode keeps crashing on me. I have no chance to even edit a single character in my code. It is a very simple playground file with some basic code, nothing fancy. I'm not able to do anything at all in the current state.
When Xcode crashes, I hit reopen and the same thing happens again.
Locate the playground file using the Finder, then right click and select 'Show Package Content'. Next select the swift file, right click and open it using your favorite text editor (which must not be Xcode :)).
Once there, either delete its content or surround your code with comments. In the latter case, you can reopen the playground file in Xcode and selectively uncomment code line by line to know which line(s) cause Xcode to crash.
I've verified that there some recurrent patterns in code that almost always makes Xcode to crash, for example, when I use 2 or more custom operators in the same statement. I don't know if it that happens for all custom operators, or it's my specific implementation - either case, I know that I have to avoid that combination. You should take note when you notice a particular combination of code regularly making Xcode crash, and try to avoid it by splitting into multiply lines when possible.
Here's what I did to resolve it. I did reinstall Xcode a couple of times. It looks stable now but I'm not sure till when it would remain so. Looks like a bug to me. I will file it with Apple
I'm using Xcode on a system that belonged to a former employe and I can't type. There's a weird rectangle text cursor blinking and a blank line at the bottom that responds to my key types in a weird manner. If I press a key the text cursor will just get smaller. There's also the location path of the file I'm currently on, I'd also like that to be removed. Thanks
added numbers in red next to each problem.
I suspect your former employee might have customized Xcode or, more possibly, customized the Macintosh to be non-vanilla (maybe it's a Text Input Entry setting or some internationalization or some third party extension or preference pane).
Try doing this: go to the "Text Editing" preferences within Xcode and toggle a few things to see if you have better luck. If that doesn't work, create a new user on the Macintosh and then launch and run Xcode from that new user account.
XVim.xcplugin <-- that was the file causing all of this. After deletion and relunch everything is back to normal. You can find more information about it here: https://github.com/WarWithinMe/xVim
This issue is composed by XVim.xcpluginxc. By deleting this we get free from this issue. For this issue. Please follow these steps.
1.Open the terminal.
2.Type "find ~/ XVim.xcpluginxc". This will list your entire system with this particular file/folder name.
3.From that list copy that particular path having this folder.
4.Type "rm -Rf path that you copied earlier".
5.Press "Enter".
6.type "exit".
Finally close the Terminal & Restart the Xcode.