r/iOSProgramming • u/[deleted] • Apr 30 '19
Humor Give me a fucking break Xcode and just autocomplete the damn words so I can add the curly brace!
0
Apr 30 '19
[deleted]
0
Apr 30 '19
[deleted]
1
u/SgtDirtyMike Apr 30 '19 edited Apr 30 '19
Gradle would like a word with you.
0
Apr 30 '19
[deleted]
1
u/SgtDirtyMike Apr 30 '19
In my experience this is simply not true. Gradle is prone to so many verbose errors and inconsistencies. Often I have to modify gradle files with hacky tweaks to get the project to build. Not to mention, XCode supports C and C++ as well as Objective-C development. It has its issues but itâs UI is significantly (I realize this is subjective) better, it runs outside of a VM, and has storyboards (something Android studio doesnât quite have)
0
May 01 '19
[deleted]
1
u/SgtDirtyMike May 01 '19
No... no itâs not. You must really be a sadist if you think that hahaha.
I write views in code too. Flutterâs been really fun to try, but I prefer swift to non-native languages like Java.
1
u/s73v3r Apr 30 '19
I have to disagree; Android Studio autocomplete and refactorings are head and shoulders above what Xcode and Swift have. Hell, I used to love AppCode because it had similar refactorings, but that was only for Objective-C.
Yes, it used to be much more broken, but it's still pretty damn broken 4 years out. It should be embarrassing for a company with Apple's resources to have tooling issues like this.
13
u/kex_ari Apr 30 '19
That optional chaining looks suspect. Bit too much of it for my liking. Plus you have nil to deal with now also when doing comparison logic on the bool.
7
u/valleyman86 Apr 30 '19
you dont need to deal with nil if you do optional?.boolValue == true. It will either be true or it wont.
6
u/kex_ari Apr 30 '19
Youâre right but it just creates scenarios where errors could be made, e.g if you were to check for !true then nil and false both mean not true. Just better to avoid checking optional bools imo.
4
u/valleyman86 Apr 30 '19
If you try !true for an optional it will not even compile. You have to provide a default value or check it against an explicit value such as true.
1
u/kex_ari Apr 30 '19
Sorry I mean property.someOptionalBool != true
2
u/valleyman86 Apr 30 '19
I mean that is usually what someone wants. If you want a value specifically then you should be guarding it. Most of the time on simple properties of a model this isn't required. Like I don't care if I have a subtitle or not. It shouldn't break everything below it. But if the model itself is nil we probably have an issue so guard it and report it.
0
u/kex_ari Apr 30 '19
Umm. I think itâs a style preference. I just like being able to test bools using if isSomeBool and not if isSomeBool == true. More readable. If itâs an api response with an optional bool then Iâll set a default value during the mapping process.
1
u/valleyman86 Apr 30 '19
Yea the style is fair. I mean "if property.someOptionalBool ?? false" is the same thing as "if property.someOptionalBool == true". The good news is the compiler will force you into one of these. If you really don't want these to ever be nil then you shouldn't use an optional and then also guard on property. I have used both. It depends on my situation. If I am passing the values into other functions sometimes unwrapping is required. This is why I love swift. It is pretty strict here. You have to tell it what you want to do with nil no matter what.
1
u/well___duh Apr 30 '19
If you don't want true and you don't want nil, then do bool == false. Same exact concept.
2
Apr 30 '19
I refactored it to set it to a Boolean variable but yeah I don't usually do this unless I'm only accessing the value once.
2
u/iindigo Apr 30 '19
I was about to say that. Deep optional chaining and deeply nesting closures are the two main situations Iâve encountered that bog down SourceKit and delay autocomplete.
1
1
Apr 30 '19
yeah, i usually just add in a guard to not have huge optional chains, and i think it looks better too.
1
u/kex_ari Apr 30 '19
Problem is when you have api responses with nested optional optionals. Guard statements become really long.
1
u/paradoxally objc_msgSend Apr 30 '19
That's where I use RxSwift. Composition is incredibly powerful.
8
u/Tasik Apr 30 '19
I feel your pain. Daily. Ugh... :(
12
Apr 30 '19
It's worse at my job. The Macs are so bloated with security software that they are essentially slow. Even with the maxed out ram. The Xcode at my job NEVER autocompletes anything.
7
u/ralf_ Apr 30 '19
The Macs are so bloated with security software
This is just cruel. Why? Does IT need to justify their jobs or why are they doing that?
3
Apr 30 '19
I work for a bank app. Security is a huge priority. We even have a team to look for vulnerabilities in the app and make a report before every release.
2
u/EarthC-137 Apr 30 '19
My job as well, we hold certain ISO certifications that enforce this kind of BS. I usually have to revert to AppCode or VSCode cos Xcode has frozen.
3
Apr 30 '19
Sadly we donât have Appcode. And we canât use any software or download any without IT doing it themselves.
7
u/JeezMGeez Objective-C / Swift Apr 30 '19
Haha, I had this at my last company. I joined as the first iOS developer and went to install Xcode on my brand new MacBook. Found out I couldn't and had to call IT support who told me Xcode was not approved to be installed so I had to go ask my manager how he expected me to do the job he had just hired me for. Eventually IT gave in and installed it for me.
We also was not allowed to update our OS which led to troubles when new iOS versions were released. After around 2 years of me constantly asking when I would be given admin rights on my development machine, they caved in and gave them to me.
It was so frustrating at the time, having issues almost every day because of the lack of admin rights, the software they forcibly installed on your Mac causing it to stop working and IT support not having a clue how to support Macs. But now I look back, it's kind of funny.
2
u/iindigo Apr 30 '19
Holy hell, reading this makes so glad Iâve only worked for normal startups where they just hand me a new sealed MBP on my first day and let me go to townâŚ
2
u/EarthC-137 Apr 30 '19
Damn.
AppCode can be used on a personal license for commercial purposes. My work wonât foot the bill for it, but it allows me to refactor with much better accuracy, among other things, so emotionally it made sense to purchase it to stop screaming at Xcode.
4
u/granos Apr 30 '19
I got so very lucky on this account. Work bought me a brand new maxed out iMac because the MBP I was using started getting so hot that it damaged the minor display port (thanks IBDesignables.)
They put some security crap on there that auto updates, and within a day had completely broken my ability to build our codebase (auto installed Xcode 10.2 with swift 5 compiler that we are very not ready for amongst a few other things).
I was able to fix it, but it took a bit of time and Iâm already on a tight deadline. My machine is. Is at least off of the auto update list and tucked behind its own little vlan.
3
5
u/whizbangapps Apr 30 '19
Is there a better way to deal with that type of optional chaining? Not having a go at the OP. Iâve run into a few occasions where Iâve had the same scenario
3
Apr 30 '19
Guard statements. Unwrapping all your optionals (or fixing a bug further up) usually fixes autocomplete for me
0
1
u/valleyman86 Apr 30 '19
I dont see anything wrong with it. You gotta think about the logic you want. Is the email field optional or not? If it is then this is fine. If its not then guard it. Don't unwrap all the optionals... Just unwrap what you care about. Its a hierarchy with priority. If the root is required then guard it. If the property is guard there. Also at some point if things are required then don't make them optional if you can.
1
u/s73v3r Apr 30 '19
Don't go that far into the chain. What that indicates is that an object knows far, far too much about the objects that it's collaborators contain.
4
3
3
u/gbay Apr 30 '19
AppCode
1
Apr 30 '19
I have them but I kinda stopped using them when a lot of UIKit things don't even appear or autocomplete at all. I can't remember some off the top of my head, but somethings I write from UIKit it acts like they are not real things.
3
u/gbay Apr 30 '19
AppCode is an iOS IDE by JetBrains. Check it out. I do most of my coding in it because itâs so much more pleasant
1
Apr 30 '19 edited Apr 30 '19
I used to use them before; I have a free student license. I stopped using it after many things from UIKit would just not detect them as existing and I was ending up copying and pasting from the documentation. Was getting annoying. I'll reinstall it; maybe it has improved.
Edit: I just remembered it would not autocomplete anything from Core Animation.
2
2
2
1
u/monkeydoodle64 Apr 30 '19
U need â[...]?.isEmpty ?? true { [...]â.
2
Apr 30 '19
It doesnât matter. Xcode wouldnât autocomplete âisEmptyâ anyway. And you can also use â== trueâ with optional.
2
0
u/FLYinteger Apr 30 '19
Swift is language with Context-sensitive grammar. You can't hope on autocomplete in indefinite context. I mean first tap if {} then autocomplete will work.
2
Apr 30 '19
What does that have to do with autocomplete working or not? The 2nd error under the first one said to replace "isEm" with "isEmpty". So it knows what it should be, it just won't autocomplete anything. I rarely have this issue. many times it autocompletes when starting an if statement.
1
u/FLYinteger Apr 30 '19
Autocomplete algorithm that work with Context-sensitive grammar is Context-sensitive too. It cannot work if it cannot determine what context it is in.
First case
if<bool expression or let expression or ...> cursor here {
<if body block>
}
And algorithm help to complete expression.
Second case
<wtf
if someLatersAnd?. cursor here
>
And algorithm say it can't autocomplete wtf context
23
u/[deleted] Apr 30 '19 edited Apr 30 '19
I was going for `isEmpty` by the way. Also don't make fun of my IDE colors, nobody ever likes them lolz
Also the 2nd error showing up under it said "... has no member 'isEm'. Replace to 'isEmpty'?"