Copied Xcode Project won't build - objective-c

OS X Version 10.10.5
Xcode version 7.2.1
Very simple steps, yet Xcode can't fathom what to do when you duplicate a folder that contains an Xcode project.
Start with Xcode CLOSED.
Start with an Xcode project that builds and runs perfectly.
Go to Finder window and right click on the directory that contains the buildable Xcode project and hit "Duplicate"
New directory is created, called "SomeProject copy"
Go into this new directory and double-click on the SomeProject.xcodeproj file to open it in Xcode.
Bam... enjoy your build errors.
In my case, it's complaining about an enum.
Tried deleting derived data folder (did so directly using finder)
Tried super-cleaning the build folder by holding down the option key.
Tried removing and re-adding complained about file that contains errors.
Tried changing path to file in Xcode File Inspector from "Relative To Group" to "Absolute Path"
I should also point out that either Finder -> Duplicate doesn't actually do what it says it does. Neither does Finder -> Copy, ~OR~ Xcode for some reason has now adopted not only the original source location as where to get its build files, but also the new location, hence the "Redefinition" error. I noticed that if I open the "copied" project and edit a file, then go back to my original project in an entirely different folder, the file is changed THERE.
And my paths (according to Xcode File Inspector), are RELATIVE TO THE PROJECT IN QUESTION. So in other words, ProjectAAA's files are pointed to the path under ProjectAAA's directory, and the same with copied project, ProjectBBB's files.
So somehow, the copy/duplicate is refusing to actually copy/duplicate.
Any ideas how to solve this?

Per John Elemans comment, moving my original project then revealed in the copied Xcode project a number of build paths and issues that needed resolving. I fixed those, and it worked as expected.

I solved this issue as follows:
After duplicating the root folder of the project, open the podfile of the duplicated project:
Podfile
then comment all the previously added pods by adding "#":
Commented Pods
hit CTRL + S in order to save the changes
Open the terminal and change the directory to the folder of the duplicated project and then perform: "pod install". Yes it will delete all the pods but don't worry we will install again in the next step
Pods deletion
Open again podfile and uncomment the previously commented pods:
Uncommented pods
hit CTRL + S to save the changes
Open the terminal and change the directory to the folder of the duplicated project and then perform "pod install". it will install again all the pods:
Pods installation
Finally, run the Project and it should run without any problem.

Related

In IntelliJ, How Do I Fix "These Files Do Not Belong to the Project"?

I recently put several old, yucky git directory structures into one new, clean structure in SVN, then pulled the entire SVN repository back out into a new, clean, local git repository. One IntelliJ project was so messed up I had to import the old IntelliJ project, which created a new .iml file having a better name, and deleted the old .iml file. I reconfigured everything, committed back into SVN, and verified other people could open the project and build.
Today I tried to edit a file for the first time in this project and got the message, "These files do not belong to the project". IntelliJ offers to unlock the file or all non-project files in the current session, but both options sound wrong. What have I done to myself, and how do I fix it?
This happened for me when I ignored the .idea/ files. Just do
rm -rf .idea/
And then File -> Invalidate Caches/Restart -> Invalidate And Restart.
I figured out the problem. The file was still open from before all the shuffling, and was apparently pointing at the original file in its original location! I closed the editor and reopened the file from the project tree without a problem. I hope this helps someone else someday.
From File-> Repair IDE -> Rescan Project Indexes -> Reopen Project worked for me.
Had same problem on Ubuntu (Webstorm), got answer from Intellij.
There are no content roots in your project, so all your files are
treated as non-project files. As I wrote your .idea files are likely
broken, the .iml file and/or modules.xml are either missing or
corrupted. Deleting and re-creating .idea folder should help:
-close the project
-remove it from Recent projects list
-shut down the IDE
-delete the .idea folder
-restart, open the project root folder with File > Open
https://intellij-support.jetbrains.com/hc/en-us/requests/3779670?page=1
This also happened for me when I opened the project through a symlink (parent directory) or when the python interpreter was inside a symlink directory (because of virtualenv).
Reopening through the original directory tree (after fighting hard with the IDE to forget its beloved project settings), solved the issue.
It's probably listed in one of the XML config files in .idea/*.xml.
Just do a find of that folder for the name of the file in question, and remove the entry for it from the XML.
Mine was listed in .idea/workspace.xml within the following node: <component name="TypeScriptGeneratedFilesManager">.
I removed the option, then invalidated caches and restarted, and now the file is marked as a standard, non-generated file again. This way you can keep all your settings without exporting them and importing them.
Similar issue with WebStorm. The difference was I had to shutdown the IDE completely and then remove .idea folder
rm -rf .idea
I tried doing it with the IDE open and going to file File -> Invalidate Caches but that did not fix the problem for me.
Same problem. File was considered not part of the project even if I deleted it and created a new one with the same name.
To fix,I highlighted the project node in the left panel, selected "File/Invalidate caches and restart" from the top menu.
After the restart I had to set my file as a JS file (right click, set as JavaScript), close and reopen the project. All fixed.
For me the above did not help. I ended up going Project Structure -> Modules -> + at the top narrow middle column -> browsed through files to select the Project Folder -> apply -> ok -> all is done and working correctly.
My problem was much simpler than expected: I was trying to run a Jupyter notebook and got the error - because it was inside a folder that was marked "excluded" in the project structure.
Simply moving the notebook out of the excluded folder solved my problem.
In my case it was auto-generated .gitignore, I had entries like:
### npm ###
node
node_modules
frontend-dest
data/
And in project files I had java package called like com.company.test.data which matched last pattern. I strongly recommend to check it before removing .idea/ files and invalidating cache.
This warning is an IDE issue that Android Studio cannot recognise the current directory if it does not include any source files.
So, adding am empty source file, e.g empty_xxx.c under the directory in question and adding below line in CMakeList.txt
add_library(${TARGET_NAME_XXX} SHARED ${SOME_DIR_HAVING_THIS_WARNING}/empty_xxx.c)
will help get rid of this warning.
In my case the above methods didn't help, I just deleted .idea file in project and reset the Jetbrain IDE to default settings and it worked normally.
NB: You will loose all your settings and plugins, but if you don't mind this might help as the last resort like in my case.
I am using Jetbrain,
make sure to include all project files in the project. Use Settings -> project structure.
PyCharm > Preferences > Project > Project Structure > Add Content Root
Somehow PyCharm lost the project root directory in my case
For me it was because I had moved a project to wsl by copying the files from wsl to windows. When I switched branches the file must've been open from before and was the windows version of it and not the wsl one.
I noticed this finally by looking on top of the file tab and seeing the path as C:\User...\filename instead of \\wsl$....\filename.
Close your JetBrains IDE, then open a Terminal window and navigate to your project's root folder, and run these 2 commands:
rm -rf .idea
and then
rm -rf .git
NOTE: you'll probably have to connect your project back to your git repository, so if you have any uncommitted changes make sure to commit and push them beforehand to avoid losing them.

Can't see project folders in IntelliJ IDEA

Every once in a while, I open an old project and I can't see any of the folders in the intelliJ project viewer. I can see all the files at the root.. but no folders. Yes I can delete the .iml file and .idea folder and re-create the project, but come on.. there's gotta be an easier way to fix this.
Is there?
If you look in project settings (ctrl-shift-alt-s), you should see a module structure. If you instead see "Nothing to see", do the following:
In Project Structure -> Modules, press the + button,
press enter (since, for some weird reason, it won't let me click on "New Module")
In the window that pops up, click on the "..." next to Content root, find your root folder, and select it
Press ok
ignore any warning that says the name is already in use (or to that effect)
the simplest solution worked from me, just delete the .idea folder
keep in mind this will delete all of idea's current project configuration, it'll create the folder with default settings when reload the project again... but all other configuration will be lost if not properly backed-up
It might be because the project didn't have any modules defined. Try adding existing source code by hitting File > New > Module from Existing Sources and select the parent directory of the project for source code
Go to pom.xml file -> right click -> maven -> generate source and update folders. You will see your files and folder structures in left hand side.
All the project-specific settings for a project opened through Intellij IDE are stored in the .idea folder.
The .idea folder (hidden on OS X) in the solution root contains
IntelliJ’s project-specific settings files. These include per-project
details such as VCS mapping and run and debug configurations, as well
as per-user details, such as currently open files, navigation history
and currently selected configuration.
So, if you are not able to see the project file structure in your Intellij IDE, just delete the .idea folder,
rm -rf .idea
and reload the project, then after reload you'll be easily able to get your project structure displayed.
Thank you very much. I just remove the .idea folder and works in my case.
rm -rf .idea
For me, the java folder was not showing up. I went into File->Project Structure. In the second column, I selected on _main. In the third column, I selected the tab "sources". In what I call the fourth column, where the "+Add Content Root" is shown, I verified, the java source/folder was present. In my case, there was an extra source folder, which was the current location. I removed this, applied and the java folder immediately showed up.
Right click on the Project name -> Open Module Setting -> Check the application context path set it up at your project location.
Check your idea.log -- it may have some details explaining why or what is happening (Help | Reveal log in Explorer). Possibly one of the config files got corrupted.
You can always backup and delete .idea subfolder (project settings) and re-create project from scratch. When it's wroking again (after basic configuration) you may copy some of the files from that folder back to recover some of your settings (if there were many).
This happened to me on a new computer when I opened up a Java project in the newly installed Intellij.
The problem was that I had not installed any JDK on the machine.
I had to install a JDK and then go into the settings at ctrl-shift-alt-s and add a JDK by specifying the folder where I installed it. It's possible that IntelliJ would have found it if I closed it and reopened it.
In my case the solution was to create a new project, specifying the project type and creating it within the same directory path as the project that does not load the project files correctly.
PhpStorm automatically detects that the directory exists and gives you the option to create project from existing sources.
This can be found under:
File --> New project...
For gradle users: "Reload All Gradle Projects" option should help.

XCode 6 Crashes on Source Control

I am getting very frequent crashes on XCode 6.01 especially when ever I try go to Source Control. I am using SVN.
Is there a workaround I could use ? Is this a known issue ?
It is probably related to the .xccheckout file.
If the project is a xcworkspace, it is located in the xcshareddata folder inside the xcworkspace bundle.
If the project is a xcodeproj, it is located in the project.xcworkspace folder in the xcodeproj bundle.
(The following trick seems to have fixed it for me:
quit Xcode
locate the .xccheckout file
revert this file to what is was when last saved with Xcode 5
reopen the Xcode project. If Xcode prompts for checking out the project from svn, do not press the ignore or cancel button, instead press the next button. In my case, it checked out another copy of my project from svn and the crash does not occur anymore.)
Step 1: Open terminal
Step 2: cd to your project's home directory
Step 3: Use commands below
http://www.linuxfromscratch.org/blfs/edguide/chapter03.html

XCode 6.0.1 error when creating project: The file "exclude" doesn't exist

When I create a new project in XCode 6.0.1, I got this error message: The file "exclude" doesn't exist
It seems to only impact the versioning of the files i.e. the generated stub files are not committed into github after the project is created.
What can cause this problem?
For me the issue was caused because I had previously created a project with the same name, and Xcode still had record of that.
To clear it out,
go to Window -> Organizer in the menu bar
Remove all of the repositories highlighted in red
To add your repository (if it's not being tracked for some reason),
Click the + (still in Window -> Organizer from the steps above)
Enter the path of your file
Make sure to change to Git from Subversion (if Xcode has Subversion set as default - it did for me.
I usually get this error if I initialize an Xcode project with a git repository, delete it and try to recreate it with the same name (casing doens't appear to make it sufficiently 'different'). Turns out, "Well I'll just start over" can leave some issues as well.
Hope this helps.
I had this issue as well, and I tracked it down to the .git-template folder included with Thoughtbot's dotfiles. Basically, Xcode expects its template folder to have info/exclude, and Thoughtbot's dotfiles don't. Creating that directory and file fixed the problem, as so (in the Terminal):
cd ~/.git_template
mkdir info
cd info
touch exclude
If you're getting this issue without Thoughtbot's dotfiles, you could probably look at ~/.gitconfig and use whatever templatedir is getting set as instead of ~/.git_template in the first command.

xcode searches for prefix.pch file in wrong directory

i made a xcode project and changed the name of the folder in xcode as well as in finder. then i proceeded to relink them via the method shown here: Renaming xcode 4 project and the actual folder
so originally the folder was weatherScan2 which i renamed to weatherScan and xcode shows that there are no issues. However when i click build, there's a clang error that says:
no such file or directory: '/Users/user/Documents/Xcode/WeatherScan/WeatherScan2(thisis the folder that i renamed to weatherScan)/WeatherScan-Prefix.pch
clearly it should be looking for the pch file in weatherscan as there is no longer any weatherscan2 folder in existence. How should i redirect this?
i already tried deleting the pch file from xcode and then readding it but the same thing happens. what part of xcode is trying to look for the pch file in the old place and not the new renamed folder? all the other files seems to be working fine.
ok, i realized the issue was in the target/build setting section where it still shows my app looking for the info and pch files in weatherScan2 folder. i edit that and everything works.