Comments (13)
@Alexander-techIOS I believe this is a different issue, could you check if you linked the library with the test target only, and not with the main target?
from viewinspector.
This is a known issue with Xcode 12.2 beta.
from viewinspector.
Just checking in on this. Since Xcode 12.2 is now officially released. I have managed to install ViewInspector into the project. But when running new Unit Test build I get this error:
ld: warning: Could not find or use auto-linked library 'XCTestSwiftSupport'
ld: warning: Could not find or use auto-linked framework 'XCTest'
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_XCTestExpectation", referenced from:
objc-class-ref in ViewInspector.o
"__swift_FORCE_LOAD_$_XCTestSwiftSupport", referenced from:
__swift_FORCE_LOAD_$_XCTestSwiftSupport_$_ViewInspector in ViewInspector.o
"XCTest.XCTFail(_: Swift.String, file: Swift.StaticString, line: Swift.UInt) -> ()", referenced from:
(extension in ViewInspector):SwiftUI.View.inspect(file: Swift.StaticString, line: Swift.UInt, traverse: (ViewInspector.InspectableView<ViewInspector.ViewType.ClassifiedView>) throws -> ()) -> () in ViewInspector.o
(extension in ViewInspector):SwiftUI.View< where A: ViewInspector.Inspectable>.inspect(file: Swift.StaticString, line: Swift.UInt, traverse: (ViewInspector.InspectableView<ViewInspector.ViewType.View<A>>) throws -> ()) -> () in ViewInspector.o
closure #1 (A.V) -> () in (extension in ViewInspector):ViewInspector.InspectionEmissary.(setup in _7842524499E11E7966421A3557BF3F7D)(inspection: (ViewInspector.InspectableView<ViewInspector.ViewType.View<A.V>>) throws -> (), expectation: __C.XCTestExpectation, file: Swift.StaticString, line: Swift.UInt, function: Swift.String) -> () in ViewInspector.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Is this still applicable in this issue?
from viewinspector.
Thanks for the response. I installed it with spm and then added ViewInspector to each test target build (under Frameworks)
from viewinspector.
Nvm my comment, it's working. Didn't have to manually add ViewInspector to each build target. It's working now, I think.
It's building :D
from viewinspector.
Now many test targets do you have? I can think of multiple test targets if you have UITestCase target (which is useless for SwiftUI as of now), but usually, there are just two: the main build target and the test target. Could you re-assure you haven't checked in the main target.
=-=
Yep, let me know if it works eventually
from viewinspector.
Sure let me just clean it up a bit
from viewinspector.
Ok so I've cleaned it up a bit. I created a new Test target. Managed to import ViewInspector fine. Then I created a simple test to test that the Tests work.. lol
Then I copied a test from your README (testVStackOfTexts), if I run this test I have a compile error:
Undefined symbols for architecture arm64:
"nominal type descriptor for ViewInspector.ViewType.VStack", referenced from:
_symbolic _____y_____G 13ViewInspector011InspectableA0V AA0A4TypeV6VStackV in SPilotDeimosTests.o
"(extension in ViewInspector):SwiftUI.View.inspect() throws -> ViewInspector.InspectableView<ViewInspector.ViewType.ClassifiedView>", referenced from:
SPilotDeimosTests.SPilotDeimosTests.testExample() throws -> () in SPilotDeimosTests.o
"(extension in ViewInspector):ViewInspector.InspectableView< where A: ViewInspector.SingleViewContent>.vStack() throws -> ViewInspector.InspectableView<ViewInspector.ViewType.VStack>", referenced from:
SPilotDeimosTests.SPilotDeimosTests.testExample() throws -> () in SPilotDeimosTests.o
"nominal type descriptor for ViewInspector.InspectableView", referenced from:
_symbolic _____y_____G 13ViewInspector011InspectableA0V AA0A4TypeV010ClassifiedA0V in SPilotDeimosTests.o
_symbolic _____y_____G 13ViewInspector011InspectableA0V AA0A4TypeV6VStackV in SPilotDeimosTests.o
"(extension in ViewInspector):ViewInspector.InspectableView< where A == ViewInspector.ViewType.Text>.string(locale: Foundation.Locale) throws -> Swift.String", referenced from:
SPilotDeimosTests.SPilotDeimosTests.testExample() throws -> () in SPilotDeimosTests.o
(maybe you meant: default argument 0 of (extension in ViewInspector):ViewInspector.InspectableView< where A == ViewInspector.ViewType.Text>.string(locale: Foundation.Locale) throws -> Swift.String)
"protocol witness table for ViewInspector.ViewType.ClassifiedView : ViewInspector.SingleViewContent in ViewInspector", referenced from:
SPilotDeimosTests.SPilotDeimosTests.testExample() throws -> () in SPilotDeimosTests.o
"protocol witness table for ViewInspector.ViewType.VStack : ViewInspector.MultipleViewContent in ViewInspector", referenced from:
SPilotDeimosTests.SPilotDeimosTests.testExample() throws -> () in SPilotDeimosTests.o
"nominal type descriptor for ViewInspector.ViewType.ClassifiedView", referenced from:
_symbolic _____y_____G 13ViewInspector011InspectableA0V AA0A4TypeV010ClassifiedA0V in SPilotDeimosTests.o
"(extension in ViewInspector):ViewInspector.InspectableView< where A: ViewInspector.MultipleViewContent>.text(Swift.Int) throws -> ViewInspector.InspectableView<ViewInspector.ViewType.Text>", referenced from:
SPilotDeimosTests.SPilotDeimosTests.testExample() throws -> () in SPilotDeimosTests.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
So regarding your earlier question. I have multiple builds for the project one prod, 1 training and 2 development builds. The ViewInspector does seem to import properly, it's in scope.
If I include a test referencing ViewInspector, I get the above build error.
from viewinspector.
Again, some sort of linking issue. Try creating a new project and linking ViewInspector with its test target - make sure the simple test passes. Then get back to your setup and try integrating from scratch, making sure there are no signs of ViewInspector left for the build targets, and clear out DerivedData.
from viewinspector.
Yea I'll do that.. ViewInspector went out of scope now.. Xcode...
from viewinspector.
Just for some closure. All is working. Can also access StateObjects, but need to implement didAppear block in the target view, and only Assert in the didAppear block in test target.
Thanks for this framework! I only have just started digging into it will maybe reach out for more complex tests.
Is there way to take a snapshot of the sut?
from viewinspector.
By snapshot, do you mean rendering view onto an image? This is not supported directly, but I'd try wrapping sut in UIViewRepresentable
and calling drawViewHierarchyInRect(, afterScreenUpdates: true)
from viewinspector.
Awesome I will try it out
from viewinspector.
Related Issues (20)
- Inspecting custom modifier doesn't see removed views HOT 1
- Inspecting conditional toolbar content
- Inspect fails to find views due to `guardType(value:namespacedPrefixes:inspectionCall:)` incorrectly failing HOT 4
- Xcode 15.0 - Type mismatch: ButtonAction is not () -> () HOT 1
- Question: trying to use the (super) ViewInspector in non test code HOT 1
- Runtime warning when using . modelContainer modifier for SwiftData HOT 1
- View Hosting on watchOS in a Swift Package HOT 1
- iOS 17: Button style check HOT 1
- Views with .help become unfindable HOT 4
- Find fails when view has recursion inside of ForEach HOT 1
- Issue with .tint() modifier in Tests after updating Deployment Target to iOS 16
- Not found Shape in test layer HOT 2
- Accessing properties on a view that takes a generic HOT 2
- Does find(button: "xyz") find custom button `label:`s? HOT 4
- Interface buttons by ID HOT 1
- Is there a timeline on when we can expect 0.10.0 to be released? HOT 4
- View for `UIViewControllerRepresentable` is absent
- Only able to find the first AccessibilityIdentifier applied to a View, unless applied using a ViewModifier.
- Inspection of onTap gesture on custom Layout HOT 1
- Not able to test Charts framework elements/protocols
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from viewinspector.