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

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...

Related

how to add subfolders inside in-app-purchase iOS package?

For some reason, any files I put inside my IAP package (hosted on Apple) under a subfolder, gets eventually downloaded directly under the iOS temporary Contents folder.
I've created a simple IAP package using xcode template which initially had the following directory structure:
projectname/projectname/ContentInfo.plist
I then placed some extra files in the package under a subdir like so:
projectname/projectname/dir1/file1.txt
Then I go to xcode->add files->select dir1 and check "create groups" for added folders. All is ok so far. When I look at xcode, I see a group called "dir1", its location relative to group is "dir1" and full path is correctly set to xxxx/dir1.
I also see "file1.txt" with its location relative to group is "file1.txt" and full path correctly set to xxxx/dir1/file1.txt.
I package everything and upload to Apple.
I run a test to download the package and set a breakpoint after the content has been downloaded. I run a file scan function to list all the files. This is what I see under the xxx.zip/Contents folder that iOS creates:
ContentInfo.plist
file1.txt
dir1 is missing and file1.txt is directly under Contents!
I decided then to reopen the package xcode created (xcarchive) using "Show Package Contents" and indeed I see file1 under Contents/ and not under Contents/dir1...
How do I get the package to retain the directory structure when it's built?
Thanks...
Ah, after several hours, found the answer:
I needed to remove the file and group references and re-create them by "adding files" to the project, selecting dir1 folder with "create folder references", not "create groups" option.
After re-packaging this way, the folders were retained inside the package!

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

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.

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.

Is my xcode project duplicating itself?

I have an Xcode project. I see that there is a folder within the project folder in my Finder with exactly the same name as the project folder and this folder contains a copy of the project and includes, you guessed it, a copy of the project within again and again. The project folder is now 5Gb while the app itself is no more than 25Mb. So I think that the project somehow is making copies of itself. I see that in my Project I have two targets, one of the project name and one with the project name + "- copy" at the end of the target name.
I wonder what I should do to stop my project increasing in size and how to safely remove the copied project folder within.
there was a copy of the project in the target, the solution is to remove the offending folder form within the project in finder and then to remove the copied project in the target.

Xamarin studio folder structure issue in iOS project

I am having trouble with xamarin folders. Currently I'm writing xamarin iOS project. In Xcode I used directories for grouping images, there could be several levels of nested folders, but when I was building project for device or iOS simulator, these resources where simply being copied to main bundle, without any folder structure. I can't reach the same behaviour in xamarin studio. Whenever I create folders in my project and put pictures or other resources in them, this folder structure is recreated on the actual device, and thus, I struggle against different paths, when loading images. How can I make xamarin studio simply copy the files in the folders to main bundle, instead of recreating folder structure?
Thanks for help.
My first suggestion is to change the BuildAction property of your images to BundleResource.
Once you do that, there are multiple ways of achieving your goal:
The first option is to specify a LogicalName to be whatever you want the name to be inside of the compiled app bundle. Currently there's no way to set the Resource ID (UI name for the LogicalName property) for anything other than EmbeddedResource files (I'll work on fixing that momentarily), but you can edit the *.csproj like so:
<BundleResource Include="Icons\icon.png">
<LogicalName>icon.png</LogicalName>
</BundleResource>
Normally, that Icons\icon.png file would be copied into the iOS app bundle as Icons/icon.png, however, the LogicalName property overrides the relative path name. In this case it would be copied over as simply icon.png.
As another example, you can also do this:
<BundleResource Include="Icons\iOS\icon.png">
<LogicalName>AppIcon.png</LogicalName>
</BundleResource>
This will copy the Icons\iOS\icon.png file into the root of the iOS app bundle and also rename it to AppIcon.png.
A second option is to simply move your image file(s) into the Resources folder. The Resources folder is special directory that get stripped out of the default path names when copied over to the iOS app bundle. In other words, Resources\icon.png would be copied over into the root of the iOS app bundle as icon.png rather than Resources\icon.png as is the case with normal project directories.
A third option is to simply register other "Resource" directories of your own (and they can exist within other directories, including the default Resources directory).
For example, you could have the structure in your project:
Resources/
Icons/
icon.png
icon#2x.png
And in your *.csproj file, edit the following tag:
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
and replace it with:
<IPhoneResourcePrefix>Resources;Resources\Icons</IPhoneResourcePrefix>
This will ensure that the icon.png and icon#2x.png files are installed in the root of the iOS app bundle.
Xamarin has two ways to setup files you want present in the iOS bundle:
Put them in any folder, and mark the "Build Action" as "Content". Whatever directory structure you have in your project will be present in the main bundle.
Put them in the "Resources" folder, with a "Build Action" as "BundleResource", this does the same as #1, but removes the "Resources" folder from the path present in the bundle. This is a nice place to put all images you want in the root of your bundle but would clutter up your project.

Resources