Copying non-existent resources during iPhone build - iphone

At one point in my iPhone app development, I had 2 rather large video files as resources for use in the app. After some tests, I decided I didn't want them anymore. So I deleted both from the resources folder in xcode - and I selected 'remove and delete selected references.' When I try to build on my iPhone or iPad, it still says "copying file opening.mov to iPhone." And it takes up space in the build.
What is happening? I deleted all references to the file everywhere on my computer, but it still copies the file on my iDevices.
I checked the xcode project folder in finder and it's not there!

You can go to Project->Build Phases->Copy Bundle Resources, chances are those files are still there somehow, delete them if they are.
Additionally as suggested do a product clean.

Go to /Users/your user/Library/Application Support/iPhone Simulator/your version/Applications and delete the folder for your app.
Hint: Library could be a hidden folder. If you not see it use tinker tools to make the folder visible.
Delete the app on your test device.
In xcode go to Build Phases and check if your file is copied to bundle resources. If yes - delete it from there.
Clean your build an run.

Related

Iphone app archive - No such file or directory

I am almost ready to release my iphone app. I use restkit for consuming my webservice. When I archive, it fails with this error:
cp: /Users/myusername/Library/Developer/Xcode/DerivedData/project-name-/ArchiveIntermediates/project-name/IntermediateBuildFilesPath/UninstalledProducts/include/RestKit: No such file or directory
I dragged & dropped restkit into the project. It builds and works fine in debug mode. I am guessing it is unable to locate restkit dir while archiving. But I am not sure why. Any thoughts?
I've had trouble linking with my own framework in the past, but I have a procedure that works. Even though I don't understand it, it works so I follow it like voodoo, and I don't risk angering the gods by asking too many questions.
Here's what I'd try on your project (again, partly voodoo here):
Navigate to the Frameworks folder in the project nav, select the RestKit and delete it with the delete key. Just delete references.
Using Finder, option-drag (copy) the framework from wherever you first got it
(~/Downloads, or another project or wherever) into your project directory, replacing files if prompted.
Back in your project, select the project, then the target, then build phases.
Open the link binary section, hit "+", then the "Add Other.." button on the bottom of the dialog
Browse to the framework you copied in in step 2.
See if you can clean, build, archive. Easy enough to try, and no livestock are harmed. Hope it works for you.

Xcode won't let go a resource file

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?
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.
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.
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.
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/
Remove the app from the simulator and delete with finder the directory of your app in Library > Developer > Xcode > DerivedData.
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
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%!

iphone simulator picks up deleted resources from xcode

I'm getting confused. I add resources (mp4 videos) to the resources folder in xcode and run the simulator and it picks them up, great!
I delete the file and simulator still picks it up from the resources directory. I delete the file in the app bundle that xcode is using and it still detects this file. I'm at a loss as to where/how I should delete items from xcode for it to actually remove them.
There's no 'remove from project' option, what am I missing here?
Regards,
Sapatos
You need to 'clean' the build to move these artefacts. Go to 'Build' and 'Clean' to remove them.
Alternatively you can blat projects from ~/Library/Application Support/iPhone Simulator/sdk_version/Applications
Have you also deleted the app from the simulator?
Product>Clean didn't do it for me. I needed to do "Reset Content and Settings..." from inside the Simulator's menu -- a much safer way than messing around inside ~/Library/Application Support/iPhone Simulator/*sdk_version*/Applications

Why can't I just send my zipped Xcode project folder to a friend, and it works?

I always use one folder on my filesystem for an Xcode project. It contains all project files. When I zip it and send it to a friend, she can't just ipen the xcodeproj file. It opens, but all paths are broken and build fails because all the classes don't find the #include'd files. But when I download i.e. some example projects from apple, these work perfectly. What am I doing wrong?
UPDATE:
I'm doing it like this:
1) I create a project and specify an directory on my desktop
2) In that directory I create an "images" directory and add images to it
3) I pull this images directory out and drag it into the Resources Groups&Files. Xcode asks if I want to copy it to destination folder, I click no. Because it's already there. All other things are set to default.
4) all other things are just created within xcode, and xcode just puts all classes in the Classes directory of my project.
5) when I want to add images, I first put them in the directory of the project, and from there drag them into the Images group in xcode. That's to make sure xcode doesn't mess them up with everything else. Otherwise it would just copy them to the root of my project directory rather than inside the Images directory, which doesn't make sense. In fact, the whole Groups&Files filesystem doesn't make sense at all, it's one big mess. Apple's biggest mistake in Xcode so far. That's why I have to do such stupid things.
We don't really know exactly what you're doing so it's hard to see what you're doing wrong.
Perhaps inspect the xcode project files directly, see if you have hardcoded paths. That's a sure fire problem. Make sure you copy resources into the project instead of referencing them externally, etc.
I expect that you have "search path" build setting set to an absolute path on your machine, rather than a path relative to the project. Best way to tell is to post a portion of the build transcript from the failed build and look at the -I directives. If those paths don't exist on your friend's machine, then they should be changed from absolute paths to paths that start with ${SRCROOT}.
Are you just trying to build on the second machine or are you trying to deploy to a device on the second machine? If you are trying to deploy to a device (iPhone or iPod Touch) then it probably has something to do with Code Signing and Certificates.

Can Xcode include application resource files that are generated during the build process?

I have a bunch of content files for my iPhone app that I generate via shell script. It takes way too long to be a part of the Xcode build process, so I run it periodically.
I don't want to have to continually add these files to my Xcode project in order to get them included my app resources folder. Is there a way to get Xcode to copy the contents of a folder into the app resources at build time? (It'd be a bonus if I could specify other locations, such as the approot documents folder.)
I tried adding a new 'Copy Files Build Phase' to my target, but that didn't seem to work. This seems like a common problem, but I couldn't find anything about it here.
-- Edit (What I did)
Per Jasarien and cdespinosa's suggestions, I did the following in a build script. I decided not to copy to the destination, because that would only work when using the simulator, I don't think that'll work when deploying to a device.
cp -rf "$PROJECT_DIR/mystuff" "$CONFIGURATION_BUILD_DIR/$CONTENTS_FOLDER_PATH/"
-- Edit 2
This doesn't appear to get files onto my iPhone. Any ideas?
You can setup a Run Script build phase in your app's target. Write the script so that it copies the resources into the app bundle.
This is the path i use for output:
${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}
Just copy your files in that directory, it's the bundle (simulator or device).
You can also take a look at my answer here : how to set up a Xcode build rule with a variable output file list?