when i am adding folder from other app to my app am getting error like no such file or directory - iphone

i am adding folder from other app folder and then put that folder in my app and i import folder files to my app file but i am getting error like no such file or directory while running.

If you're attempting to move folders between running iPhone applications, you can't because of the application sandbox that isolates the applications from each other.
If you're attempting to add files and folders to an Xcode project, you need to make sure they are added to the appropriate target. If they are resources like images, sounds, plist etc you must have Xcode copy them to the project folder to ensure they are included in the final product.

Related

How do I save files downloaded in my app to Downloads folder in Files app in Swift 4.2?

Is it possible to save the files downloaded from my app to be stored in the Downloads folder in Files App?
I am successful in creating my app folder in "On My iPhone" in Files and saving the files there.
However, my requirement is to save it in the Downloads folder in Files.
Is this possible? If so, how do I achieve this?

Copying non-existent resources during iPhone build

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.

xcode: how to save files in "documents" folder in compile/build phase (not via "code on run")?

I have a lot of jpeg+png+html files to add to my app, and of course when i "build" it all my resources files are added/included in myApp mainBundle folder.
I'd like to be able to modify via code, in run time, some of my resources, but:
1) we cannot "write" files via code in run-time in mainBundle
2) we can do it just in "documents" folder (or temp, or...)
3) we can copy files in "Documents" folder just via code in run-time
4) we cannot delete the mainBundle files after coping them in "Documents"
but that means that we will have doubled-sized our app, and in big apps (it's my case) this should be a non-sense, we'll have a lot of big files never used again in the mainBundle...
so i wondered if there was a work-around for this problem (is it just me thinking it's a non-sense?) to add files directly in the "Documents" folder in the "build" phase via xCode, or other similar solutions...
ps
one could be to download all files the first time a user use my app via server/internet directly in "Documents" folder, so my app won't be heavy to download via iTunesStore, but of course this will get a lot of time the first time for end-users, and it could be not well accepted, of course...
Well you can't, since the document directory is created on installing the app. There is no way to do what you want on compile time. Neither you can do it at the install.
Since you needed the file you have to include them in your bundle, i've even included 10MB sqlite database that I copy to to the document direct on first launch. That is just the way it is.
Doesn't work for apps
Copying files to the documents directory during compile time requires you to know that directory in advance. You generally can't know this as the documents directory might not have been created before your app is installed.
Can work for unit tests on the simulator
However, the location of the documents directory depends on the target platform and the kind of bundle you are building. For unit tests based on SenTestingKit executed on the iOS simulator, you can determine the documents directory at compile time by just doing this inside a "Run Script" build phase:
~/Library/Application Support/iPhone\ Simulator/$IPHONEOS_DEPLOYMENT_TARGET/Documents
Note that this really only works for unit test bundles as those are not executed in a dedicated app directory and thus access a "shared" documents directory on the simulator platform.

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%!

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.