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

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!

Related

File With Same Name From different folder in ios

I am using "xcode 6.1.1" and "cocos2dx-3.2".
I need to access same file name from different folder.
In Resource i have 3 folder "A,B and C" and all this folder contain image with same name "1.png".
If i need to access 1.png of folder "A" ,How i can do this in cocos2dx please help?
following code is working fine in Android but not working in iOS
helpImage->setTexture("A/1.png");
Thanks.
Didn't used cocos for some time now, but it is pretty easy to do.
Do this:
Prepare directory with your game data. Here lets call it "GameData". Pick name you like.
Drag and drop that directory to the xcode, probably best location is Supporting files. Dialog will show up. Select "Create folder references", deselect copy if needed.
And basically you are done. During build process all resources will be copied to bundle with paths as is in that directory "GameData". So you can have files with same name without problems.

Put files in bundle into specific folder locations on iOS app

The files inside of my app bundle are arranged into folders, but when I check the file layout of the bundle, it seems these files are all added to the same directory, and not sorted by folder as I have them in XCode. How can I make sure they're added to the device in the same folder structure?
The folders created in Xcode using "Group" or "Group from Selection" (yellow folders) are not true Folders, but Groups. They are only a visual way to organize your sources.
To make true folders (blue), create them on disk (using, say, the Finder).
You can then import them into Xcode using the option "Create folder references for any added folders".
In short:
Groups (yellow). Not related to the actual file/folder layout
Folders (blue). Direct representation of the OS hierarchy

Unable to see image files in xcode folder reference

I added a folder which contains some images in Xcode as "Create folder references for any added folders". It added the blue folder but it doesn't show the arrow to see its contents.
Is this an issue in Xcode or am I missing something ?
Screenshot :
Blue folder means you added folder reference ,not folder
Right click on the images folder you added and select show in finder...See if the images are there..if not.. you linked the wrong folder
Make sure the search bar at bottom of the file explorer is empty
You have added the folder in a wrong way. To create a reference folder select the checkbox
'Copy items into destination's group folder if needed'
and in folder options select the radio button
"Create folder references for any added folders".
This works.
If you use blue folder references for your resources these folders will also be created inside your application bundle, while resource files in groups will simply be copied to your mainBundle's root directory.
When folder structure is managed outside of XCode (for example, a cross-platform project which has project files for different versions of XCode, Visual Studio and other IDEs, all using mostly the same directory tree), you normally want folder references. Otherwise one would have to recreate every project file every time folder structure changes.
This is Your solution->
if you do want to auto-import newly added files from the file system's folder to this group in XCode, instead of using "Create groups for any added folders", change to "Create folder references to any added folders"

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.

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