Adding a Supporting File to xcode project - ios

I am new to xcode, and development in general. Following a tutorial that tells me to add "file.plist as a supporting file to the project."
Does this just mean add a file to the project? I placed it into a folder (BT_Config) that has the another .plist file in it already). Not knowing anything about my project, does that sound right?
I can't find a clear google reference to "xcode supporting files" - so i'm not sure.
Any suggestions?

You need to add it to your Xcode project. Xcode will then copy it into the file system folder if needed. Just open your project in Xcode and drag your file into the left sidebar. It doesn't matter where you drop it, but supporting files are usually added to the 'Supporting files' group.
If you want to create a new file, just use the 'File > New > File...' item from the menu bar.

Related

xCode won't list storyboard or info.plist for localization

I'm trying to localize an iOS app. According to all the tutorials, one of the first steps is to add localizations to the info pane of the project editor. When I get there, "use base internationalization" isn't checked by default. When I click it, the window "choose files and reference language..." comes up as expected, but it doesn't list any files--i.e. there are no choices for files to localize.
The app builds/runs fine. My storyboard is named "main.storyboard" and is in the project's main folder, so I'm not sure why xCode wouldn't recognize the file.
Of note, the project has gone through a re-naming, and I've been through a couple abortive attempts to localize after adding a language without the base, with the idea of adding the base later. But it looks like that takes me off track, and I had to undo those attempts; in the process, I manually deleted the .lproj folders that had been created.
Any ideas on what the problem is?
Important: Before you do any actions, keep backup of your project folder.
When you select use base internationalization, Xcode will look for User Interface files (Storyboard, Xibs) inside any *.lproj folders in your project. But in your case it won't find any *.lproj folder.
Steps to fix:
Create a "en.lproj" folder next to the storyboard using the Finder.
Then move one UI file like the main.storyboard (or other UI file) into the new folder.
On Xcode, relocate the storyboard file. One way to do it is to remove the old reference to the storyboard file. (will be in red) and re-add it to Xcode.
Now you will see that this file has "English" localization selected.
Retry now the 'use base internationalization' button and it should suggest you to move the main.storyboard to the Base.lproj which it will create for you.

Bad references of files in a XCode project

I'm trying to copy/paste my XCode project in an other folder of my Mac but when I open it in the new folder, all the files are in red like there was not in the project.
But the files are in the good arborescence of the project.
I already try to delete them and add them but it still doesn't work :/
You have only the reference now! delete those files and drag them to the project again, while doing so, please select the "copy items to destination folder" option

Find missing files in Xcode

I am re-arranging files in my file system for my Xcode projects. Therefore, when I open the Xcode project, all of the files are red.
I can add each file manually, but is there a way for Xcode to quickly find these files for me? All of the files are located in one directory.
If you have a bunch of missing (red) files that now live in the same directory, you can improve on the "fix each path individually in the inspector" method by selecting (Cmd-click) all the files at once. You'll see "multiple values" in the inspector, like so:
Clicking the button under the Location dropdown will bring up a directory selector -- note that the prompt says "Choose folder containing..." rather than "Choose file and location".
As far as I know, Xcode doesn't have a way to automatically locate moved files. You can reconnect a reference to its file using the Inspector (panel on the right) but it is somewhat tedious to do so. In your case, it would probably be faster to simply delete the references and then add the files back to your project.
I agree with the answers already given. In a real pinch, or as a last resort, you can open the project file in a text editor and fix the path references by hand.
Close the project in Xcode
Backup the project file someplace safe
In the Finder, right-click on the project file and select "Show Package Contents"
Drag project.pbxproj to BBEdit (or TextEdit or whatever)
Edit whatever "path = xxx" references you want
In this case i do this steps:
1) Add a new group with name Res
2) Click "Add Files to ..."
3) Find a folder with resources, and click CMD + A
4) Set check box on "Create folder references for any added folders".
And in source code i use e.g. "fonts/font1.xml".
5) Then for refresh, i just Removing a Res group references
6) And do steps from 1 to 4
Hope this will be a useful

Moving localization folders in Xcode 4

I've recently upgraded from Xcode 3 to Xcode 4.2, and migrated an existing iOS apps to use this new version. This app is localized, and I now want to add another language.
Under Xcode 4, when I add the new localization, it creates the country specific folder in the project root. For example:
/fr.lproj
All of my prior language folders are in a Resources sub-folder, however. Such as:
/Resources/de.lproj
/Resources/en.lproj
For the life of me I cannot figure out how to get Xcode 4 to move the new language folder to Resources. There is no GUI option I can find. If I move the physical folder using Finder, Xcode just changes the reference to red, but gives me no option to fix it.
Can anyone help?
UPDATE:
Here are a few screenshots demonstrating the problem (using Chinese this time):
The file listing:
The identity section for that file. Note that I can't change it:
Found the solution. It's not pretty, but it works.
Here's what I did:
View the contents of the .xcodeproj folder in Finder
Edit the project.pbxproj file
Search for .lproj within the file
Change the path = section to include the Resources part of the path.
Save, then restart Xcode
This smoothed everything over, and allowed the Localization to reside in the Resources subdirectory.
Here's a way how to solve it w/o editing .pbxproj file (Xcode 4.6.3):
select localization parent file (Localizable.strings)
Utility pane > Identity and Type > under Location (Relative to Group) choose path icon and set required new location for localization files
Finder > move all your en.lproj, fr.lproj, etc subfolders to that chosen folder
UPD: doesn't work in Xcode 8 :(
This way works on Xcode 5.1 also (Greek example):
Create Resources/el.lproj folder within Localizable.strings file in Finder
Open your project file in Xcode and right-click on Resource folder
Click on "Add File to..." context menu item
Select Localizable.strings file from Resources/el.lproj folder -> OK.
Greek Localizable.strings automatically will be added to Localizable.strings files.
You can use the same way to add localization for xib files.
The file structure on disk is mostly irrelevant in Xcode. Just move the directory in Finder, then in Xcode you can either: (a) remove the fr.lproj directory and re-add it, or (b) select the red entry, open the right-hand (properties) panel, and near the top you should see the path. Change the path to the new location and it'll go back to black.

move xcode project causes red text (missing files from project)

When I move iphone project directory to a new path.
There are some red texts indicate the missing files from the project source codes.
How to avoid these?
Here is how to locate the missing (red) files using the Xcode 4 interface:
Select the file or files in the left hand Project Navigator (the folder icon)
In the right sidebar click on "File Inspector" which is the leftmost icon resembling a page
In the "Identity and Type" section, there is a grey box labeled "Location".
Click on the small icon to the lower left that resembles a file browser - this will come up with a file browser to locate the file.
Voila, you are done.
Xcode 7
1.) Right click on the red (missing) file.
2.) Select "Show File Inspector"
3.) Look at the right hand side of the screen under "Identity and Type" between "Location" and "Full Path"
4.) Click on the folder icon to the right of the file name.
5.) Navigate to the file's new location in the pop-up window and select the file.
I encountered this issue when copying my project from one mac to another.
The solution for me:
assuming your files are grouped (in folder)
from xcode open the group in file inspector
The group will probably be missing the absolute path.
press the little icon nearby to pick the folder to associate the group with.
restart xcode to see the changes.
I had the same problem, when I changed the permission on the files/folders to everyone read/write they then appeared in Xcode.
This worked on a Pod project. Quit XCode.
rm -rf project.xcworkspace/xcuserdata/*
Restart XCode and reopen project.
In Finder, create a duplicate of the project directory just in case all goes squiffy.
In Finder, open the project directory that contains all the files with red references
For all the red files you see in XCode, except the info.plist file (see step 5 below), highlight them in Finder and drag them from Finder to XCode's project navigator. i.e. import them.
In XCode's "Choose options for adding these files" window: a) Select Copy items into Destination's group folder (if needed)
b) Select Create groups for any added folder
c) Select Add to Targets, and press Finish
Highlight and drag the info.plist file from Finder to Project Navigator and repeat step 4 WITHOUT selecting Add to Targets
If you had groups in Project Navigator (e.g. Supporting Files), reorder the files to be in the right places.
Delete the original bad red references in Project Navigator, and Cmd-Shift-K to clean for good measure.
Build and run on a device to remove the bad reference to the .app file
you just have to locate the missing file press in file icon in the identity and type you will find the full path just locate your file where do you move it click the file icon
When you create these files be sure to save in your app directory. Or if you import classes from other project be sure to check the copy option.
I dont know if this is the main reason but when you are importing files to the application, do you mary the "Copy items in to destination group's folder (if needed)" ?
this make sure the file is not only referenced but added to your project folder and ir will move any where you move your project.
Did you move files in to folders directly in your project folder and not in xcode?
This worked on a Pod project.
go into finder and project.
right click on your project .xcworkspace and click show package contents
right click on contents.xcworkspacedata and open with textEdit then make sure file path is correct. If project has been moved this can change
I also did this below but now sure if you need it
Quit XCode.
rm -rf project.xcworkspace/xcuserdata/*
Restart XCode and reopen project.
If you create an Xcode project, then move the .xcodeproj file or the newly created project folder to a different folder using Finder, subsequent builds may show many missing files which still reference the original folder locations (which no longer exist because you moved them). These missing files can appear as red text or as issues in the Issue Navigator.
This can happen when Xcode is configured to automatically add or remove files to/from source control (under Xcode > Preferences > Source Control). When configured this way, simply creating a project in Xcode causes new project folders and files to be marked for addition to source control. When you later move the project folder or .xcodeproj file these pending adds now point to missing files.
To resolve this issue when Subversion is the source control program, revert the pending adds for the phantom items from your local working copy folder. In my case this requires dropping into a Terminal window, navigating to the parent of the phantom project folder, then reverting the automatic add, e.g.
cd /my-working-copy-folder
svn status --depth infinity
svn status --depth infinity existing-parent-folder/phantom-project-folder/
svn revert --depth infinity existing-parent-folder/phantom-project-folder/
Note that the first svn status command will list both missing files as well as properly added, modified or deleted files which you must take care to avoid reverting. The second status command is "practice" for the final revert command, to ensure you've specified the proper path to revert.
I do not know git but I assume it offers corresponding commands.
It's too simple to do :
Close the project that includes the missed files and open the Xcode, go to "Organizer">"Projects" and remove the project from the list there. Open your project from Finder and that's it.
hope this help.

Resources