How to copy a XIB to another project? - iphone

Simple. I have two projects in Xcode. In one of them I made a .xib file and I want to copy it to another project, so as to save some time redoing it.
I can't drag it to the other project, nor do copy/paste by command, nor copy/paste by the Edit menu.
Any suggestions?

Go into finder, find the .xib file and copy it to the directory of the second project. Then uses add existing files to add it to the second project.

Just drag and drop from one project window to the other.
Make sure that you check the "Copy items to the destination folder"
If you have more than one targets make sure that you check the appropriate target when you add it.
You probably have to reconnect all of your outlets, and if it crashes for some reason it means that there are connected outlets/actions which are not available in your code.

Here is how I managed to do this with XCode 10.2.1
Close the XCode project with the xib file you want to copy.
Drag the xib file from finder over to the new project. Make sure you tick the copy items if needed box.
If the xib file uses images for outlets, also drag the images to the new project.
There is no need to reconnect the outlets.

Related

Adding Files to Xcode project

Trying to add file to the project!
Right click on the subfolder and selected add file to projectName. I added file which are required into my project[Destination unChecked and selected folders Create groups for any added folders and selected Add to Targerts projectNameTest], and close the xcode and reopen! the file which are added to the project is not appear's. Then again right clicked on the project selected add file's from 'workspace' and add to project [repeated same scenario] And close the xcode still files are disappearing from my workspace.
each time i need to add the file again and again from the work space. When I close the Xcode.
what i need to do for this issue so When i Open Xcode the files need to be appears into my workspace
What i do generally when I need to add extra source files to my project is :
1. Drag the file from source to my project.
2. I add Tick mark to the "Copy items into destination group's folder (if needed)" option.
3. Now i can seed added file into my project.
Hope!! this helps.
If you want to add files with a CLI, as I do, since I use a remote mac for development, you can check XCodeControl at github. This method is much faster than licking somewhere, at least if you hung over ;)

can not find nib (xib) file

In my project there was a file named view controller.xib. I deleted a button from that and an window appear I select move to trash. And after deleting that control, I can't find my xib file. But my project is building successfully and running properly with that view. but I can't find that file in project and also from the project directory. How can i recover that xib file.
Need Help.
Thanks.
Actually when you pressed delete button, your file.xib was selected from project, instead of deleting that control button, your Xib file was deleted, by clicking this dialog button.
Now your file has been removed from your project. Look carefully what is being used instead that file.xib. may there is still another file under the same name, or you are using another file instead of this one.
As concerning the recovery of your file, you can have a look at these posts:
Recovery deleted files from Xcode
Accidentally deletion of classes from XCode 3.2.5
Check the Spotlight . Type the full name of the xib file with the extension . If you have not deleted it permanently and only clicked on "Remove Reference" only, then there is the possibility you'll find it. Else its gone , sorry.
Please check in your project folder. you might have removed only its references, search for the file name and add it to your project .

Drag and drop XCodeProj into another XCodeProj not giving me the option to copy

I'm trying to "install" core plot 0.4.
The first instruction is to drag and drop the XCodeProj file into my own project. I do this. Normally when I drag and drop images or the such like it asks me if I want to copy the file into my own project. However for some reason its not asking me, its just creating a reference.
I'm not sure what the difference is, and whether it will still work or not with a reference, its just the first instruction (http://recycled-parts.blogspot.com/2011/07/setting-up-coreplot-in-xcode-4.html) says to click the "copy into folder" checkbox.
However that whole dialogue doesn't come up. I drag and drop and it puts the xcodeproj into mine without anything happening!
confused lol
Thanks
Edit: My solution works, but the reason it works is in this answer: https://stackoverflow.com/a/5373575/264947
--
This is what I did to fix it:
Close Xcode.
Open Xcode and create a new workspace.
File > Add files to "Workspace".
Add the first project.
Build to make sure it builds correctly.
File > Add files to "Workspace".
Add the second project.
Build to make sure it builds correctly.
Drag one project into another.
Now, be careful with the next step:
Erase the second standalone project but choose **REMOVE REFERENCES. **
There. Now you should have one project as a dependent of another project.

How to add bundles and resources like images in that bundle in iPhone

I created bundle using i-phone-OS->resources->setting but I am unable to add images to this bundle. I tried dragging images folder or by adding existing to folder but nothing works.
Thanks in advance
The Settings.bundle is added as a folder/bundle reference and not as a group.
Thus you won't be able to easily add some content to it right from the Groups & Files panel in Xcode unfortunately. Instead, go in the Finder, right-click (or ctrl-click) on this Settings.bundle and select "Show Package Contents" then drag & drop files in there. You will then find the added files back in Xcode.
I also find this kinda anoying in Xcode3 that we can't add files to '.bundle' folders/bundles directly from Xcode3 :( But AFAIK there is no other solution
One your file has been added to the '.bundle', you can edit them directly from Xcode. (Going thru the Finder is only necessary for adding new files to it)

What's the best way to copy xib file(s)?

I have a ViewController.xib that I would like to duplicate so I can make some settle changes to the duplicate copies. Everything is laid out how I like it in interfaceBuilder and coded correctly in the original ViewController(.M & h.). Can this be done and what is the best way to do this?
Sadly, there isn't a way to directly duplicate a file from within Xcode. I've submitted a bug to Apple on this and you should too. It's not too difficult to do manually, though:
In Xcode, right-click on the xib and choose "Show in Finder"
Once Finder comes up with the file selected, right-click on the file and choose "Duplicate"
Rename the file as you need
Drag these new files back into your Xcode project.
Using FINDER, duplicate all three files and rename them.
Drag them back into the project in Xcode.
Rename the Class in the .h & .m files & start making your subtle changes.
However, if your changes are all just to do with positioning you could just use the one file and change the frames of the things you're moving about
OR
Just duplicate the XIB file, rename it appropriately, add to the project & make the subtle changes. Then you can load the ViewController with whichever XIB suits your needs...