I'm trying to introduce Unit Testing to a project. The project compiles, builds, runs perfectly fine.
However, when I try to run Test, I get a failed compile error that a .pch file is missing.
I've cleaned the project, cleaned the build folder, and deleted the derived data before trying both those steps again. But every time, it fails with a no-such-file-or-directory /blah/blah/ProjectName-Prefix.pch error.
Any thoughts as to how I can stop it looking for something that doesn't exist? Or alternatively, make the file exist so that it can be found?
The problem was that the project had been renamed at an earlier date.
Searching the Build Settings for oldname and updating them all to newname means that it's now looking for the files in the correct places.
Related
I am currently developing a swift framework for my iOS class.
Here is the project structure :
I would like to test my class named SimpleCoreData, but when I go to the generated ESGISimpleCoreDataTests file, the import (also generated) isn't accepted:
Cannot load underlying module for 'ESGISimpleCoreData'
So I checked this other topic, and verified the targets, but everything seems fine.
framework:
tests build phases:
I am beginning in Swift, so I may have missed something obvious. Can you please help me with this one?
Finally, after examining each commit to see where it breaked, it turns out that the problem was probably coming from a unit test file I created, which had the same issue (probably didn't created it correctly), and then only removed its references instead of moving it to trash.
So I went a commit backward, used the default unit test file generated, and it worked.
Here's another variation on this theme. πΆπ΅
I imported a folder of files into my main project, and in that folder was a file which had import XCTest in it.
The compiler didn't flag this problem, and I didn't see it until I used finder (like CodingMouse).
Once I moved this testing file to the UITests folder and changed its "Target Membership" to the UITests Module, I did a clean and build to get everything working again.
So the takeaway from this is the compiler won't always point you directly to the actual problem. Using finder, scan through your files and confirm nothing looks suspicious or out of place. π
I have a problem in the project. After some moment I've realised that a lot of errors appears after indexing. All that errors are the problems with linking in the project (something like: use of undeclared identifier and etc. but when you cmd + click on the name of some buggy class everything is fine). After project is build errors disappear but then if I start surfing through the project, all errors appear again. It's very annoying.
Solutions that I've tried to fix this with no luck:
Clean the project
Clean the Derived Data
I think it's somehow related to Prefix.pch file. I've check that all paths in project file are fine.
Any ideas?
I was having the same problem I deleted the #import lines from the pch file and recompiled which failed as expected then rewrite the deleted line and build again and it compiled without any error
First off, I know this is a config issue because my code was building and running just fine before I synced my project to GitHub. Xcode's internal source control seems to be having trouble recognizing some of my files and I'm getting Use of unresolved identifier... errors where these files' initializers are in use, and were working before. I'm running the latest versions of Xcode and OS X, and these are the steps I was taking before and after the issue started...
BEFORE:
After several rounds of implementation and committing with the default local repository, I built and ran the app multiple times with no issues.
I created a new repository on GitHub, committed (w/push to remotes) and everything made it to GitHub just fine and was building and running in the simulator.
In order to organize the repository (to match the 'groups' I had created in Xcode) I did some brief research and then added nested directories to my project folder. I re-opened Xcode and repaired the file paths. Some took, but several kept showing ? (although I could still access the code just fine) and I got the corresponding Missing Files... warnings.
Because I couldn't get the new hierarchy to work (the files w/?s, not being recognized, were not able to be committed to GitHub), I tried to move the files back. This worked for most, but for a few (which seem to be the effected files) I had to rename them, recreate a new file and then paste their contents over (this is where I think the problem lies). I was able to commit everything to GitHub (even the problem files went up) but all the warnings remained.
To clear out the warnings I attempted to run my tests, and that's when the Use of unresolved identifier... errors popped up, and of course the build failed.
AFTER:
I verified all the paths and target memberships were correct.
When that didn't work, I built an entirely new project (although I did add it to the same workspace; not sure if that matters) and copy/pasted all my code over to new files. I didn't drag / reference the files and I didn't link the new project to GitHub. When I went to build, same errors in the same places...
I exited the workspace and opened the new project separately. Still no joy.
Any help or points in the right direction would be much appreciated.
EDIT:
After some help, I tried deleting the reference and dragging the file in manually but that didn't resolve the issue.
I also checked Build Phases -> Compile Sources and everything was listed fine with no compiler flags. I removed and re-added from Compile Sources, issue persists.
You can try removing referencer for the missing class file in Xcode,then add same file to folder (right click add file ) from physical workspace location this might help.
After rebuilding an entirely new app a third time, with all new files, I copied the files over and this time everything seems to be working fine. Had to repair a bunch of provisioning issues to make sure it worked (maybe that was part of the problem, but I doubt it), but everything is back to normal with the app. The only thing I did differently this time was not adding the new project to the same workspace.
I was reading the document of XCTest(and personally i think the documentation for this part is not that enough) and I thought I should give it a try for a new project(a MAC command-line project, not and iOS project). and then I faced complaints about linking issues--the test case building failed because the conresponsding class .o(if I am not wrong) files are not found. (the error mes here was not recorded by me, sorry)
Then I wanted to delete the test project and in the end I did not even manage to remove the test project. So seriously, how to remove an exsiting project from the solution if the notion in VS applies here?
After failing at that, I removed the auto-generated test file and created my own test case file and strangely, although Xcode detects the existence of the new test case and test method, the build failed and it failed with no issues--no linking issue, no syntax or whatever issue but it just failed. Now I do not know how to move on now as I do not even get a complaint or an error.
I don't know enough about the state of your project to be certain what the problem is, but here is something to consider: If Xcode added a new build target for your tests, be sure that the .m files that contain the classes you are testing are included in the new build target. You can do this by clicking on the relevant .m file in the Project Navigator and looking at the "Target Membership" in the File Inspector pane. Make sure the box is checked next to the test target.
I loaded a long-dormant Xamarin.Android project that I last opened in MonoDevelop, when it was still called Mono for Android. Every time I tried to build the project, debug or release, it fails with "Error: duplicate class" pointing to R.java.
Since R.java is just an auto-generated file for the various project resources, I tried editing a filename and letting Xamarin Studio update the file. This didn't resolve the build error.
Similar searches find issues with improperly named IDs in an axml file, but all the IDs in this project appear to meet Android requirements (and it built fine the last time I worked on it to generate the project's APK).
Deleting the project's bin and obj folders entirely and letting them be rebuilt from scratch resolved the build error just fine.
Since the actual R.java file is buried deep in the obj folder, it may have been possible to be a little less eager with the deletes. There is probably a better solution entirely, but this certainly got the job done.
delete all files and folders from your c:\users\\appdata\local\xamarin\
Restart VS - very important
Clean Solution
Build / Rebuild solution
If the above ends up with some other resource errors , close and reopen VS and repeat steps 2,3,4.