4

My question today is about how Xcode deals with resource files in the app bundle which it creates. I know that it may be trivial, but I can't find an easy way out. Basically my problem is that Xcode seems to keep on including a resource file (eg a text file) in the app bundle even if the file has been removed from the project. Here it is in detail what is happening here.

⁃   Added a file to the project (both by choosing file - new file or dragging a file to the Xcode groups and files left column checking add to project folder if needed checkbox)
⁃   Compiled and launched the project in simulator
⁃   Verified that the file is present in myApp.app bundle, located in User/Library/Application/Support/iPhone Simulator/3.2/Applications/<application system number>/myApp.app and even in <my Xcode projects folder>/myApp/build/debugiPhonesimulator/myApp.app
⁃   Deleted the file from groups and files column in Xcode
⁃   Deleted the actual file with Finder in <my Xcode projects folder>/myApp/myFile
⁃   Deleted User/Library/Application/Support/iPhone Simulator/3.2/Applications/<application system number>/myApp.app and even <my Xcode projects folder>/myApp/build/debugiPhonesimulator/myApp.app
⁃   Emptied the trash
⁃   Verified that there is no reference to the file with Finder spotlight
⁃   Verified that there is no reference to the file with Xcode search
⁃   Rebuilt and relaunched the app in simulator
⁃   Verified that a brand new /Library/Application/Support/iPhone Simulator/3.2/Applications/<application system number>/myApp.app has been just created
⁃   Verified the content of /Library/Application/Support/iPhone Simulator/3.2/Applications/<application system number>/myApp.app bundle: the file is still there. Where the h. did Xcode take it from?

I am surely missing something really obvious. Any help?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user236739
  • 1,323
  • 2
  • 15
  • 21
  • 1
    If you don't clean or delete the build directory, then the old files will not be removed. The build process does not remove files from the app bundle, it only adds them. – logancautrell May 10 '11 at 18:38
  • The top answer to http://stackoverflow.com/questions/5714372/how-to-empty-caches-and-clean-all-targets-xcode-4 has a much better solution for Xcode 4. – Victor Van Hee Dec 28 '11 at 23:40

7 Answers7

6

Have you checked the "Targets" node ? If not then;

  • Expand the "Targets" node and the application one.
  • There must be a build phase called "Copy Bundle Resources".
  • Check that the resource is not in the phase.

You can also try to perform a full clean of the project to ensure that no temporary files stay.

Laurent Etiemble
  • 27,111
  • 5
  • 56
  • 81
  • Hi Laurent, and thank you for your attention. You mean check the Target as an option while adding the file to the project? – user236739 Apr 13 '10 at 14:11
  • All right, solved. I performed a full clean (under Xcode build menu) and it solved the issue. Thanks a lot. – user236739 Apr 13 '10 at 15:53
  • That's the trick. Xcode soes not track deleted resources and delete them from a standing build product; it will incrementally add new ones, but to delete you have to remove the build product (or do a full clean.) – cdespinosa Apr 13 '10 at 16:36
2

Clean used to work in xcode 3 but it doesn't seem to do a thing in 4. I found that deleting the app from the test device seems to help make the resource disappear.

vdk
  • 21
  • 1
1

Ran into a similar problem a few days ago.

It turned out that under 3.2, the simulator creates several application folders, one for each SDK version installed. I have:

~/Library/Application Support/iPhone Simulator/3.0
~/Library/Application Support/iPhone Simulator/3.1.2
~/Library/Application Support/iPhone Simulator/3.1.3
~/Library/Application Support/iPhone Simulator/3.2
~/Library/Application Support/iPhone Simulator/User

If you compile under a different SDK it creates a new application directory for the app within the folder for the new SDK. I had an alias to the old folder and ended up looking in the wrong folder at a version of the app that Xcode was no longer targeting and therefore never changing. IIRC, I had to track down the new app in the matching SDK folder.

TechZen
  • 64,370
  • 15
  • 118
  • 145
  • Hello TechZen, and thank you for your answer. It's a good point but it doesn't seem solve my issue. In fact I performed such a search without finding a myApp bundle without the deleted file. More, the myApp bundle I found has a creation date which is posterior to the deletion of the file... – user236739 Apr 13 '10 at 14:10
1

I had the same problem. However the solution proposed in the answer, didn't solve my problem. In the Targets > Copy Bundle Resources, I don't see the "ghost" files. I tried doing a full clean up, delete the app and reinstall it, and I still have the files in my app. The solution I found was by manually deleting the contents of the folder: ~/Library/Application\ Support/iPhone\ Simulator/4.3/Applications/

ffleandro
  • 4,039
  • 4
  • 33
  • 48
1

Remove the app from the simulator and delete with finder the directory of your app in Library > Developer > Xcode > DerivedData.

1

I ran into a similar problem. Xcode 4 keeps complaining about missing resource file even though it has been removed from the project. It results in build error.

This is how it's resolved:

1) Open the .pbxproj file 2) Delete all the lines referencing the resource file that you want to get rid of 3) Build it

Chuankai
  • 151
  • 1
  • 8
0

I had a similar problem with a .scnassets file - XCode Copy Resources only lists the .scnassets file (a real folder, not a group) but also remembers and copies it's contents even if they've been deleted. An intentional clean fixes this. Moreover, files deleted from a ghost .scnassets files appear to be copied every time you run the app, instead of the first time they're needed. Cleaning speed my build time up by 300%!

mcornell
  • 768
  • 1
  • 6
  • 15