I'm working on an MVC site with an image upload capability and I want to write a test that will upload an image.
I made an image called TestImage.jpg and set Copy to Output to be "Copy if Newer". In my test I try to load that with the following code:
System.Drawing.Image testImage = System.Drawing.Image.FromFile(#"TestImage.jpg");
Shouldn't the "Copy to Output" copy it to the same directory where the test is running? If not, how can I find out where it was copied to? Best would be some kind of project root relative path so I can feel free to move the solution around without this breaking.
In MSTest, the framework copies all .dlls to a folder called TestResults. Unfortunately, it only copies .dlls, .pdbs and .configs from the output folder to the TestResults folder, so your files are not being copied.
To copy those files, you will need to either
add the DeploymentItem attribute to the test(s) in question
edit your .testrunconfig file by adding the appropriate files in the Deployment tab
A better alternative is to embed the test-specific files in the test as an embedded resource and then read them directly from the resource stream.
in the solution explorer Under solution items double click LocalTestRun.testrunconfig go to deployment and add the image
http://img17.imageshack.us/img17/5219/sanstitrelca.jpg
Related
In my case I have 50 Folders where each of it has subfolders and images. I could drag them into the apps main bundle but there are many duplicate filenames and it would be more practical to access them in the structured way.
Your wording "it would be more practical to access them in the structured way" seems to suggest that you think the Resources folder cannot contain a folder tree of files, it can. However if you let Xcode itself copy your resource files into the bundle it will flatten the tree without any option to preserve it (for reasons unknown). To address this you can copy the files into the bundle using a build script.
In outline, you need to fill in the gaps with some reading:
First add your files and folders into your project. Use one group per folder, in Xcode 9 creating a group creates a corresponding folder in the project directory but in prior versions you must create the group and then associate it with a folder – check the documentation of whatever Xcode version you are using.
Mark all the folders and files added in this way as not part of your build target. This prevents Xcode copying the files automatically into the bundle, and flattening your folder tree in the process.
Now in the target settings go to the "Build Phases" tab and add a new build script phase. Add a shell script which uses something like ditto to copy the folder tree into the bundle. Various environment variables are set which reference the project and the bundle, check your Xcode documentation or just run a dummy script and dump them out (it is an option, or use printenv). You can use these environment variables to determine the source and destination for your copy.
In your app itself you can locate the root folder of your tree using standard bundle methods. From there you can use whatever method you choose to traverse it/reference items with in it, in exactly the same way you would if the folder tree was not inside the bundle.
HTH
I have made an empty single-view application in Xcode 6 (FWTest) and added a Cocoa Touch Framework (FWTestKit) as a target and asked it to embed in FWTest. Then I add an image (photo.png) to the framework, that I expect to be in Frameworks/FWTestKit.framework/Versions/A/Resources/photo.png when I build & archive my app. However, I find it in Frameworks/FWTestKit.framework/photo.png
How can I make it at least be in a Resources folder? Preferably a versioned folder so I can ship different versions of my framework?
When I add this framework to another app, do I need to do anything special to make sure the resources are bundled along with it, so that when I reference a resource from within my framework I can be sure it'll be available also when used in another app?
Cheers
Nik
You should add your photo.png into separate folder (let's call it "gica" ). Then drag folder into project, check Copy items if needed and create folder reference. Then (important) in build phases, drag photo.png again in Copy Bundle Resources, keeping Copy items if needed and create folder references. After you compile you should have now desired folder structure [It is keeping gica/photo.png].
I think you need to revise the architecture about versioning. Anyway if you still need to place the image inside the folder. Try creating a run script.
In your build phases instead of adding your images to copy bundle resource phase. You can create a shell script to copy your images to desired folder. Please note build phases are run in the order they placed. My point is you can customise xCode Build process through your own shell scripts.
I am using "xcode 6.1.1" and "cocos2dx-3.2".
I need to access same file name from different folder.
In Resource i have 3 folder "A,B and C" and all this folder contain image with same name "1.png".
If i need to access 1.png of folder "A" ,How i can do this in cocos2dx please help?
following code is working fine in Android but not working in iOS
helpImage->setTexture("A/1.png");
Thanks.
Didn't used cocos for some time now, but it is pretty easy to do.
Do this:
Prepare directory with your game data. Here lets call it "GameData". Pick name you like.
Drag and drop that directory to the xcode, probably best location is Supporting files. Dialog will show up. Select "Create folder references", deselect copy if needed.
And basically you are done. During build process all resources will be copied to bundle with paths as is in that directory "GameData". So you can have files with same name without problems.
I have a large project tree and I decided to set up my tests in a different way. Setting up a new test project is easy but to copy hundreds of files from tens of directories is quite a problem. Is there an easy way to copy all these files from another project tree?
I would not duplicate the files that should be used without change in both test projects, but use separate (sub)folders for the test projects specific files and refer to the common units with a relative path.
Something like:
...\MyProject\Test1 and using '..\MyCommonUnit.pas'
...\MyProject\Test2 and using '..\MyCommonUnit.pas'
You do that for the first Test1 project, then merely saving it in another folder with the 'Save Project As' will duplicate the test only files and you can start directly modifying code in the new Test project...
What's the best way to backup a project?
To be more specific: I have a DropBox account and I prefer to have a copy of the project over there.
I assume I should copy all the h+m files.
Can I copy all the xib files? does it make any sense?
Can/Should I copy all the jpg/png/mp3 files that I use for resources?
Is there a proper way to do that, like a "backup project" button where I can select the target and it compresses the project in some smart way?
You need all of those and the project files, etc. Look in the project file to see all files referenced. Check to see if you have everything by making a copy and trying to build from the copy. You'll get complaints if you missed any thing.
The best way to backup a project is source control. There are many options available to get free or very cheap remote source control repositories where you can store a copy (and history) of your source. Checkout http://www.beanstalkapp.com or http://www.github.com for a start.
Best thing is to copy the entire directory where all your project exists. Copy this directory to your dropbox folder. To open the project open yourproject.xcodeproj with xcode.
Although this method is okay for one time thing or when you are the only one working on your project but in the long run you should look at trying to adopt a source control versioning system like GIT. Xcode has wonderful integration with GIT.
Hope this helps...