Giter VIP home page Giter VIP logo

Comments (13)

nalexn avatar nalexn commented on May 30, 2024 2

@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.

nalexn avatar nalexn commented on May 30, 2024

This is a known issue with Xcode 12.2 beta.

from viewinspector.

AXR-Tech avatar AXR-Tech commented on May 30, 2024

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.

AXR-Tech avatar AXR-Tech commented on May 30, 2024

Thanks for the response. I installed it with spm and then added ViewInspector to each test target build (under Frameworks)

from viewinspector.

AXR-Tech avatar AXR-Tech commented on May 30, 2024

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.

nalexn avatar nalexn commented on May 30, 2024

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.

AXR-Tech avatar AXR-Tech commented on May 30, 2024

Sure let me just clean it up a bit

from viewinspector.

AXR-Tech avatar AXR-Tech commented on May 30, 2024

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.

nalexn avatar nalexn commented on May 30, 2024

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.

AXR-Tech avatar AXR-Tech commented on May 30, 2024

Yea I'll do that.. ViewInspector went out of scope now.. Xcode...

from viewinspector.

AXR-Tech avatar AXR-Tech commented on May 30, 2024

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.

nalexn avatar nalexn commented on May 30, 2024

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.

AXR-Tech avatar AXR-Tech commented on May 30, 2024

Awesome I will try it out

from viewinspector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.