Xcode copies package resources multiple times

I have a question regarding copying Xcode and bundle assets.

I am currently working on a project with a large asset library. Thus, a clean install or change of a package resource will ensure a copy of the "new" package resource (s).

However, the problem I'm currently running into is that Xcode copies a portion of my entire resource library every time the app is built. This behavior is super weird, as in all projects I worked, Xcode only copied resources if they were changed, or if it was a clean install, or if there was something new that hadn't been copied yet.

In this case, however, it copied all resources on a clean install (expected). However, on every sequential build, it still copies some of the files. Now this is super weird as none of the files have changed and it doesn't copy all files, just a small portion of them. One more thing - if I run the same application, with the same configuration on the simulator, the copy won't happen (weird weirdness).

Is there some setting that I can change, or maybe a flag that I can turn on that might prevent this?

Thanks in advance for your help!

Hooray!

+3


source to share


2 answers


It's been a month since this question was asked and I was able to find a "sort of workaround" solution.

Now, the reason I accept this as the accepted answer is primarily because no other answers / solutions have been posted since this was written. If anything is better posted (or if I have an update) I will definitely mark the best answer as accepted.

In any case, this "workaround" will work if you have a super large set of assets that don't change in successive builds.

The project I am working on has a lot of audio and video files that have already been prepared and will not change (other than accidentally overwriting or something like that).

So, as per my question, Xcode was copying a subset of the resources. Ideally, once the resource has been copied (and there are no changes), it will not be re-copied (at least should not be re-copied) across sequential builds. In my case, it was copied during each sequential run, resulting in my general build starting at around 15-20 minutes. I would also like to point out that regardless of whether we used a "run script" during the build steps or if we had media in our Xcode project, we ran into the same problem.



Solution: What I did was that I cleaned up the project, uninstalled the app, and did a fresh install. So, for the first time, it copies ALL files using the app. Also, the resource directory is NOT in my Xcode project. We've added a "run-script" phase in which we run rsync to copy the media from the media folder to the application during each build.

Now when the application finishes executing a new build; it would copy all necessary media files.

Then, DELETE / DISABLE the script, do a Clean in Xcode (command + shift + K) and run the project again. This time, since no script is being executed, and since Xcode has done a cleanup where it now thinks that all it has to do is recompile the binaries, it builds super fast. Since I have NOT uninstalled the application, the media folder is still in my application and my build for start time is about 30 seconds ~ 1 minute (this includes sandboxing and code signing). Code-sign and sandboxing for the app still take a while, but it's waaaay better than waiting 15-20 minutes every time I hit run. :)

Hope this helps!

+3


source


I have a very similar situation. Also, I have 6,000 resources in my application and even listing some of them (not copying) was a little slow. I found another workaround (very similar to yours, but a little simpler implementation). This was inspired by yours, so thank you so much!

I copied the project target, set its bundle ID as original (it was automatically set with the $ {PRODUCT_NAME} option from the build settings) and removed all assets from the Bundle's Copy Resources section. The first time (after removing from the device app) I need to run the original target with its resources, but then I can create the copied target while the resources are still on the device.

Some benefits:

  • It is very easy to switch between both goals.
  • no need to write two scripts (that was the goal, I didn't use your solution)


Entertainment with numbers:

  • 58 seconds from "Cmd + R" to the loading screen displayed with the package resource.
  • 20 seconds for the same interval with a blank Copy Resources section. Not as good as your cultivation, but it still matters.

Hope this helps too :)

+2


source







All Articles