Cannot set the compiler flags in Xcode 4.3.3 - ios

I am trying to set compiler flags to disable arc for some of the files and i am not getting the dialog box when i double click or press enter on one of the files. It happens in a new project and old where i already set the compiler flags before. All it does just becomes gray after i press enter and looses focus. Is any one else having same issue or could i be doing something wrong.
Thanks!

I figured it out. I think its because i am using Macbook Pro with retina with resolution set to more text. When i enabled assistant editor in Xcode and pressed enter to change the compiler flag the dialog box came out on the other side top right corner almost not seen. Hopefully the next version of Xcode will support retina display.

I still couldn't see the dialog box but did it blind-fully.
Copied "-fno-objc-arc" and then in Xcode, Enter -> CMD+V -> Enter... the magic was done. :)
Thanks all!

I'm posting this in case someone stumbles across this answer when having the same problem on XCode 5 and none of the above solutions work, as happened with me.
In my case the problem was some kind of corruption of the workspace data. The problem was solved by deleting the xcshareddata/ xcuserdata/ and project.xcworkspace/ directories inside the project directory.
From a terminal:
cd <project_name>.xcodeproj
rm -rf xcshareddata/ xcuserdata/ project.xcworkspace/
Then restart XCode and the problem should go away.

And additionally if you're on a macbook pro without an enter key (the return key wont bring up the compiler flag box) and desperately are trying to flag multiple files at once... you just have to hit shift + fn + return. Just fn + return wont work - at least for me.

Related

Xcode 11 Beta 5 stuck indexing [duplicate]

A project I've been working for 2 months stopped working for no reason because Xcode got stucked on "Indexing". I can't Build the project anymore. If I try to build, Xcode freezes and I have to force quit. This happens only with this project.
I tried cleaning all derived data but didn't help.
I'm using Xcode 4.5.2.
Any ideas?
Open your Project Folder.
Find ProjectName.xcodeproj file.
Right-Click Copy and Paste to Safe Place.
Right-Click Show Package Contents.
Find project.xcworkspace file and delete that file.
Reopen Your Project and clean and Rebuild.
If your problem is not solved then replace the file with your backup file.
Close that project from Xcode
Open Xcode Organizer, find the problematic project
Delete Derived Data folder in the Organizer
Close/re-open Xcode
Nuking Derived Data is the first thing to try in all cases of Xcode misbehaving
I had this exact problem, it was caused by a 20 item array literal. Had to switch to different syntax. Pretty silly.
Close any opened Xcode
rm -rf ~/Library/Developer/Xcode/DerivedData
Right click your PROJECT_NAME.xcworkspace, choose 'show content', and delete 'xcuserdata' folder
Another thing to try if your trying to solve indexing issues and you're this far down the page!
Try adding this flag to your build settings.
-Xfrontend -warn-long-expression-type-checking=400
It will cause warning where the compiler take a long time to deduce a complex expression.
This may cause a build error which will go away after you find the slow expressions and then remove the build flag.
I had a similar problem, and found that I accidentally defined a class as its own subclass. I got no warning or error for this but the compiling got stuck.
class mainClass : mainClass
{
...
}
When using Xcode 6 and it says
Waiting for make
It might be that an instance of make is already running. Kill the process and indexing proceeds. Silly, but worked for me.
This happened to me. If you are using cocoapods do this:
Delete project.xcworkspace
Reinstall pods using pod install on the terminal
It will create a new project.xcworkspace
Open the new project.xcworkspace
-> Clean
-> Build
First, disconnect from network. Both your wired network and wireless network should turn off.
Second, kill the com.apple.dt.SourceKitService process. Then XCode would start to index again instead of stuck.
Hold alt > Product > Clean Build Folder
It's a Xcode bug (Xcode 8.2.1) and I've reported that to Apple, it will happen when you have a large dictionary literal or a nested dictionary literal. You have to break your dictionary to smaller parts and add them with append method until Apple fixes the bug.
For me completely closing out of Xcode and then restarting the project worked.
This is not the solution for the original question, I don't believe, but it is one more simple thing to try before deleting files and folders, etc. Credit to this answer for the idea.
I had a similar problem where Xcode would spend lots of time indexing and would frequently hang building the project, at which point I had to force-quit and relaunch Xcode. It was very annoying.
Then I noticed a warning in the project about improperly assigning self as a delegate. Sure enough, there was a missing protocol in the class declaration. Note that there is a similar assignment in the OP's sample code (though it is impossible to tell from the sample whether the correct protocol is declared):
leaderboardController.leaderboardDelegate == self;
After resolving that warning (by correctly declaring the implemented protocol), Xcode stopped misbehaving. Also, I should note that the project did execute correctly since the protocol methods were implemented. It was just that Xcode could not confirm that the protocol should in fact implemented by the class.
For me, I made a stupid mistake. I write a Class like this:
class A: A {
.......
}
A class inherit itself that causes the freezing. There is no message hint from Xcode.
Nothing worked for me, my project is too big (merging objective c, c++, swift, and java files with j2obj). I've disabled Xcode indexing and worked without code completion for months (and it's a pain). But finally I've found a workaround. The idea is to keep Xcode indexing the code, but to limit its CPU usage with an external tool like cputhrottle.
So first you need to install cputhrottle in terminal
brew install cputhrottle
Then limit the Xcode indexing process like this (20 = 20%)
sudo cputhrottle $(pgrep -f com.apple.dt.SKAgent) 20
I've exposed my "solution" here with mode details : How to prevent Xcode using 100% of CPU when indexing big projects
I'm working with Xcode 11.4.1 and I have the same problem with several projects. Every time, when internet connection is lost, indexing gets up. The best solution (it's just my opinion based on observing this problem):
- turn off internet and just kill the "com.apple...." process, then restart the Xcode(turn on connection)
or more easier
- just restart the Mac(with the internet)
Had similar problem in Xcode 6.4. The progress bar indicated that "Indexing" was "Paused". Tried deleting project.xcworkspace, then deleting Derived Data as described above. Did not appear to help. Noting that the posts above also suggest fixing warnings, and since I had inherited this huge project with 180 warnings, I said to myself, "What the hell this looks like a good day to fix warnings". As I was fixing warnings, a half hour later, I noticed that the "Indexing" progress bar had increased from 10% to about 20%. An hour later, it was at 50%, then another hour to 80%, then after another half hour it was done! Conclusion: Add "take a long lunch or a nap" to the above suggestions.
I experienced the same issue for Xcode 7.0 beta.
In my case, values for "Provisioning Profile" and "Product bundle identifier" of "Build Settings" differed between PROJECT and TARGETS.
I set the same values for them. And I also used the same values for TARGETS of "appName" and "appNameTest".
Then closed the project and reopened it.
That resolved my case.
In my case, deleting the derived data directory did not help. Apparently I had a file locked by another process, because after closing out a couple of terminal windows and emacs, and terminating a react-native packager process, everything resolved.
I have experienced this problem in some projects with Xcode 9.3.1 and in my case the problem is due to some swift code that for some reason Xcode doesn't like. This problem is hard to solve because is difficult to find what file is causing the problem.
When I have this problem, I removing some files from the Xcode project (removing references) and I try to test if indexing works. My process to do so
Remove some files
Close Xcode
Open Xcode
If indexing finish try to rename some method if works probably the files you have removed they have something strange for Xcode.
In my case I had a class definition with a reactive extension in the same file and for some reason Xcode doesn't like it, I moved the reactive extension to another file and now the indexing works fine.
2022 | Algorithm what to do:
Open activity monitor and kill there com.apple.dt.SKAgent
If did not help:
Close Xcode(cmd+Q). Run command in terminal:
rm -rf ~/Library/Developer/Xcode/DerivedData
If did not help:
Restart PC
If did not help:
Right click your PROJECT_NAME.xcworkspace, choose 'show content', and delete 'xcuserdata' folder
If did not help:
run your project build with additional warning. For doing this you need to write:
-Xfrontend -warn-long-expression-type-checking=100
to the following place:
and optimize code at all of places.
If did not help:
Z. Uninstall XCode and install it from scratch
If did not help:
Z+1. answer of El Belga https://stackoverflow.com/a/50541767/4423545
Also stop running app. if you have another application running with your xcode, stop it first and you should have your indexing continue.
For me, the cause was I opened the same file in both the Primary Editor and Assistant Editor at the same time. Once I closed Assistant Editor, it came through. (Xcode Version 7.2.1)
Close Your Xcode , close any git client(source tree or terminal)if it is opened and finally restart your project.
Faced this recently on XCode 7.3.1 - for me, I noticed RAM usage going to 100% on to CleanMyMac3. The problem magically fixed itself after I restarted my machine. In all fairness however, I'd already gone ahead and tried the accepted-answer, so you'll want to do the same before you restart just in case :-)
I fixed this by simply deleting the app from my device and rebuild.
I had the same issue in swift 2.2
It had to do with a generic function overloaded function
func warnLog() {
print("Warning line: \(#line) file: \(#file) ")
}
func warnLog<T>(input:T? = nil) -> T? {
print("Warning line: \(#line) file: \(#file) ")
return input
}
func warnLog<T>(input:T) -> T {
print("Warning line: \(#line) file: \(#file) ")
return input
}
all I needed to do is remove one of the non used overloads
func warnLog<T>(input:T? = nil) -> T? {
print("Warning line: \(#line) file: \(#file) ")
return input
}
My case: it was not the project.xcworkspace file, it was not the Derived Data folder.
I've wasted a lot of time. Worse, no error message. No clue on the part of Xcode. Absolutely lost.
Finally this function (with more than 10 parameters) is responsible.
func animationFrames(level: Float,
image: String,
frame0: String,
frame1: String,
frame2: String,
frame3: String,
frame4: String,
frame5: String,
frame6: String,
frame7: String,
frame8: String,
frame9: String,
frame10: String) {
}
To go crazy! The truth is that it is worrisome (because there is no syntax error, or any type)
For XCode 9.3 indexing issue - Uninstall the XCode and instal again from zero. Works for me.
This issue happened to me when my machine was out of swap space. Closed several programs and browser tabs and the build suddenly succeeded after 30 minutes of being stuck in place. Nothing to do with derived data, locked files, etc. on my side.

Xcode 8 syntax highlighting doesn't work

The code above has correct syntax highlighting in Xcode 7. It is mix of Obj-C + Swift:
I've updated project to support Xcode 8 and only few things was changed:
In Build Settings Swift 2.3 support
And have fixed few errors related to implicitly unwrapped properties in UIKit
After all the project is compiled fine for Xcode 8.
But Obj-C code integrated in Swift doesn't have any syntax highlighting and vice versa:
And there is << error type >> problem with autocomplete:
Derived data deleting doesn't help, Xcode restart either :) CocoaPods version 0.38.2, iOS 7
This answer helped me https://forums.developer.apple.com/thread/46223 with one of my projects:
I got help from an apple engineer at WWDC on this issue and resolved
it. The problem stemmed from cocoapods... Apparently cocoapods was
copying .h files into the build directory and SourceKit was getting
confused. I'm not entirely sure why the .h files were being copied -
they aren't needed there. So the fix was to add a post-build script
in your build phases section that removes the headers after a build.
It would look something like this:
function removeHeaders() {
find $BUILD_ROOT/Debug-iphonesimulator/ -name '*.h' -exec rm -f {} \;
}
removeHeaders
Fixed. Problem was related to the presence of target in project which is not compiled. So if you have targets e.g. A, B, C and C is not compiled this cause problems with syntax highlighting.
I have found that when syntax highlighting falls over, switching tabs in Xcode fixes the issue ¯_(ツ)_/¯ sometimes I find I need to switch to at least 4 different tabs before it comes on again.
Otherwise a quit and reopen
It happened also to me with Xcode 8 GM but also lots of time when I used Xcode 7: sometimes the auto-complete feature and the syntax highlighting die without notice.
The only solution that it works for me is restart Xcode but a few times I needed to complete reboot my Mac; I still don't know exactly what causes this annoying problem.
Setting Use Legacy Swift Language Version to YES in the Build Settings helped me to solve similar issue
Commenting and then uncommenting the affected lines worked for me.
In my case:
In Finder I navigated to user->Library->Developer->Xcode->DerivedData. Close your Xcode Project then Clear DerivedData. It's work for me.
Happy Coding...:)
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.
As others have stated above - if I create a new tab ..or 4 then close the tab that usually does it. Sometimes commenting out a line then immediately uncommenting does the trick as well. I got tired of using several keys to accompolish this and made a simple AppleScript to do it for me.
Create a Automator 'service' and add this script to it. In System Preferences under Keyboard -> Shortcuts -> Services find your new service and assign it to an empty function key (I used F1) and now you have a 1 key fix!
on run {input, parameters}
tell application "Xcode"
activate
tell application "System Events" to keystroke "t" using command down
delay (0.5)
tell application "System Events" to keystroke "w" using command down
delay (0.5)
tell application "System Events" to keystroke "/" using command down
delay (0.5)
tell application "System Events" to keystroke "/" using command down
delay (0.5)
end tell
return input
end run

Xcode 7.3.1 autocomplete code completion not working

Ever since Xcode 7.3 the autocompletion or code completion doesn't work properly.
I have tried:
Deleting Derived Data folder
Clean Targets and Build
Reinstalling Xcode
It does autocomplete after you type it out fully the first time. But if you haven't referenced it once (i.e. like enums) it only shows what you typed out before (not showing full list of enums). Pressing escape doesn't help either.
Any other suggestions? Or anyone else experiencing the same?
Without doing anything, In Build-Settings -> Deployment changing iOS Deployment target from 8.0 to 8.1 resolved the issue for me.
It also works for XCode 6 as mentioned here
Also works on Xcode 8, Simply change the deployment target from iOS 9.0 to iOS 9.1.
Xcode 8 has now fixed this very annoying autocomplete issue. So anyone who is still having this problem, update to Xcode 8.
Edit: Please note, this has not solved for others. So your milage may vary. For me, it has fixed without doing anything extra. But they are using their new 'intelligent' autocomplete. Thinking about it, it could be part of the indexing. Deleting the DerivedData folder could help.
Perhaps, this answer is too late, I'll share it anyway.
First of all, I've uninstalled Alcatraz and all plugins.
Second, I've followed ElonChan's instructions explained on:
Xcode 7.3 autocomplete issues
As a result, autocompletion automagically got back! Thanks #ElonChan.
I hope this answer also solves your problem.
This Happen usually when you are using core Data in your project.(because of automatic indexing of files by xcode not been done) The simple way to avoid this thing is that just click to your project name and clean project come back the same file where you wanna see suggestions type any word and thats it.
There is a way to set shortcut keys for code completion. Xcode -> Preferences -> Key Bindings -> find Show Completions and set whatever non-duplicate keys you want.

Xcode - Invalid character in source file (Replace " " with " ")

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

Xcode 6 - Syntax highlight / completion not working

After one day my code loses its highlight / completion again in xCode 6.
As always, I tried to Organizer > Projects > and Delete Derived Data.
Which did not work in Xcode 6, even after it finish to index everything.
I tried to uninstall and install 3 times - and its still coming back after some time.
I really can't find why Xcode loses it.
Any help will be appreciated.
Syntax highlighting and code completion can sometimes only work on part of the file too, and it happens during the editing or on a random basis.
I fix this by cleaning the project... not a sexy solution, but it works.
I think it's a bug in some Xcode versions, I have it on Xcode 6.4 and the only solution I found is to open Editor menu -> Syntax coloring -> Choose None
then Editor menu -> Syntax coloring -> Default for filetype.
PS: cleaning the project didn't solve the problem for me.

Resources