Correct way to copy Swift project without altering old project? - swift

I was wondering if there was a correct way to make a copy of a Swift project?
I realised that when I want to make a copy of a project (so that I can have a backup working copy when I continue with my project and I make a mistake) and I use that copy; the copy alters the build folder of my original file. Not only that but if I re-name classes or change IBLabels/IBOutlets, and although the change isn't reflected in the original code; when I compile the original file there will an error associated to an undefined class or the xib file would be changed which would also throw an error. At the start the original file compiled, but after working on the copy of the original file and running into an error. The original file also wouldn't compile, any ideas on why this happens? And how to fix it?

Though #Daij-Djan's answer is correct you need to watch for added files with relative paths. So what I do for a backup is to use git. That works better than any backup.
If you really want a copy, just copy the folder with the project with CMD-D which creates a <folder> Copy (or whatever is your localization). You can rename the copy, but leave the contents untouched. Also do leave it in the same folder as the original one to avoid conflicts with relative paths.

Just copy the whole folder from a to b!
IF you used absolute paths in your xcode project though .. bad for you :/ your project references the original files no matter what
what you can try is fixing the project.pbxproj xml file manually. this is doable but not supported by xcode really :/
IMHO if a copy isn't enough because you messed up the project with absolute paths, readd all files MANUALLY and make sure all is relative to the project location

Just zip your current project & extract it inside your new project folder & enjoy....

Related

Unity project folders missing

i found an old unity project but the "standard project folders" such as
"ProjectSettings"
"UserSettings"
"Packages"
ecc.
are missing.
here it is the folder screenshot
the only folder that i have is "Assets". is there a way to find the missing folders?
maybe they are stored somewhere else in the disk and linked to the project? (i don't know if it's possible)
the project in this state is corrupted and not usable, is it possible to fix it?
Try creating a new project, and replacing the "Assets" folder of the old project with that of the newly created project.
Unity has changed the structures of its projects over the years, so it is normal that after many years you cannot open it.
When you open the project with the old "Assets" folder, remember that you will have many errors to solve: you will have to add all the packages you entered, and modify the opsoleto code.
I checked the folder further, and saw that there are actually no normal assets such as scripts, images or audio in the "Assets" folder. Without those you can't get it back.
I am sorry.
I write another answer because the first one is valid for all cases where the "Assets" folder is intact.
You can decide which one looks best for you.

vscode: changing a file modifies it in temp folder, I cannot make changes to files outside of the temp folder

I have a file built by somebody else. I am trying to append lines to the end of it.
When I do this and hit save, everything seems to work. But the only change has been in the temp folder, which seems to be a copy of my real folder. No changes occur to the actual file. This means that I cannot do development in vscode, since I cannot actually modify files.
How can I fix this?

Organise my project folder

It's a terrible mess in my project folder (not in xcode, where all is clean, but on the desktop folder).
How can I organize this folder without killing all xcode references ? I just tried, but all the links broke.
Thanks,
What I'm used to do in this case is:
Organize everything in my finder folders, don't mind the red missing files in xcode. If you are using svn, make sure you use its commands to do this.
Then I go to each file in XCode marked red and redefine its Location using the right pane Utilities tab (xcode 4) or its file properties(cmd+i in xcode 3).
Clean and build to make sure everything is OK.
To avoid this, I got used to organize my project each time I create a new file/folder. I first create the folder physically and then add it to xcode, later I create the files.
I don't know a simpler way of doing this.
Hope it helps,
I've been there myself :) You do need to remove and add back in the files that need organizing , but it can be safely done. Here's what I'd normally do;
Remove the files / folders you need to organize from within your XCode project (this is safe, you can add them back, no worries) ONLY DELETE THE REFERENCES when asked. Do NOT Trash them.
Close XCode
In your desktop folder, now arrange and organize your files and folders as needed.
Open up your XCode again, and open your project. Now, re-add your now well-organized files and folders back into the XCode project. Copy them into to your folder if you happen to be adding anything from outside the desktop folder.
Now, your project will be well organized both in and outside.

Renamed Files Still Exist in Xcode

I'm making an iphone app that displays a random picture chosen from pictures in Resources.
I have renamed some files for categorization,
but running console shows that file with a new name and file with old name both exist as separate files.
Of course, I can't see the file with the old name in my Resource folder, nor in the original folder where the pictures are.
Kinda freaky...
How could I remove the files with old names and make it a norm to not keep another file with the old name whenever I rename a file?
Please help me out.
Thanx.
Expand your Target and remove the images from Copy Bundle Resources.
I'm not sure I understand your question correctly, but I recommend cleaning your targets from the project menu and resetting the simulator.
You can also select all the new files in XCode, right click and select compile.

How do I properly add existing source code files to my Xcode project?

I'm new to iPhone development and I'm still getting familiar with the Mac dev environment, including Xcode. I want to add some 3rd party code to my iPhone project, but when I add the "existing files" to my Xcode project, I'm presented with a dialog box that has far too many options that I don't understand and, as such, my project isn't working. When I #import headerfilename.h, I get a build error that reads headerfilename.h: No such file or directory.
alt text http://joecrotchett.com/images/misc/fileadd.jpg
Can anyone explain to me what all these options mean or give me a link to some documentation that can? I'm having a hard time finding anything in Apple's docs.
Which options do I want to choose to add existing source code files to my Xcode project? I should note that the source code files that I'm trying to add are located in my project/Classes/frameworkname/ directory.
After they're added, do I need to reference this new code directory in my project settings anywhere (i.e. some kind of header file directory variable)?
Thanks so much!
Update: I found the following answers/responses on the apple dev forums that were very useful and helped me fix my issue...
To make it simple :
- if you do not check the copy option, the file stay where it is.
- if you check it, it is copied in your project folders In the first case
(what it seems you are doing) you need
to tell the compiler that the header
files are in another directory :
- project info -> build -> search paths -> User Header Search Path : add
the directory from where you took the
header file Hope this will help
You have discovered the most confusing
dialog box that ever came out of
Cupertino. Six years of Xcode, and
this thing still is partly a mystery
to me. To even get that far, I had to
make many test projects to try and
reverse-engineer what this thing does.
The "Copy" box means that it will copy
the files as they are right now, into
the project. If this box is not
checked, then it just references those
files during a build and copies them
as they are at THAT time. For source
code, you want the Copy box checked.
The "relative to" is a total mystery
to me and I can't help you with that.
I usually leave it however it is
already set. Does it mean relative to
where they are on disk, or the
arrangement in Xcode, or in the
bundle? Who knows. The last 2 radio
buttons SEEM to mean that it will
either re-create the folder structure
of the folder you are adding, or just
put "fake" folders in Xcode that point
to the real folders. This is probably
your problem - you are adding source
code that is not all at the top level,
and when it goes to find it, it does
not re-create the hierarchy. Others
can supply a better way, hopefully,
but what I would do is put all of the
source in one folder and add that,
using the Copy box. Then in Xcode you
can make whatever bogus folders you
want and put the source file names in
those fake folders.
This is from the Xcode user guide:
"The project navigator shows projects, groups, folders, and files:
The project or projects in your workspace window are the highest level
of the hierarchy in the project navigator. Open the project’s
disclosure triangle to see the groups, folders, and files in the
project. Select the project to display the project editor, where you
can view and edit project and target settings.
A group appears in the project navigator as a yellow folder icon. The
group does not represent a folder on disk. Although you can organize
your project in Xcode to reflect the organization of files on disk,
moving files into and out of groups does not affect the content of the
folders on disk, and moving files on disk into and out of folders does
not affect the content of the groups in the project navigator.
A folder is a reference to a folder on disk and appears in the project
navigator as a blue folder icon. The contents of the folder in the
project navigator reflect the contents of the folder on disk. It’s
important to note, however, that the files that appear in a folder
icon in the project navigator are not part of your project unless you
have added them to the project explicitly (in which case they appear
directly under the project or in a group, as well as in the folder).
You can view and edit the files in a folder, but to move files in and
out of the folder you must use the Finder.
A file in the project navigator is a reference to a file on disk."
I think usually the default option is the best one. If you want to add into some group, you can tick on the "Copy Item to Destination group"
You don't have to change any project settings after adding
And if you want to add the whole framework code, please choose add existing framework
Copy items into destination group's
folder (if needed)
Well, only if you want it to copy the files. If you are happy with their existing location and don't want it to copy them, don't select it (that's what I do).
Reference Type:
A total mystery to me
Text Encoding
Self explanatory
Recursively create groups for any
added folders Create Folder References
for any added folders
Leave this as the default and then organize the folders in your Xcode project any way you want.
Add to targets
If you add an additional target to your project, e.g. for iPhone vs. iPad versions, then not noticing that it has by default added the files to just one of them (at random?) can cause headaches.
Also, make sure you add the new header directory to your search paths in Project Settings > Build > Search paths. I think that's what's causing your problem.
Hope this helps, I remember how confusing this was to me at first.
If you want to add an Framwork Bundle, just add is as one. Add -> Existing Frameworks