Xcode puts old data file in bundle, not the new version of it

Xcode keeps resurrecting an old version of a bundled data file despite my best efforts to replace it with an updated version of the file.

I put a data file into my iOS document-based app project, did a build, and when run then app found the file in its main bundle as expected. Then I decided to change the data file by replacing it with a newer one. I deleted the old file from the project (reference removed and file deleted). I dragged the new file into Xcode project navigator just as before. I cleaned the build. When I rebuilt, the old file was still being put into the build output folder (the Build/Products/Debug-iphonesimulator/myproduct.app package). The original version of file does not exist anywhere on the system. I'd even emptied the Trash.

Anyone know what's going on? Is there some cache Xcode keeps that's outside the build folder structure and is not cleaned?

This isn't even anything to do with simulators or test devices. The build output is just plain wrong right on the Mac. (The app fails of course: it opens the data file but it's got the wrong, old data in it.) I've tried product cleaning, deleting the file from the project and on disk, putting the master file into Xcode under a new name, even deleting ~/Library/Developer/Xcode/DerivedData/(my project)-(alpha junk).

I'm using Xcode 10.3 on macOS Mojave 10.14.6.

1 answer

  • answered 2019-09-10 15:15 Bob Peterson

    The answer is to change the file type in the File Inspector of Xcode. It was "Default - Data" and should be "Data". My file is a byte stream from a NSKeyedArchiver. Apparently Xcode mangles this by trying to wrap the contents in XML.