During my build my files arent always copied. Even when i modify them.
Its a web app im building and the folder that isnt copying is:
HTML (blue folder icon) it references a HTML folder on disk.
It doesnt seem to copy.
I've tryed doing a run script saying
Shell: /bin/sh
Script:
touch -cm ${SRCROOT}
And it makes no differnece.
How can i FORCE xcode to always copy every file?
E.g a script to touch every file and folder to make sure it copies?
Im a a dead end here!
A blue folder represents a folder reference, which is a kind of file reference, just like all the references to .h and .m files in your project.
The only modification time Xcode cares about is that of the referenced item—in this case, the folder. Not that of any item in the folder, nor of any descendant item, nor of any ancestor folder (such as your project directory, which is what $SRCROOT refers to).
So, you need to touch the folder specifically. Any time you modify anything in the folder, you need to touch that folder.
This doesn't apply if you add or delete files in the folder, since that counts as modifying the folder itself.
If you really want to unconditionally copy the folder every time, you can create a shell script phase before the Copy Files phase that takes the folder as an input and produces it as an output, and touches that folder specifically. Then the Copy Files phase after it will see that the folder has been “modified” and will re-copy it.
Expect long build times if you do that.
Related
We are using Delphi 6. Currently, we have kept all the different application folders under one main folder.
We have below folder path for one of the applications:
C:\dev_GIT\MyApplications\Delphi\Sales_Applications\Member_Joining
For some reason, we would like to move this folder to below folder path:
C:\dev_GIT\Member_Joining
Issue we are getting is that we have some common files which are kept in separate folders and which are used in so many other applications as well.
Since we are moving this folder outside of the current folder path, we are getting compile error, which is expected.
The real issue is, as there are so many files which are in common folder path, we need to change their path in .DPR file one by one. Is there any better way by which we need not to change path for all the files in the .DPR file?
In my case I have 50 Folders where each of it has subfolders and images. I could drag them into the apps main bundle but there are many duplicate filenames and it would be more practical to access them in the structured way.
Your wording "it would be more practical to access them in the structured way" seems to suggest that you think the Resources folder cannot contain a folder tree of files, it can. However if you let Xcode itself copy your resource files into the bundle it will flatten the tree without any option to preserve it (for reasons unknown). To address this you can copy the files into the bundle using a build script.
In outline, you need to fill in the gaps with some reading:
First add your files and folders into your project. Use one group per folder, in Xcode 9 creating a group creates a corresponding folder in the project directory but in prior versions you must create the group and then associate it with a folder – check the documentation of whatever Xcode version you are using.
Mark all the folders and files added in this way as not part of your build target. This prevents Xcode copying the files automatically into the bundle, and flattening your folder tree in the process.
Now in the target settings go to the "Build Phases" tab and add a new build script phase. Add a shell script which uses something like ditto to copy the folder tree into the bundle. Various environment variables are set which reference the project and the bundle, check your Xcode documentation or just run a dummy script and dump them out (it is an option, or use printenv). You can use these environment variables to determine the source and destination for your copy.
In your app itself you can locate the root folder of your tree using standard bundle methods. From there you can use whatever method you choose to traverse it/reference items with in it, in exactly the same way you would if the folder tree was not inside the bundle.
HTH
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!
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 have created a rather large application in xcode and wish to move the files somewhere else on my computer.
Could this process be as simple as dragging the project folder to a different place in finder or will something mess up?
Moving the .xcodeproj files will not cause any issues as long as xcode is closed when you migrate the files and you delete the old files.
When xcode is next launched, if you browse and open the proj file from the new directory, all the references will be set to the correct destinations
on a side note it always pays to keep the old files in a .old folder when migrating projects to avoid issues.
As long as the files are kept in their respective folders, next time you run a build in xcode, the references to the new directory the proj file is in will be updated.
As another side note, i just tried to do this and it messed up for me. Typically, any references will switch over, but i had a linker error: ld. it was trying to link to an external library that was contained within the old folder. i had to go to build settings->search paths->library search paths and change that to the new folder location. that worked for me.