Error in conversion to swift 3 syntax for an existing cocoapods integrated project - xcode

I've recently upgraded to xcode 8 and did a conversion for my xcode project. While every other swift files checks out fine, there seems to be issues with this particular swift file.
I suspect it could be a result of cocoapods not being updated and thus I did a repo update to the latest pre version before doing a pod install on the project again but still to no avail.

Hmmm ok I found a way to fix this, apparently just going to product>clean will solve most of the problems. This is for anyone out there converting to swift 3. Now on to solve some other problems...

Related

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.

Xcode 9 code completion and highlighting not working

I have seen many threads about this online, but not for Xcode 9. For some reason code completion and syntax highlighting is no longer working. Last week it was fine.
Using the GM build.
Anyone have this issue or know how to resolve it? A restart of Xcode and my computer did not help.
In Finder I navigated to user->Library->Developer->Xcode->DerivedData and deleted the subfolder of the project in question. After next build of the project the syntax highlighting and code completion returned.
In my situation, there are a few of .swift files not working. I've overcome by removing these files from project and re-adding them back.
Quitting Xcode then reopening it works for me.
To make it work again, I have to restart the macOS System.
I'm using Xcode 11.0 (11A420a), at the same time, Xcode 10 works OK.
So I think there is some process does not work, which should work for code coloring.
For me, code completion/highlighting not working due to the missing file in the Compile Sources under Build Phases. I added that file and it works.
Hope this helps anyone.
I have observed the same problem while writing in swift on xcode 9.0, Seems it is fixed in 9.1 i am using 9.1 which is fine, please update xcode to 9.1 or newer.

Alamofire and Reachability.swift not working on xCode8-beta5

I have a custom CocoaPod created in swift2.3 and it has Alamofire and Reachability libraries inside the project. I mean I did integrate Alamofire and Reachability into the project manually.
It still works perfectly on xCode7.3.1 and I am going to update it to swift3 on xCode8-Beta5. I tried to update it but I couldn't get it done successfully.
Here is how I did for the update.
Replaced Alamofire and Reachability in the project folder for swift3 from
https://github.com/Alamofire/Alamofire/tree/swift3
Opened xCode8-Beta5 and converted all files to Swift3 syntax(actually xCode asks it when opening the old version project). So the converting was done automatically by xCode.
And I tried to build the Cocoapod but it gives a the bunch of error.
How can I solve this problem and update the Cocoapod successfully?
I tried to update two Cocoapods on xCode8-beta6 but Alamofire is still not working. Here is a screenshot.
https://www.dropbox.com/s/gm8ud67qc1ixffb/Screen%20Shot%202016-08-20%20at%2011.06.31%20AM.png?dl=0
If you plan to convert your code into swift 3, and to develop in the latest XCode 8 Beta 6 (forget to use Beta 5, I was trying to success round a clock and finally in Beta 6 it is possible to use Alamofire without rewriting all their code):
You need to update the Alamofire to its 4.0 version. I was waiting for this version neverending weeks between beta 2 and beta 6, as it wasn't able to use Alamofire at all. Apple ischanging SDK version by version during summer, but now the latest branch of this framework is on github.
In your Podfile you need to set more parameters to be able to use update stuff in these beta times. They are hardworking on swift3 branch.
If you don't use 4.0 version, there are many issues that XCode is not able to resolve in its convertor for its previous versions of Alamofire.
Huge amount of code they had to change.
They announced they will produce official 4.0 version after Apple releases GM seed. So until we get XCode GM Seed, put this to your Podfile before its install:
I could build Alamofire and Reachability frameworks successfully on xCode8-beta6 without any problem from the following branches.
https://github.com/Alamofire/Alamofire/tree/swift3
https://github.com/ashleymills/Reachability.swift/tree/feature/ios10

Xcode 6.3 autocompletion slow with bridging header (e.g Parse)

tl:dr
Xcode Update 6.3.1 solved the problem for me.
It's still lightly slower than before but I'll give that shame to my Evo 840.
the problem
Since I've installed the latest Xcode version (6.3) my projects with bridging headers seem to have problems with autocompletion. It's incredibly slow!
Is there any known workaround (except removing bridging headers...)?
EDIT:
Bug reports
20549109
20549764
20549768
EDIT (04/17/2015):
bugreport.apple.com marked this as a duplicate of
20445407
I had similar issues and after updating to xcode 6.3.1 and swift 1.2 they dissapeared.
Not appearing with xcode 7 & swift 2.0
Steps are as:
1. Just go in user->Library->Developer->Xcode->DeriveData and delete the Data of folder(Derive data).
2. Just restart your system.
3. It will work better.

cocos2d xcode frameworks are not being added to the project

I have recently updated to Xcode 6.0.1. I am trying to create an Cocos2d 3.x project. When I do I get 200+ errors. The errors are due to the fact that the frameworks are not automatically being added to the project. I can go through and add them manually and fix the problem but this gets very annoying to repeat every time I want to create a new project. Can anyone tell me why the frameworks aren't being added? It used to work. I'm pretty sure the problem started when I updated to Xcode 6.0.1. Thanks.
I found the answer here: http://forum.cocos2d-swift.org/t/something-wrong-with-the-xcode6/15437
Basically, the problem is in Xcode 6.0.1. They recommend creating the project in Xcode 5 or SpriteBuilder and then opening it in Xcode 6.

Resources