英文:
Loading test resources without Bundle in XCTest
问题
I have translated the code part for you:
[[NSBundle bundleForClass:[self class]] URLForResource:@"TestResources/test" withExtension:@"json"];
If you need further assistance, please let me know.
英文:
I've a static library with a corresponding test target. The test target doesn't use a "Host Application". Within the test target, I've some test files in the folder TestResources
, which I'd like to load.
The resources are copied, I see them in ~/Library/Developer/Xcode/DerivedData/<workspace>/Build/Products/<schema>-iphonesimulator/myLibraryTests.xctest/TestResources/
.
But
[[NSBundle bundleForClass:[self class]] URLForResource:@"TestResources/test" withExtension:@"json"];
doesn't work. There are no bundles at all! [NSBundle allBundles]
returns nil
.
So what can I do to get the path to my resources?
答案1
得分: 0
The bundle is there and the resources can be loaded!
Xcode gave me a false lead. I don't know why, but in the debug area, all variables are nil
, despite "Debug executable" is enabled in the schema.
英文:
The bundle is there and the resources can be loaded!
Xcode gave me a false lead. I don't know why, but in the debug area, all variables are nil
, despite "Debug executable" is enabled in the schema.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论