Xcode compiler doesn't see files after update to v6.3? - ios

After update i have errors with folders in my project.
file not found
and if i comment this import, i get this
Unknown class FLLoginVC in Interface Builder!
But they are in project and in copy bundle file.
If i add my FLLoginVC.h and FLLoginVC.m to 'Copy Bundle Resources', it works, but if i add full folder hierarchy, it doesn't.

You don't add the whole folder to copy bundle resources. You select the .m and go into sidebar, first tab, and check your current target (so that the code compiles for that target). You only copy images and data files to bundle.

Related

Resources not copied to bundle

I have an XCode project for an iOS application, and added to it 3 small mp3's in the structure that are copied to the destination bundle upon compilation.
I have then added a bigger mp3's (4MB) to the structure (same folder than the previous ones) and into the Build Phases:
However upon compilation, this file is not present in the bundle. I tried to clean and recompile, change destination, but the file is still absent:
Anything I could have forgotten to check ?Thanks.
Go to your build phase->resources and check these files are showing there or not and check when you add them did you allow them to copy when required checkbox was selected or not.
When you add resources, make sure not only the copy items into destination group's folder (if needed) is ticked, but also tick the corresponding target in the Add to targets list.

Xcode can't find my .h file that was made in the project

Disregard the typo in the body of the #implementation where the view controller being called is different than the one being imported. I've fixed that and the error still occurs..
I can't figure out why it doesn't find the file when the file is clearly within the project..
And it does this for every file that is in the Models, Views and Controller files..
The problem is that the "Controllers" folder is a folder reference and not a group. That is why it is blue and not yellow like the other groups in your project. Remove the folder reference and add the "Controllers" folder as a group to your project. To do this, when you drag the folder into your project, in the dialog that appears make sure to choose "Create groups for any added folders" and not "Create folder references for any added folders". The "Models" and "Views" folders will also need to be fixed.
When you have a folder reference the files will be added to the product of the target, but not compiled.
Don't attached imgur pictures... You can attach them inline with your post.
Ensure that your header is included with the linked headers under the build information.
Run a clean build and ensure you're running the regular target and not the test target.
If your file is included during compilation (aka your build settings include it) then restart Xcode.
I press OptCmd+a to add the folder and got this issue.
A simple image to solve the issue:
Make sure you selected the "Create groups", I must clicked the "Create folder references" by mistake sometime before

texture atlas file not found in main bundle in resources folder

I'm having a problem where a file in my Resource directory is not being recognized as being in the Main Bundle.
I am creating a texture atlas using a pvr file format using texturePacker. The output of texturePacker produces two files xxx_iPhone-hd.pvr.ccz and xxx_iPhone-hd.plist. These two files are being stored in my Resource directory of my cocos2d project. Once the files are stored in the Resource folder, I go to the Resource folder and right click to 'Add Files to "myProject"' (with the copy items into destination box unchecked).
When my cocos2d project runs and tries to load this file, the absolute path is unknown to the Main Bundle. Specifically, my code executes the following line of code:
backgroundBgNode = [CCSpriteBatchNode batchNodeWithFile:#"StoreMenuBackground_iPhone.pvr.ccz"];
The cocos2d code knows that the device has a retina display and modifies the filename to create a relPath of "StoreMenuBackground_iPhone-hd.pvr.ccz". It then tries to execute the following:
NSString *imageDirectory = [relPath stringByDeletingLastPathComponent];
fullpath = [[NSBundle mainBundle] pathForResource:file
ofType:nil
inDirectory:imageDirectory];
This results in full path being nil. I previously created a different xxx_iPhone5-hd.pvr.ccz file with the above procedure, and the above code successfully returns the fullpath. I have very carefully checked and rechecked the spelling and don't see any problems. I have also tried removing and re-adding the files under "Copy Bundle Resources" of the "Build Phases" for the project. Is there something I can do to force the mainBundle to find this file?
You should verify that the file actually is in the bundle.
You can do that by right-clicking the built bundle (in your project's DerivedData folder) and select "Show Package Contents". If you don't know how to locate the built product, do an Archive Build targeting a device (archive builds are unavailable for simulators). In the Organizer window that opens right-click the app and select "Show in Finder", that brings you to the xcarchive. Run "show package contents" on the xcarchive and navigate to /Products/Applications and perform another "show package contents" on the bundle.
If the file is there but in a subfolder (not in the root of the bundle) then you have created a folder reference inside Xcode, denoted by the blue folder icon. Remove that and re-add, this time uncheck the checkbox "create folder references for..." in the Add File dialog.
If the file IS there, copy its filename and paste it back into code. Case differences can sometimes be elusive and hard to notice, even if you double-check.
desperate measures then. Copy in finder the files on the side ... ie not in the project directory structure. Rename the newly copied files to something dead simple , like a-hd.pvr.ccz and a.plist (hoping you dont already have an a-hd.pvr.ccz in your project ;) ).
Edit a-hd.plist to make certain that the last section points to the right file name. Drag them from Finder onto the xCode resources folder, selecting to copy the files. Make certain to change the name in your code. Delete the previous files from the project. Deep clean the project. Delete the app from the device. Run. If that worked, redo the same steps, reverting the name to your favourite name.

How to add existing .momd to a project in Xcode 4?

I have a project that includes a subproject. The subproject has a Core Data model and generates a .momd "bundle." I need that .momd bundle to be included in the main projects app bundle that is generated when the project is built. The .momd file is generated, and is in the build directory, but I cannot see how to get it included in the final app bundle.
I can add the .momd as a file in the "Copy Bundle Resources" (by adding a reference to it to the main project in my Supporting Files group) but since the .momd is not a Finder level bundle, it adds it in as a directory and the .momd contents get copied into the app bundle, but not the .momd folder itself, so the system cannot find it when the app runs.
Of course, after trying all sorts of things all afternoon, and searching with Google and Bing and inside SO, and not coming up with anything, soon after I post the question, I figure it out.
When adding the .momd file to the main app project (I added it to "Supporting Files" group), check "Create folder references for any added folders" and NOT "create groups for any added folders" (And also do not check "Copy items into destination group's folder" if the .momd is being generated in a sub-project)
Doing it that way makes the .momd gets copied into the app bundle...

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