"aFile.m" is not part of the build phase of any targets in this workspace - xcode

I'm asking this question again since the other one had an answer that did not work for me.
I'm getting this message when trying to rename a class, along with code sense and color syntax broken.
The file is in the build phase of the target.
I'have tried erasing the derived data to rebuild the index. I can see the index rebuilding but this does not help.
I'm using Xcode 4.2

I found it to be a bug in Xcode 4.1 under OS X 10.7.1 along side with other issues i had. When I reopen my project, the message was gone, refactoring worked as expected and auto-completing worked as well.

Related

Opening Storyboard fails with "An internal error occurred. Editing functionality may be limited"

Im running Xcode 9.2. My storyboards are completely useless now. Ive
experienced what this article shows and have tried everything the
article suggested.
My issue occurred when I tried to add a single swift file to an existing
objective C project with about 320 files in it already. I removed the
.swift file entirely from the project, then did everything in the article
link above and still nothing fixed it including removing/reloading XCode
several times trying different things.
I filed a bug with apple but haven't received any replies in a week (of course). Apple seems to be slammed with tons of bugs lately they keep
creating.
Now I cannot work on this project's storyboards at all and Im dead in the
water. Really not happy with Apple lately!
Is there anything more that anyone has had success in fixing this issue?
Im completely dead in the water on this application now.
Fixed this by setting the command line tools version to the correct one. Mine was blank in Preferences / Locations
For my case, whenever I open a storyboard from a workspace, this happens. So I got rid of cocoapods and workspace, then just use carthage for thirdparty libraries. Storyboards opens faster and without this error.
Note that the storyboard I am testing is empty.
This turned out to be stupidity on my part. I had a script that was killing certain processes on my Mac over and over and it turns out that was my issue. When I removed it everything worked as normal again.

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 doesn't create swiftmodule

I've spent the past few months converting a project of mine with about 1500 source code files into Swift. It was incredibly tedious, but I finally did it. It runs well, builds well, but:
When I attempt to archive the project, Xcode fails with the following error:
ditto: can't get real path for source '/Users/USER/Library/Developer/Xcode/DerivedData/
APP-dtsbrzschafjiubelceuxtfwstqf/Build/Intermediates/ArchiveIntermediates/APPCore/
IntermediateBuildFilesPath/APPCore.build/Release/APPCore.build/Objects-normal/
x86_64/APPCore.swiftmodule''
Command /usr/bin/ditto failed with exit code 1
APP being the app and APPCore being the embedded framework.
What I've tried:
cleaning the project (which really has no effect when archiving, since archive always compiles from scratch)
using Xcode 7.2 beta (released a few days ago)
making as many declarations as possible non-public
disabling any Swift optimizations for the release build configuration
building the APPCore framework as release - which actually works (!) - and does (!) create the .swiftmodule file
The last part being the strangest here. This evidently points to the archive doing something slightly different, but I have no idea what.
My question is if anyone has any idea why is this happening and how to debug this. I've spent the last two days trying to figure this out, but no results...
I've googled this error as well, but unfortunately, the answers were fairly limited and suggesting to comment all lines of code and then start slowly uncommenting them until the project builds. Which is OK for a smaller project, but not for a 25KLOC project, mainly when you have absolutely no idea where to start...
I had the same issue and your question actually helped me to solve it (Xcode 8).
In debug mode just got the "ditto: can't get real path for source" without any further information. Switching to release mode showed me that the problem was that the framework wasn't allowed to have a bridging header file. I went to the build settings and removed the bridging header file (don't know why there was one) and it now compiles both in release and debug mode.

Xcode Source Compiling Order Issue

I am working on a fork of the Xbox HID project (to allow greater configuration of the controller) and came across a really strange issue.
The project is three projects, which I have grouped together under a workspace, which works well, it compiles them in order (kext, daemon and prefpane) and all works.
However, I decided to uncrustify the code (thanks Alcatraz!) and standardise the names and locations of source files. This required me to update the project as file paths changed.
Once this was all completed the PrefPane wouldn't load. For some reason it was instantiating and sending initWithBundle to an object that was NOT the File's Owner in the XIB.
After a lot of debugging and hair-pulling I discovered the object it was instantiating also happened to be the first file listed in the Compile Sources build phase. Once I moved the correct file to the top of that list the PrefPane once again launched and worked as expected.
That seems wrong, why does it need to compile this particular class first... better yet, why is it picking up only the first compiled class instead of the one specified in the XIB?
I am using Xcode Version 6.2 (6C131e) under OSX 10.9.5, however, I am using the OSX 10.6 SDK and have 10.6 as the deployment target.
I was having some other issues with the project in question, so I rebuilt all three projects and this issue went away.
I am guessing there was some sort of issue with the Xcode project itself as I believe it was probably upgraded from at least two previous major versions of Xcode.
Lesson here seems to be, rebuild the project files themselves and see if that fixes the issues!

Xcode 5 cannot run using selected device on iOS simulator

So this seems to be quite a common question but all the answers I found were related to getting "xcode cannot run using selected device" when trying to run it on a connected device. My issue is getting this error just trying to run it in the iOS simulator.
Some background is that app was running in simulator fine, and then I changed the Project Name, the Target name and the Scheme name and that is when the problems started to occur.
I tried many of the different solutions in some of the other threads such as: Clean, Delete Derived Data, restart Xcode, restart computer, make sure using Default LLVM, remove Info.plist then re-add it into project again. None of them worked.
I finally discovered the problem and was able to get it working and will post my solution below.
What I discovered to be the problem, was that in the Info.plist file the Executable File (CFBundleExecutable) was hard coded as "MyAppName". When I changed the Project name and Target name and Scheme name, this hardcoded value was not changed, but still had the original app name in it.
So I changed Executable File (CFBundleExecutable) in the Info.plist file to be this constant:
${EXECUTABLE_NAME}
And the problem was solved :)
EDIT:
I had the problem occur again on a different project, however the above was already set to ${EXECUTABLE_NAME}.
So I went searching and found that under Build Settings > Build Options > Compiler for C/C++/Objective-C was set to UNSUPPORTED.
I changed this setting to DEFAULT and the problem was solved :)
EDIT:
I had the problem occur again and the above two things did not fix it.
So I went and made sure that the info.plist was removed (unticked) from any Target Membership, and this solved the problem. It seems that there are multiple things that will cause this issue, so try all the solutions!
I ran into this and had to change the deployment target (iOS version) in the general tab of the project options menu. Apparently xcode had been updated to support iOS 8.2, but my simulator had not, therefore nothing appropriate was showing up in the list of simulator targets. Changing the deployment target to 8.1 fixed the issue. I'm sure that keeping my Mac up to date would also help.

Resources