I have created a plist file for my App. 2 questions:
1) If I have added the plist file to the Xcode project, will the file get automatically bundled and distributed with the App?
2) The Simulator always seems to 'locate' the file upon startup. Even if I manually remove the file from the App's root folder. This is where the Simulator is looking for the file:
/Users/Joe/Library/Application Support/iPhone Simulator/5.0/Applications/28C13BB3-xxxx....
Where should my plist file be located?
1) Yes it will as long as it is in the Target/Build Phases/Copy bundle resources.
2) It will be located on your application documents directory, you don't really need to worry about it, except you have to add the file to your project and make sure number 1 of this list has been done.
The simulator finds it even after remove, because it keeps state, unless you manually reset the simulator. Therefore it already had a copy of the file in the folder you mention, even if you removed it.
1) Yes. If Xcode project lists the file, it will be automatically bundled and distributed.
2) You can place your plist file anywhere under the top level project folder. Everything under your top level folder is your project bundle.
What do you mean when you say you remove the file from app's root folder ?
Related
I am looking to .gitignore my plist file found within a subdirectory within my project. When I ignore individual files at the root level where .gitignore is located I have no problems with the exclusion, but when I try to exclude files within the a subdirectory I can't seem set up the proper way to exclude this and my file still appears. I think what is throwing me off the most is the way that my Xcode projects appear in my finder compared to my Xcode program. In Xcode, my .plist appears within a Supporting Files folder. Once would assume that this would mean my gitignore request would be /app-name/Supporting Files/Info.plist, but in the finder, there is no Supporting Files folder, just Info.plist.
Any advice as to what I should do?
Should my .gitignore look like:
facebook-login-template/Info.plist
or
/facebook-login-template/Supporting Files/Info.plist
or should it be something else?
I think you are looking for this:
*Info.plist
If you only want to avoid the one inside "facebook-login-template", it should work with
facebook-login-template/Info.plist
but remember you have to reset the file on git if you've already tracked it.
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.
I have a cross-platform codebase, structured a bit like this:
/Projects
/App1
/src
/iOS
/App2
/src
/iOS
/App3
/src
/iOS
Win32.sln
iOS.xcodeproj
XCode wants to put icons and launch images under /Projects, as siblings of the .xcodeproj file, but that's messy - these are project/target-specific files. I would rather have each app keep app-specific iOS files under e.g. App2/iOS.
I've seen some topics on this kind of issue, talking about how xcode wants to copy images to the root, but no definitive answer if you can or can't do it.
edit: the same goes for my app .plist file, can I relocate this?
Currently the project I'm working on has the load screen icon in root folder and the appIcons under Resources/Icons so there's definitely a way of copying them there.
Try copying the icons to the desired folder manually, then add them to your project and uncheck "Copy items into destination group folder".
Also, I would advise you to create folders using finder, then adding them into Xcode to use them as Groups instead of creating them in Xcode.
I have found these are all possible
The plist file is easiest, there is a build setting info.plist which must be updated accordingly.
For the icon and launch images, remove references from your project and then move the files on disc to some folder that makes sense for your codebase. Then add these items to the project (right-click, "add files to "). Finally, use a copy files build phase to copy them to the Resource folder, or possibly add them to a Copy Resource Bundle build phase.
When I did this, the files were copied into the App-Bundle itself, the iPad displayed them as expected, and XCode displayed the images in the Project Summary screen.
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.
I deleted it out of the folder view in the left sidebar. It's gone from inside the apps folder and it isn't in the trash. It isn't letting me undo inside xcode either. It's a phonegap project and I deleted the 'www' folder.
Normally, the folders in XCode do not represent real folders in your filesystem.
Did the folder contain certain files? Can you check if these files are still present in the root of your project folder (via finder)?
If yes, the simplest way would be to just create a new folder an drag the files into it again.
I hope you have a backup. Xcode 4 deletes the files directly, rather than moving them to the trash. Please, file a bug report about this at bugreport.apple.com!