Reputation: 3045
I'm having trouble saving to disk when using unit tests for a framework.
I've read up on other threads and there seems to be a special case for fixing up the unit tests to enable writing to the disk. Typically for a normal application, defining a path for the Bundle Loader and the Test Host, like in the referenced link would enable disk writing. I receive the following error instead,
ld: file not found: /Users/myName/Library/Developer/Xcode/DerivedData/TestFramework-hbmitredrfzizgeypdtunedsiqqt/Build/Products/Debug-iphonesimulator/TestFrameworkTests.xctest/TestFrameworkTests clang: error: linker command failed with exit code 1 (use -v to see invocation)
I used the following for the bundle loader $(BUILT_PRODUCTS_DIR)/TestFrameworkTests.xctest/TestFrameworkTests
the following for the Test Host
$(BUNDLE_LOADER)
For an app, these variables are already filled out for you. For some reason, probably a good reason, these variables were blank for frameworks.
I followed the path in the error and there's no executable, if a normal project is made, the path would lead to an executable and behave as it should. I'm at a loss.
Please help. Thank you.
=================
Here's the project I used, it is totally fresh, just dummy code that logs to console.
http://speedy.sh/3MuGu/TestFramework.zip
Reference stack overflow thread
NSHomeDirectory in iPhone unit test
Upvotes: 3
Views: 1085
Reputation: 28756
There's generally no issues with saving to the disk for iOS unit tests.
One catch, though, is if you're writing to the standard document directories for Simulator hosted application tests, or logic tests, then you may need to create that directory first.
Just do the following in your test's setup or somewhere else that will happen before tests run:
This is just a stab-in-the-dark, based on my own experience. So let me know if this helps you or not.
Upvotes: 2