Qt Creator keeps old directory after it was renamed; app path is now wrong - qt-creator

I use Qt Creator to build a Mac OS program. Recently I renamed the folder containing the project. Unfortunately the program runs incorrectly now. I traced the error to an incorrect application path returned by QCoreApplication::applicationDirPath. The path is incorrect in that it contains the now nonexistent old folder name.
For example:
old project folder: Users/graham/CartoType-3/src/apps/Maps
new project folder (after renaming): Users/graham/CartoType-mainline/src/apps/Maps
I also noticed that when I build the project, I get a message telling me that Qt is creating a stash file in the old folder - which it stubbornly recreates.
I have googled for a long time, and based on what I found, have tried the following:
(i) deleting the .qmake.stash file - no point because Qt Creator calmly recreates it in the wrong place
(ii) deleting the .pro.user file, which contains instances of the incorrect path - that doesn't work because Qt Creator recreates it with the incorrect paths again, then recreates the stash file in the wrong place
(iii) deleting the .qmake.cache file - no point, because there is no cache file after I do a clean, and the problem is still there
So I can only conclude that somewhere there is a configuration file containing the old directory name - but I can't find it.

I have a solution. The erroneous folder names are stored inside Qt Creator and can be edited in the Build Settings pane displayed when you click on the Projects icon in the left sidebar.
Strange how the answer typically becomes clear only after one gives up googling and posts a question. However, I hope the information is useful.

Related

Swift - `.framework` file is not generated

So I just followed this very short tutorial on how to create a framework with Swift.
At one point, the author of the article does this:
This leads him to this:
When I try to do the same, nothing happens though (Finder is never opened). So I thought I could just manually navigate to the project's folder to find the .framework file. But it seems, that such a file is simply never generated:
And even after searching for SortedList.framework in Spotlight, nothing is found.
A noteworthy detail is also, that in Xcode, the 'Products' are shown in red:
Why is the .framework file not generating?
The framework is being generated, but it is located within Xcode's DerivedData directory where your project is built, not the directory where your framework's source files are located.
Your target's path is likely not correct, which is why the product's name appears in red, and Finder can't open a window to that directory.
The location for the framework should be ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework, which (for the Debug configuration) would expand to:
~/Library/Developer/Xcode/DerivedData/SortedList-<random suffix>/Build/Products/Debug-iphoneos/SortedList.framework`
Update:
If you select the framework product, then look in the Utilities -> File Inspector pane, you should see that its name is SortedList.framework, its type is Framework, and its location is Relative to Build Products.
The full path shown below that should automatically correspond to the DerivedData location for the framework.
Here's an example of what a framework's File Location pane would look like.
I can't comment so I'm writing this here to build upon PetahChristian's excellent answer.
I had the same issue, my folder was listed in Xcode as:
/Users/jack/Library/Developer/Xcode/DerivedData/PDFManipulator-ggvfnlbpcgwblwdnvsnxweqnuvgc/Build/Products/Debug-iphoneos/PDFManipulatorTests.xctest
But in reality, it exists in:
/Users/jack/Library/Developer/Xcode/DerivedData/PDFManipulator-ggvfnlbpcgwblwdnvsnxweqnuvgc/Build/Products/Debug-iphonesimulator/PDFManipulatorTests.xctest
Notice that the last folder each is slightly different. I can rename reality to make it the same as the Xcode one which fixes the problem.
However, if I rebuild the project again the files are recreated in Debug-iphonesimulator. Not sure how to fix that.

Changing the name of main folder in Xcode project

This is not the first time I've had trouble with this and I suspect not the last time either. Despite having learned many frameworks inside out I still find the organizational structure of a simple xcode project elusive. I simply wanted to retitle a project from CATouchSynth to ABTouchSynth. A while ago I discovered that if you click on the Project folder in project navigator and than change the name in the Identity and Type section it will rename many of the relevant files and directories to the new name. However, there is one main folder inside the folder on your computer that doesn't change and still has the old name. I could see no way to change this folder name through Xcode and so I renamed it manually from finder. This turned all of my source files and assets red so I manually "relinked" them in xcode and they are now non-red and seemingly linked with the newly named folder. However I am getting several compile-time errors talking about the old folder name but I have no clue what Xcode is referring too. The errors look like this
It seemed as if derived data was an issue so I deleted the derived data folder from Xcode and I still get these errors. Has anyone experienced this before and what can I do to ressurrect my project?
Note: Before doing any changes do backup your project folder. This is seriously recommended.
Follow the steps below to rename the source folder of your project –
Close XCode.
Rename the Source Folder.
Right click the project bundle .xcodeproj file and select “Show Package Contents” from the context menu. Open the .pbxproj file with any text editor (Xcode).
This step should be done with extreme caution. Search and replace any occurrence of the original folder name with the new folder name.
Save and Close the file.
Open XCode project.
The error is happening at build time during the compile phase, so you will have to go into the app target's Compile Sources build phase, remove all those .m files, and add them again.

Rename Xcode Project Doesn't Change Filesystem Project Folder Name - Not A Redo of Other Q's

Using Xcode 4.5.2
I occasionally want to rename a project all the way through the project without leaving obvious folder name atavisms from previous versions in the project 's file system.
The usual instructions for renaming an Xcode project do not accomplish this. I have read them and done them many times. They only go so far. They leave the main directory (at the same level as the .xcode.proj file) with the ORIGINAL project name. Call me persnickety but I don't like that. So I endeavor to change it as follows.
I begin with the usual instructions, then attempt to rename the remaining original folder name both in Xcode and in Finder. It ends badly. Here are the steps I follow. It should be reproducible.
We will attempt to change a project named "JoeSchmoe" to "JoeSchmoe_1".
Do the Usual Project Rename Procedure
Create a new Xcode Utility project, named: "JoeSchmoe". Use Storyboards and ARC.
Build, run, and test functionality to verify that everything is OK. It is. Stop.
Hit cmd-shift-J
Open the Utilities panel on the right
Under Identity, change project name to "JoeSchmoe_1". Xcode will ask you, "Rename content project items?" Click "Rename"
Build. It should succeed. And it does.
The Problem
In the Project Navigator, notice that the main folder in the project is still named "JoeSchmoe"!
Change the name of that folder to JoeSchmoe_1
Build. It should succeed. And it does. We're done, right? Well let's look at the project's file system.
Quit Xcode
In Finder, open the folder containing the newly renamed and working "JoeSchmoe_1.xcode.proj"
(Its containing folder is still named "JoeSchmoe". That's ok for now. We could change it to anything without affecting Xcode, so long as it contains the .xcode.proj file and associated files and directories. We leave it alone.)
In that directory (at the same level as the JoeSchmoe_1.xcode.proj file), notice that the main project folder is also still named "JoeSchmoe" !!
Change the name of this "JoeSchmoe" folder to "JoeSchmoe_1". (We expect this to break the project because we know Xcode will still be looking for the "JoeSchmoe" folder, since it didn't change it for us.)
Start Xcode
Build. It fails, as expected.
Notice that all the filenames in the Project Navigator are now red colored, meaning files not found. (We expected this. Now we want to fix it.)
In the Project Navigator, select the project (top icon), then Target -> Build Settings -> Packaging -> Info.plist File.
Notice the file pathname in the Info.plist File settings row is named: JoeSchmoe/JoeSchmoe_1-Info.plist !! The directory still has the old project name. But in the file system we just changed it. So let's make this the same as what's in the filesystem.
Change its name to JoeSchmoe_1/JoeSchmoe_1-Info.plist
Re-Verify that the directoryname/filenames are identical in the file system and what you have in your Xcode Packaging -> Info.plist setting.
If they are, the project should build. Right?
It Fails. And all of the project files are in red (meaning not found).
Try cleaning the project (Product menu -> Clean),
Quit Xcode, Restart and Build.
It Fails, as before.
At this point I don't have a theory as to why it fails, other than to assume that there is an Xcode setting that needs to be changed somewhere that I haven't yet discovered. Looked all around for it. I'm stumped.
What am I missing?
Since they got rid of the feature that was in Xcode 3 to easily change your project name, it's been a pain in the butt to do manually. I found a great app in the mac strore Project Duplicator for Xcode 4 that copies your project and lets you name it whatever you want. I've been using it for a while now and have never had an issue with it, and it was only $1 when I purchased it.
GW
The last thing I had to change when renaming a project, including the finder folders, is the setting under "Build Settings->Prefix Header". It was still pointing to a finder folder that no longer existed and the compiler would throw on a file not found error.
Once I changed this to my new inner project folder, it all worked fine and I've been able to build the project as expected.
See this answer for fixing the problem manually
Renaming xcode 4 project and the actual folder

File in the project not seen by Xcode after Git pull

A partner and I are managing an Xcode project via Git. He recently "localized" the project, which added a directory for German ("de.lproj") to the project with a number of files. After I pulled those changes over to my copy of the project, Xcode now fails to compile complaining that two files in this directory don't exist. These files are present in the filesystem, but displayed as red (missing) in the Xcode sidebar.
Is there a way to force Xcode to rebuild it's internal catalog of files so that it can "rediscover" that these files are, indeed, present?
Note, I've tried a fresh "clone" of this Git project as well, same result.
I found a solution without removing the file from Xcode -
In the Project Navigator, locate the file (colored red for not being found) and highlight it.
Show the File Inspector
Under Location change Absolute Path to Relative to group or Relative to project,
Then next to the path, there's a little white icon, click it and choose the file's location.
This turned out to be a case of absolute vs. group paths memorized in the project.pbxproj file by Xcode. For reasons I do not understand, when my partner localized our project, some files were added to Xcode using absolute paths. When I pulled that version of the project, my copy of Xcode could not find those files because the absolute path did not match my absolute path. Even though the files were in the project and transferred properly by Git, Xcode could not find them.
My solution was to use Xcode to delete these files. Since these were localized files, I actually had to delete the "parent" version of the localized files. I told Xcode to only remove the references to the files. Then I dragged the files from Finder back into Xcode. This time Xcode inserted them as "relative to group" and all was well.
I committed and pushed those changes back to our remote Git repository. My partner was able to pull those to his copy and all worked for him too.
Neither of us understand why the files were inserted as absolute references in the first place, but at least we were able to use this workaround to make the project portable again.
I had this issue and i fixed it just by quitting xcode and reopening it. All the missing files magically reappeared. Hope this will help some one.
Check the project folder path. If any of the folder name in the path contains a 'space' then remove it and open the project again. I had this issue with Xcode 9.

xcode copying project to another computer

I'm having problems copying a project over from one mac to another. The project compiles and runs fine after being copied, however xcode seems to have some duplicate of the same classes which seem to be invisible on the project browser on the left.
For example if I jump to definition on a variable I get 2 suggestions pop up. The top file when I look at its properties is relative to xcode folder (this is also the one that shows up in the class browser to the left). The second file which cant be seen on the browser has absolute path type in the properties.
Is there any way to get rid of this behaviour so its just looking at one file only like it originally was doing on the other mac? Its a bit problematic as I am never sure which one I am editing and they don't seem to update each other even though they appear to be the same file.
On a side note if I copy the copied project to another location then I get 3 etc files pop up in the jump to definition.
It's usually a good idea to either not copy the "build" folder (or delete it after you've copied everything over - only do this when Xcode is not running though).
Ok so what you need to do is this:
1.Duplicate your project.
2.Open the copy w/the original ,but only the folder.
3.open the Projects files(not the tests the main files)
4.then Drag and drop the files into the xcode area.
5.Zip the folder and its done
its like that because it just removes the references but not the files they are all still there though so just add the references back into the file.

Resources