Project Crashes After Rename - ios

If I change the name of my iOS project in XCode either in in the navigator view:
What is the equivalent of Project->Rename in Xcode 4
Or in the Inspector, like this:
http://woolybeastsoftware.com/woolyblog/2012/01/22/xcode-4-renaming-projects/
...XCode quits unexpectedly? Anybody run into this problem?
Why does this happen and how can you avoid it?

If your Xcode project is corrupted, you can do the following,
In finder, right click on your .xcodeproject file and click on show package
contents.
Then right click on your project.pbxproj and open it in some text
editor.
Then search for the previous project name which you used and manually rename
it to the new name.
Save it after changing and then reopen the project.
The reason is because your project.pbxproj file which stores all details related to the project got corrupted which causes the Xcode to not able to parse it and hence it crashes. Ideally this shouldn't happen while renaming, but in your case somehow it got corrupted. –

There is a more simpler way: go to Build Settings -> search for "Product Name" and rename it.

I got this problem after upgrading to Xcode 6.3. After downgrading to 6.2 it worked fine again. So it seems that some versions of Xcode handle renaming better than others.
You find an old version here: https://developer.apple.com/downloads/index.action?name=Xcode Hope this can help someone.

Related

Cannot preview in this file - active scheme does not build this file : SwiftUI on Xcode 11 in CatalinaOS

I opened Landmark App using SwiftUI on Xcode 11 in macOS Catalina(10.15) and while opening the Canvas Editor for .swift files containing SwiftUI is showing
Cannot preview in this file - active scheme does not build this file
Try Again, Diagonistics option or restarting Xcode not solving the problem.
If this is a new project coming from a copied folder and inside an iCloud folder, just close Xcode and relaunch it. The sync was not yet done.
Select the Scheme that has the current file to Preview
You should go through Xcode and Apple SDKs Agreement and you can do it by running the following in terminal in mac:
sudo xcodebuild -license
After doing that reopen your project.
I experienced the same issue. All I did was to copy the "StartingPoint" folder out of the downloaded folder and relaunched the project. It worked!!!
I bumped into this too, following the Landmarks tutorial. When I created the 'CircleImage.swift' it was not letting me preview it, with the above error message.
You can see the current Scheme you're using by going to Product > Scheme. I've got macOS selected.
Clicking on the CircleImage.swift file loads it, and in the rightmost sidebar it shows the Attributes inspector. A few buttons to the left of that is "Show the File inspector".
There, you can see this file's chosen "Target Membership". My problem was that "Landmarks (macOS)" was not checked. Checking this immediately got the Preview working.
I imagine I could also have changed my Product's Scheme to iOS and it would have worked, as that was already checked.
I encountered the same error for some of my SwiftUI View files when trying to preview on Canvas. What fixed the issue was I copied the code within the current file, deleted the file, created a new SwiftUI View file under the same name and pasted the original code. Hope that helps!
Creating a new folder in Documents/Desktop and copying the files over also resolves the issue.
This problem happened to me when I copied a folder into my project with the "Create folder reference" option instead of the "Create groups" option.
The problem was solved when I deleted the folder from project and copied the folder again with the latter option.
I just upgraded to both Monterey 12.3, and Xcode 13.3, and boom ran into this issue. Things were fine before the upgrade. Nothing above helped.
Creating a new project does help. So the only thing I found is to create a new project, and just add the files from the old project to the new one. Yuk.
EDIT: I hadn't rebooted the computer (mac mini), after reboot things were fine again.
In the schemes I was able to select, it contained only one scheme. Reopening the folder in a folder that's not in the Downloads directory made live editing work for me
Restarting my PC worked for me.
The described issue happened to me after cloning a project via git (no iCloud syncing as described in another answer - so I definitely know that the sync itself was completely done).
Funny enough restarting Xcode did the trick.
Just closing and opening the project isn't enough.
I found that the file I was trying to preview was not listed in Target -> Build Phases -> Compile Sources. Once I manually added the file, Preview worked. I had drag and dropped a directory into the project, and for some reason Xcode had not added those files to that list.
Try About this mac -> Storage -> Manage -> Developer, Then delete Xcode cache from here then restart Xcode...This worked out for me
Make sure the file you are trying to preview is in your app (the folder with the same name as your project).
I was able to fix newly created files not previewing by moving the file into my project.
Another solution:
Make sure you select file type Swift UI instead of Swift File when you create the file.

error: Unable to resolve build file: XCBCore.BuildFile

error: Unable to resolve build file: XCBCore.BuildFile (missingTargetProductReference("3bf83096e50de72a94699e9afc1133ebe3512682230d04680075c283a974e273")) (in target 'MyTarget')
Xcode 10 is giving this error immediately when trying to build our project. It's not immediately clear what is causing it.
How can I resolve it?
For XCode 10 Beta: Problem occurs when I have two workspaces open that share the same project directories. Solution was
Short version
Shut down all but one workspaces
exit XCode and reopen XCode
XCode > Product > Clean Build Folder
Longer version
Shut down all but one workspace
XCode > Preferences > Locations > Derived Data > goto directory ~/Library/Developer/Xcode/DerivedData
Clear out subdirectories from DerivedData
exit XCode and reopen XCode
XCode > Product > Clean Build Folder
Thanks to #aferriss answer for the clue.
I came across this same error while using openframeworks 0.10 with xcode 10 recently. It seems like it was caused by having multiple openframeworks projects opened at a time. If you close them all one by one, and then reopen the one you'd like to work on, it should resolve the error. Hoping this is just an xcode-beta thing.
Xcode used to tell you that there as a workspace integrity problem, and you could just ignore it. But it seems like it's returned. There's some discussion about this issue here.
For me, XCode > Product > Clean Build Folder and restart Xcode then worked.
This was the culprit for my experience of the same error:
After setting the correct version of Command Line Tools (i.e., Xcode 10.2.1; see below) on my system, the error went away!
Just Restarted my Xcode and the problem went away
The key here is missingTargetProductReference, or you might get namedReferencesCannotBeResolved. Xcode can't find something.
This happened after upgrading to Swift5/Xcode10.
I found that removing linked frameworks and then re-adding them fixed the issue.
I had an embedded Xcode project that was not found (light blue). Deleting it and dropping it in again solved the issue.
In case this helps, I had a new repo and the Libraries weren't correctly linked.
I opened Xcode, cleaned, and went through, one by one, through Libraries on the menu. I clicked on it, which opened the info panel on the right, and pressed the small folder button, and found the path designated and clicked and opened, to make Xcode recognize those Libraries. Path names were often
/node_modules/react-native/Libraries/(something)/(something).xcodeproj
In my case, after trying all solutions in this question and some more (including updating Xcode 10.2 beta and even macOS), the only thing that worked was accessing the project bundle (right click > Show Package Contents) and remove everything except project.pbxproj:
project.xcworkspace
xcshareddata
xcuserdata
If you have a File Group which is backed by a physical folder and that physical folder has been deleted then you will get the same error "Unable to resolve build file: XCBCore.BuildFile".
In my case the physical folder has been removed (because I removed all "real" files from it) and in XCode group there was still one external project linked.
Solution:
- created a new group (without a folder) in XCode
- Moved external project reference there.
- rebuilt the project
Error gone.
For me there was a different solution after none of the above worked.
The problem started after using unlink for one of my packages.
Then for some reason, the Package was still there under Libraries, but it was greyed. After deleting the greyed Library, everything started working again.
My solution was that I was using the wrong Xcode version for the project I was working with. It still required 10.1 and I was attempting to run in 10.2. I instead opened it in 10.1 and the error went away while successfully compiling.
The problem is that on new xcode 10.2 there is a new BUILD Configuration, you need to change to LEGACY.
You can check how to change it here: https://medium.com/xcblog/five-things-you-must-know-about-xcode-10-new-build-system-41676cd5fd6c . CHECK THE GIF
So if you have a newer version of xcode different than the one used when the project was working probably this is what is causing the issue.
I have the same problem. Because a folder not upload to Git server, git not allow upload empty folder, then I create a folder in project folder, and it work well.
missing folder
In my case, it was a simple issue of a missing file.
Checked all secondary error messages. Error report said that my bridging-header.h file was not being found. Checked the path of the missing file from the target settings (just search for .h to get the right setting key). Fixed the new path and error went away.
The cause:
I had reorganized my folders after a system crash and added a second level to my project location.
I've faced the problem in Xcode 10.1.2. Xcode restarting and the clean project solve it in my case.
Seems like there are a number of reasons for which one runs into the same error. For my case, it was not having the Submodule checked out locally. After I made sure all my Submodules were downloaded, the error went away.
I had correct Command Line Tools and cleaning did nothing for me.
While resolving a merge conflict, A Group named "Recovered References" had appeared in my project navigator. Probably due to a mistake I made during merging. The Group was empty and deleting it fixed my problem.

Xcode 8 can't open Model.xcdatamodeld

I am running macOS Sierra (Build 16A320), using Xcode 8.0 (8A218a) and have migrated all my code to Swift 3.
I can't open my Model.xcdatamodeld file anymore. Selecting it in the project navigator does not open up the "Core Data Model editor" view (not sure what it is called). I have tried restarting Xcode, but it does not work. I have tried deleting derived data, cleaning, does not work. I have tried double clicking, does not work.
Model.xcdatamodeld is visible in the Project navigator view, but it is not possible to interact with it (other than right clicking), nothing happens when I click or double click on it.
EDIT: Problem solved, see my answer below
Okay so I solved it... Hmm not sure why but seems like some part of the Swift Migration guide messed up the Model.
SOLUTION:
Remove the model from the project (was not even asked about trash or
reference, but delete reference if asked of course).
Re-add the file
This resulted in this Git change (screenshot from SourceTree):
As you can see, the Model.xcdatamodel (note difference vs Model.xcdatamodeld) file was missing! I guess it somehow got messed up during the -> Swift 3 migration?
Anyway, now it works! :)

Xcode- 7: No such file or directory

I keep trying to run my Xcode project (titled "YidKit") and it keeps giving me the following error:
error: /Users/Dani/Library/Developer/Xcode/DerivedData/YidKit-exnbjyxkgkbeaedoznkmtoenfijq/Build/Products/Debug-iphoneos/YidKitTests.xctest: No such file or directory. I spent several hours online, trying different solutions that I've seen, and nothing has worked. This is driving me crazy, because it is the only error left and I just finished getting rid of about 80 that were caused by Swift 2.0. I appreciate all of the help I can get!
UPDATE
Here is an image of the file in the explorer. The red one is the file that is giving me the error.
do following two things I might solve your problem.
Product -> Clean and build folder
Go to finder -> library -> Developer -> Xcode -> Derived data
delete that folder
or check screen shot may be this is your problem
and then check
TARGETS --> Build Phases --> search file --> delete redundant .m
For future reference
One way you can solve this problem is to open your Project with a text editor and search for the file there. It should be there the file path for it. Just delete it and any references that might exist of the file.
It should be working now.
Don't forget to BACKUP FIRST before doing this
Go to project, target, build phase
remove the files causing problem (click - below)
add the files again (File -> Add Files to Project)
clean then run
I'm sure you've figured out a workaround by now but for those still running into this problem the error is occurring because Xcode is trying to access a file for your project, but it can no longer find it. In your case the file it can't find is YidKitTests.xctest, so what you can do is click on it in the Project Navigator, then on the right in the File Inspector, click on the little folder icon under Location. When you click on the folder a Finder window will open up and its your job to navigate to where the YidKitTests.xctest file should be and double click on it. More often than not the file is in the exact place Xcode says it isn't, eg. /Users/Dani/Library/Developer/Xcode/DerivedData/YidKit-exnbjyxkgkbeaedoznkmtoenfijq/Build/Products/Debug-iphoneos/YidKitTests.xctest, but for some reason it can't see it without you pointing it out. I hope this helps!
I had a similar error popping up, and it turned out being the simulator was not being found. So, I deleted all my simulators and and added new ones. This fixed it for me. It's pretty unlikely this will be a fix for you, but I really wish I had seen this response 3 hours ago.
The solution which worked with me is as following:
Go in the left panel of the Xcode to products folder then select the Tests.xctest file
In the right panel of Xcode / Target Membership, unselect Tests
Click command u
Just delete the "Derived Data" folder and compile the project again.
Anyone tried the good old trick rebooting the computer? I tried and everything worked out fine! Give it a try
You should try to edit option in folder to show more you looking then you will see some error file inside after you find it delete it! Hope this help.

fatal error: malformed or corrupted AST file - Xcode

I get this error when building my app in the latest version of Xcode:
fatal error: malformed or corrupted AST file: 'Unable to load module
"/Users/me/Library/Developer/Xcode/DerivedData/ModuleCache/XYZYIE6ZV0OP/Darwin.pcm":
file not found' note: after modifying system headers, please delete
the module cache at
'/Users/me/Library/Developer/Xcode/DerivedData/ModuleCache/XYZYIE6ZV0OP'
1 error generated.
When I navigate to:
/Users/me/Library/Developer/Xcode/DerivedData/ModuleCache
I can see that the directory 'XYZYIE6ZV0OP' doesn't exist.
Does anybody know how I can resolve this? I cannot delete anything at the directory as suggested in the 2nd part of the error message as that directory doesn't exist!
Had same problem. Clearing derived data folder solved the issue for me. In Xcode, go to Window->Organizer->Projects, select your project, and press the "Delete..." button next to "Derived data".
If this doesn't work, you can try to do a Product->Clean (Cmd+Shift+k).
Press Command + shift + k or clean the project and then run project...
In Xcode select Product-->Clean problem will be solved
By default Library folder is hidden in Mac. Best way to navigate to that folder is :
Open Finder
Select Go from menu -> Select "Go to folder"
Type : /Users/"your user name"/Library/Developer/xcode
This will open direct xcode folder inside hidden library folder.
Select "DerivedData" folder
Command + A, select all and delete them.
Open Simulator and "Reset Content and Settings".
Now run XCode again, all will fix.
I had the same issue, solved it by cleaning the project.
Product-> Clean
or press
command+shift+K
In my case, I accidentally modified NSURLConnection.h. Xcode complained about cache at path
/var/folders/p6/fk2rmf017sn2d_gds6dtqr6hrst8b2/C/com.apple.DeveloperTools/5.0.2-5A3005/Xcode/5.0.2-5A3005/Xcode/ModuleCache/XWWWZ5ED888F
I finally found the steps to fix it:
Quit Xcode
Delete the upper "5.0.2-5A3005" at
/var/folders/p6/fk2rmf017sn2d_gds6dtqr6hrst8b2/C/com.apple.DeveloperTools/5.0.2-5A3005
When Xcode restarted, it regenerated that folder and everything in it.
I had the same issue ever since installing the latest SDK.
My solution was to delete the derived data and clean the project.
I got same error on executing xcodebuild command of Xcode6-beta5.app coexisting with Xcode.app (Xcode 5).
In this case I added -derivedDataPath to separate ModuleCache from the one for default Xcode.app.
xcodebuild -derivedDataPath ./build/Xcode6-beta5/DerivedData ....
This works for me.
I tried deleting derived data and Clean project several times and it doesn't work. The file in my warning is an old file I already deleted from Project Navigator and all the Build Settings. But it keeps showing up and gives me this error. The error only occurs on Simulator, but not on device. Which is really really weird. :/
For some reason, I switched branch to some other branch and switch back and it works again. If anyone even know how that could work please tell me :D
Simply clean remove the Derived Data and build folders. The problem shall be resolved.
In my case the SSD was broken.
You can verify the disk with apples Disk Utility
In my case I had a spaces in my plist file name.
I removed it, and changed Info.plist File key in target Build Settings
Refreash Safari browser, scroll down the page and you will see you "Click + button for add build ..." then add actual build, click Save and "Waiting for Review"
Cleaning the project and deleting the drive data didn't fix it for me. But what finally fixed it was changing the model of simulator that I used.
So first do a clean, then if you were running it on iPhone 5 simulator, run it on iPhone 5s simulator to fix the issue. basically, run it on any other simulator other than the one you were running.
(Credit to Hlung for his answer, I hope this one is a bit more clear)
If you have your project scheme set to "Wait for executable to be launched" this error might happen.
In that case, just changed your scheme from Product > Scheme > Edit Scheme...
In my case, I tried to archive a app in one project within a xcodeworkspace
close Xcode, the open the single target project, and clean an
Then, I do archive, it makes an iOS App archive.
I hope I can help someone.
Got this error while trying to build a third-party app for the first time. Adding foundation as a library fixed the issue for me.
I did Clean cached, Delete derived data, Manually delete the Module cache folders which found from the error logs, Restart xcode, Restart machine.
But non of them helped me.
But this steps help me to resolve the issues
Comment out all the #import line in [Name]-Prefix.pch files.
Build, as expected its pointing me to different errors.
Revert back the changes I have done in [Name]-Prefix.pch and Build, compilation succeeded.
This solution help me to resolve the issue.
if you can't find your "Derived data"
File -> Workspace settings
Click on the arrow icon next to your path
Remove "Derived data" folder
tried to re-install XCode which didnt resolve the issue, also created a new local user account & get the same error so in the end I gave up & restored to a time machine backup from a few days before... seems to be ok again... for now!

Resources