I have the following directory structure:
- container
- app
- index.html
- ...
- ios
- mobile.xcodeproj
- Mobile
- www # imaginary folder (or could be a real, empty one)
- android
- ...
app contains files shared among an Android and iOS application. I'd like to add a imaginary folder to my xcodeproject so that files in app look like they really are in www inside the ios directory (../app should look like ./www).
I need to exclude certain files in the app directory, thus I can't simply use a symlink and add that folder, because then I can't selective exclude certain files.
The reason why I'm going through this trouble is that PhoneGap searches for the file index.html inside the www directory, which don't exist in my case so I need to somehow fake its existence.
Anyone know how to solve this? My guess is to setup folder groups and add file-references, but I can't get it to work properly. Also, let me know if I should elaborate on something.
Note that when you create a group, you can then specify where the root folder of that group is with Xcode. In Xcode 4.x, click on the group icon on the left pane. Open the rightmost pane and click on the top icon that looks like a document. You'll see "Identity" underneath is "Group Name", "Path", then another entry with no label that has a window-like icon to the right. Click on that icon to set which folder the group aligns with.
Related
Okay, I am a noob. It must be simple but I stuck here.
I do rigth-click and choose 'select file'.
After I choose the file the dialogue appears:
I want to keep my icons not in the root directory. But I can't figure out how to do this. I tried different ways, even create project from scratch...
Please help.
When you bring image assets into Xcode they will all be in your application bundle's root directory at run time.
It appears that you've added a file named "icon#2x.png" to your project at one time already. Go to the project's summary page in Xcode click Build Phases and then expand the section titled Copy Bundle Resources. There you'll find the reference to the resources that will be copied to your bundle at run time.
More on bundle structures here:
https://developer.apple.com/library/mac/#documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html
Anyway, the way I've done this in the past is to:
Remove the existing image duplicate from Xcode and from the folder structure in Finder.
Add a new folder in Finder call it "/AppIcons" (or whatever).
Copy all the app icons to that folder in Finder.
Drag the "/AppIcon" folder into your XCode project. I typically put images in an "/Images" subdirectory in the Xcode project. Again you can put it wherever you'd like.
In Xcode on the project summary panel, add your app icons from the folder "/AppIcons" by dragging / dropping or by right clicking and adding them as separate files.
Alternatively in the past when I've had problems with this sometimes Xcode will copy the app icons to the root project directory. If that happens, I make sure that I have the "/AppIcons" folder structure on disc (in Finder) and in my Xcode project. I add the app icons to the project, then move them to /AppIcons in Finder, and re-reference them all over again.
Your Copy Bundle Resources should then have the proper file reference. Note that my apps icons go in "/Images/AppIcons"
Good luck!
I would add the image files to your project with the name icon#2x.png. To do this right click where you want to add the files in xcode and click add file/s. Then search for your image and add them using the dialogue that pops up. - there is a check box so that you can either copy them to the projects destination folder which will copy them into you project folder or leave it unchecked (inadvisable) which would reference it's current location on your HDD. Make sure the file doesn't already exist in the project before doing this!
EDIT:
Sorry I forgot to mention then drag and drop the file from within xcode onto the image location box.
In XCode 4 (I'm using 4.6.2) you will get this confusing message if you've just moved the target's info.plist file, but not corrected the location at the top of the summary panel. Fix this and the icons will reappear, assuming they are added to the project, or if not you should now be able to drag them in without xcode insisting on making extra copies.
This tends to happen when you're starting a project and sorting out the mess of default file locations that xcode gives you. I like my project structure to be 99% the same as the file system structure.
This is an easy fix. If the image you want as your App Icon resides outside of the root of your project, when you get that dialog just click "Yes", and then click delete on the newly created file in the root, and "Move to Trash".
The reference is still there and works without a hitch, since the file will still be in the root at runtime
I had a Localizable.strings file in my project for which I wanted to add more localizations.
So I went to the Project Settings and clicked the "+" to add languages. Somehow I cannot do that anymore on the right panel as there is no "+" button.
Xcode creates the cn.lproj folder inside the en.lproj folder in the file system which is messy but some other lproj folders such as de.lproj do get created where they belong.
How can I move an xx.lproj folder to where it belongs without breaking everything in Xcode? I am afraid leaving them where xcode is putting them can cause errors at run time because cn.lproj should not be a sub-folder of en.lproj.
As it turns out it's an Xcode bug, but fortunately it can be resolved.
First step is to backup your project. Then move the wrongfully placed lproj folders out of en.lproj and if you want, put all of them in a localized subfolder.
Then delete all the link-broken files (red) from the Project Navigator. For the stacked files that have an arrow you will have to delete the root item. Do not choose "Move to Trash". Then make sure in the Project Settings you have all the localizations you want. Drag the "localized" sobfolder containing all the lproj folders into Xcode wherever you want it to be, and make sure it gets added to the current target (Add to target checkmark must be checked in the list). In my case everything was functional as expected after doing this. And as a nice side effect I got rid of these annoying stacked files with the arrow and instead have a very clear group structure consisting of a localized and several lproj folders which makes much more sense to me.
The correct way to add a localization would be through your Project Info pane in Xcode.
It looks like this:
I would think trying to do it any other way might be asking for trouble (or hassle).
I think, you should have a folder en.lpoj for English.
Now if you click "+" and choose xx as language you should get another one named "xx.lpoj" nearby of the old one (on the same level so to say) and NOT inside the en.lproj.
So delete this wrong sub-folder and do it again ...
I've migrated an Xcode project (iOS app) from one mac to another (same Dev Account and Code Signing preferences). Now the build fails and I get errors stating that certain files (MainWindow.xib, MyappViewController.xib and InfoPlist.string) don't exist. I've already read that several people have had this problem before and tried out the answers they got, but nothing seems to work.
As I understand, the problem lies within the path preferences for the NIB files. The error messages give the files' path as Users/Meonmyoldmac/etc - which I should change, because it's an absolute path and therefore doesn't make sense on another computer. But: when I try to open those files under Groups & Files their location is already set to 'Relative to group' and their path is given as Users/Meonmynewmac/etc. - which is exactly how I actually want it to be. (Oddly enough, the file type is listed as 'Default - Unknown' )
I've already tried…
- cleaning the project
- deleting those files from the project and putting them back in again
- restarting Xcode several times
that's possibly important:
- I'm talking about a Universal iOS App, yet only iPhone files are affected; their iPad equivalents work fine
- I changed the app localization to German, so the mentioned files are located in a folder called de.lproj
- I created the project with Xcode 4 on my older Snow Leopard Mac and use Lion/Xcode 4.2 on the new one - does that play any role here?
Thanks in advance, Fruity
If you have absolute paths to some of your files, you'll need to change them to relative paths:
In the Project Navigator, locate the missing files (colored red for not being found) and highlight one of them.
Show the File Inspector
Under Location change Absolute Path to Relative to group or Relative to project,
Then next to the path, there's a little white icon, click it and choose the file's location.
Right-click on the files in Finder, select Get Info. Check that you have permission to read the files.
Edit: Just noticed the error messages refer to the old path, so it can't be a permissions problem.
Groups can have paths set as well. Select the groups and verify that their paths are correct.
In XCode 4, when you have all three panes open, select the file in the left most pane. In the right most pane, select the white document icon at the top, looking for the header "Identity and Type." Under the popup for "location" is the name of the file. To the right of that name is a tiny icon like a window. Click on that, and you can set the location of the file.
I performed the terminal search suggested by Jim yesterday, found some 'source tree: absolute' entries in project.pbxproj and tried to manipulate them, which didn't work - couldn't even open the project in Xcode afterwards - so I called it a day.
Just now I did what I already tried yesterday before posting my question: I deleted the files from the project and copied them back in again. That miraculously eliminated all red warning signs from my project and just gave me a nice green SIGABRT when I tried to run it on the simulator. Cleaned project, restarted Xcode - perfect. Oh, and I checked the targeted device family setting, found that it was set to iPhone and switched it to iPhone/iPad - no idea if that was part of the issue.
I'm not sure if that's really an answer to the problem - but the problem has vanished...
Thanks for your help!
A less-actions solution. You can change manually in the project definition file.
Close xCode
Open .xcodeproj file in a text editor: in fact it's a folder, so edit in a text editor the inside file: project.pbxproj.
Search for the string: absolute (for sourceTree param)
For each entry (file with a absolute path set), change absolute to group.
And change the path parameter to a relative path. example:
path = en.lproj/PilotInfoViewController.xib;
- Save the file and reopen xCode.
PS: Make a backup copy of your project file before doing this manipulation.
iPhone resources by default show up in a "Resources" group that's visible in the main xcode project view. I want to be able to put them into an actual, physically separate directory at some arbitrary location on my machine decided by me. Interestingly enuf, the default "Classes" group is an actual, physical directory but the "Resources" group isn't.
How can someone tell me how to do that?
TIA,
Howard
Right click on Resources, add existing files, choose your directory
and select "Create Folder References for any added folders".
VoilĂ .
An alternate approach is to start with a directory in your project with some files, drag it into Xcode and have it create the folder references for you. Anything you add within that folder reference is automatically put in that subdirectory.
Both the abovementioned approaches are just how-tos. These operation will transform into build setting. Here is how you can change (or at least just view) the setting on XCode.
If you are using XCode 4+, check the project icon, then select your Target. In Build Phases tab, looking for "Copy Bundle Resources (x items)" category. In it, you should have your folder there. If no, click "+" button.
I had a bunch of images in my Xcode project. They were originally added without choosing "Create Folder References for any added folders". So I removed the references and re-added as per these instructions Include a resource directory hierarchy into app bundle
Unfortunately, Interface Builder will not display any of the images inside that directory. On the project tree the directory comes up with a blue icon and all the files are there!
The file names show in the IB Inspector (i.e. under the 'Image' property), but I get missing image icons for everything located in that directory.
Any ideas how to get the images showing again?
Problem solved! Turns out that blue folder references are fine, but IB will not read them!
For anyone else who cares to know, if you have the following:
/iphone-project-dir/images/pic.png
Once you've added them in a blue folder in Xcode (as detailed in link above), you can refer to them in IB as follows:
images/pic.png
In the XIB's XML it will look something like this
<string key="NSResourceName">images/pic.png</string>
Simple! The only drawback is Interface Builder's WYSIWYG preview does not process these paths!
I found the answer here http://www.iphonedevsdk.com/forum/iphone-sdk-development/6457-xcode-folder-directories.html
If you like to have your images structured in your SCM and under XCode but really doesn't mind that all images will be placed in one directory once building the final .ipa package, here is what you need to do:
Create a directory called e.g. "Images" in your root folder
Place all your images into this folder
Add a new group from within XCode and call this "Images" too
Right-click this group and choose "Add Files to ..."
Select all your files and uncheck "Copy items into destination group's folder" because they are already in there
Make sure to select your right targets
From Interface Builder you are now able to pick your images without prefixing it with the folder name and you will see a preview of your images within Interface Builder.
Gives me both my IB preview and a neat folder structure when designing my app.
Copy Images folder to your project folder.
Add this folder to project. In "Choose options for adding these files" dialog, you must check "Create groups".
"Copy items if needed" you can leave checked.
Make sure to select your right targets
Finish