Git Product home page Git Product logo

Comments (27)

lawrencelomax avatar lawrencelomax commented on August 15, 2024
  1. Are you certain that the arch of the binary matches the Simulator? The FBSimulatorApplication instance you create will have an arch property. This should be i386 or x86_64 (or both) depending on the target simulator. FBSimulatorControl does not currently check archs when launching.
  2. Check the Log for the Simulator, there might be something of interest there. Currently this will be stored at ~/Library/Logs/CoreSimulator/Devices/<DEVICE-UDID./system.log. FBSimulatorControl should probably expose this on FBSimulator.
  3. Inspect the Underlying Error. This is the actual error that we get back from CoreSimulator and there may be some extra userInfo there.

from idb.

jaredly avatar jaredly commented on August 15, 2024

Bingo! The simulator arch is x86_64, and my binary is i386. Is there a way to get the simulator to start up as i386? (testing iPad 2, ios 9.0) I didn't find an option for that. I also haven't been able to get xcode to create an x86_64 binary (pretty new to these things, sorry for the noob questions)

Edit: Actually, I'm less convinced now that it's an architecture problem; The binary I'm using is created by Xcode and run (by xcode) on the simulator just fine. It's just when I try to run that same binary on the same simulator w/ FBSimulatorControl that it fails.

from idb.

jaredly avatar jaredly commented on August 15, 2024

Digging more through the code, it looks like there's a separate step for installing the app, which must be done before launching it. Is that the case?

Anyway, I tried

      BOOL success = [[[session.interact
                        bootSimulator]
                       installApplication:myApp]
                      performInteractionWithError:&error];

And this also fails. The simulator boots up fine, but then the "installApplication" step fails, with the error: "Failed to install Application". Digging in, there's an undescriptive error that doesn't end up getting surface that just says "POSIXErrorDomain" with some large integer values.

The system.log shows no log messages when I run my thing. It does show log messages when running via xcode.

Incidentally, if I switch the cli xcode version to 6.4, then I get a different error: "Timeout waiting for device to boot", even though the "iOS Simulator" app opens and boots quickly, long before the timeout error is thrown.

from idb.

lawrencelomax avatar lawrencelomax commented on August 15, 2024
  1. Yes you need to install an Application before launching it. I'll update the documentation to clarify this.
  2. "Booting" is based on the information that CoreSimulator provides to us, not the launch of the Simulator process itself. I don't have 6.4 to hand, but this is the version that I think Travis-CI is currently using.
  3. Have you tried on different Simulators? IIRC iPhone 5 may not run with 64 binaries and the 5S was the first iPhone to introduce this. Try running against a later device to confirm that it's definately not an architecture thing.
  4. Errors are returned with high-level explainations and the error that is actually manifest from Core Simulator will provide whatever information is available in NSUnderlyingErrorKey. The Error Code may provide some value, but it's worth exhausting the possibility that this is an architecture issue first.

from idb.

lawrencelomax avatar lawrencelomax commented on August 15, 2024

Check out MacErrors.h for descriptions of the error numbers.

from idb.

oliverhu avatar oliverhu commented on August 15, 2024

also happens for me, output is the same as @jaredly 's

from idb.

oliverhu avatar oliverhu commented on August 15, 2024

I am able to install the App, but failed to launch it:

  2015-10-06 11:49:16.055 xctest[20772:290316] *** Assertion failure in -[FBSimulatorSessionLifecycle simulator:didStartWithProcessIdentifier:terminationHandle:], /Users/khu/ios/FBSimulatorControl/FBSimulatorControl/Session/FBSimulatorSessionLifecycle.m:84
    /Users/khu/ios/FBSimulatorControl/FBSimulatorControlTests/Tests/FBSimulatorControlApplicationLaunchTests.m:56: error: -[FBSimulatorControlApplicationLaunchTests testLaunchesSafariApplication] : failed: caught "NSInternalInconsistencyException", "Invalid parameter not satisfying: self.simulatorTerminationHandle == nil"
    (
      0   CoreFoundation                      0x00007fff9427b03c __exceptionPreprocess + 172
      1   libobjc.A.dylib                     0x00007fff9015a76e objc_exception_throw + 43
      2   CoreFoundation                      0x00007fff9427ae1a +[NSException raise:format:arguments:] + 106
      3   Foundation                          0x00007fff886d799b -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
      4   FBSimulatorControl                  0x000000010526ebd7 -[FBSimulatorSessionLifecycle simulator:didStartWithProcessIdentifier:terminationHandle:] + 743
      5   FBSimulatorControl                  0x00000001052780a6 __46-[FBSimulatorSessionInteraction bootSimulator]_block_invoke + 1462
      6   FBSimulatorControl                  0x0000000105275170 -[FBInteraction_Block performInteractionWithError:] + 80
      7   FBSimulatorControl                  0x00000001052743c1 __35+[FBInteraction chainInteractions:]_block_invoke + 369
      8   FBSimulatorControl                  0x0000000105275170 -[FBInteraction_Block performInteractionWithError:] + 80
      9   FBSimulatorControl                  0x0000000105274fb6 -[FBInteraction performInteractionWithError:] + 70
      10  FBSimulatorControlTests             0x0000000103908294 -[FBSimulatorControlApplicationLaunchTests testLaunchesSafariApplication] + 1236
      11  CoreFoundation                      0x00007fff941527bc __invoking___ + 140
      12  CoreFoundation                      0x00007fff94152612 -[NSInvocation invoke] + 290
      13  XCTest                              0x000000010002134f __24-[XCTestCase invokeTest]_block_invoke_2 + 159
      14  XCTest                              0x0000000100053822 -[XCTestContext performInScope:] + 184
      15  XCTest                              0x000000010002129f -[XCTestCase invokeTest] + 169
      16  XCTest                              0x000000010002173a -[XCTestCase performTest:] + 443
      17  XCTest                              0x000000010001f40b -[XCTestSuite performTest:] + 377
      18  XCTest                              0x000000010001f40b -[XCTestSuite performTest:] + 377
      19  XCTest                              0x000000010000ddbf __25-[XCTestDriver _runSuite]_block_invoke + 51
      20  XCTest                              0x0000000100031f32 -[XCTestObservationCenter _observeTestExecutionForBlock:] + 611
      21  XCTest                              0x000000010000dd08 -[XCTestDriver _runSuite] + 408
      22  XCTest                              0x000000010000e8b7 -[XCTestDriver _checkForTestManager] + 696
      23  XCTest                              0x0000000100054a6f _XCTestMain + 628
      24  xctest                              0x0000000100001dc9 xctest + 7625
      25  libdyld.dylib                       0x00007fff897d05c9 start + 1
      26  ???                                 0x0000000000000005 0x0 + 5
    )

from idb.

jaredly avatar jaredly commented on August 15, 2024

I'm now using xcrun simctl for installing + running the app, and it works fine. no arch issues

from idb.

lawrencelomax avatar lawrencelomax commented on August 15, 2024

There's probably more that can be done in terms of looking at preconditions before calling certain CoreSimulator methods. I'll look at installed apps shortly.

@jaredly did you find out what the Error Code corresponded to?

from idb.

oliverhu avatar oliverhu commented on August 15, 2024

I manually opened the app and it functions properly, here is the command:

    FBSimulatorSession *session = [self.control createSessionForSimulatorConfiguration:[FBSimulatorConfiguration.iPhone6 iOS_8_4] error:&error];
    FBSimulatorApplication *application = [FBSimulatorApplication applicationWithPath:@"/Users/ohu/Library/Developer/Xcode/DerivedData/foo-frhgmrtfxqiflycndwcgfpqkbhdy/Build/Products/Debug-iphonesimulator/Foo.app" error:&error];
    FBApplicationLaunchConfiguration *appLaunch3 = [FBApplicationLaunchConfiguration
                                                   configurationWithApplication:application
                                                   arguments:@[]
                                                   environment:@{}];
    BOOL install = [[[session.interact bootSimulator] installApplication:application] performInteractionWithError:&error];

    BOOL success = [[[session.interact
                      bootSimulator]
                     launchApplication:appLaunch3]
                    performInteractionWithError:&error];

from idb.

oliverhu avatar oliverhu commented on August 15, 2024

another question is how to run xctest with this tool? Any sample code for that?

from idb.

lawrencelomax avatar lawrencelomax commented on August 15, 2024

@oliverhu Are you talking about using FBSimulatorControl to launch Application Tests on a Simulator? It should be possible to do this for application tests with an Application launch with the -XCTest argument.

from idb.

lawrencelomax avatar lawrencelomax commented on August 15, 2024

@oliverhu you should also hopefully see that cryptic message go away after #48 is landed.

from idb.

oliverhu avatar oliverhu commented on August 15, 2024

Finally be able to run the application - the issue is I cannot boot simulator again when trying to launch the app.

@lawrencelomax Still not able to run xctest (with host app)

    FBSimulatorApplication *application = [FBSimulatorApplication applicationWithPath:@"/Users/ohu/Library/Developer/Xcode/DerivedData/foo-aodwsnztqjhrikgifstschfgfhzf/Build/Products/Debug-iphonesimulator/Foo.app" error:&error];
    FBApplicationLaunchConfiguration *appLaunch3 = [FBApplicationLaunchConfiguration
                                                   configurationWithApplication:application
// also tried @[@"-XCTest"] and @[@"-XCTest", @"All"]
                                                   arguments:@[@"-XCTest", @"All", @"/Users/ohu/Library/Developer/Xcode/DerivedData/foo-aodwsnztqjhrikgifstschfgfhzf/Build/Products/Debug-iphonesimulator/FooTests.xctest"]
                                                   environment:@{}];
    [[[session.interact bootSimulator] installApplication:application] performInteractionWithError:&error];
    [[session.interact launchApplication:appLaunch3] performInteractionWithError:&error];

from idb.

foulkesjohn avatar foulkesjohn commented on August 15, 2024

@oliverhu did you manage to get the tests to run? I have managed to get the bundle to load but the tests aren't running...

from idb.

oliverhu avatar oliverhu commented on August 15, 2024

@foulkesjohn no ..

from idb.

foulkesjohn avatar foulkesjohn commented on August 15, 2024

I tried moving away from FBSimulatorControl to see if I can get my XCTest bundle to run just using a single simulator. I am getting the same issue, I've put more detail in this SO post: http://stackoverflow.com/questions/33633882/run-xctest-bundle-with-simctl. This probably isn't the place to have this conversation but thought it could help.

from idb.

gblotter avatar gblotter commented on August 15, 2024

Any update on this? I'd be interested to know how to run tests from the FBApplicationLaunchConfiguration...

from idb.

lawrencelomax avatar lawrencelomax commented on August 15, 2024

I have a branch that aims to do this but haven't had the chance to finish it.

Running xctest bundles doesn't require the xctest commandline. xctest works by injecting a dylib into the App-Under-Test that will load the xctest bundle at runtime. If you inspect the system log you can see the environment variables that are passed to the App-Under-Test on launch. In fact this is the way that xctool launches tests

cc @ExtremeMan

from idb.

gblotter avatar gblotter commented on August 15, 2024

@lawrencelomax Thanks for the response.

I've been looking at this thread and #10 's thread. I checked out the demo project linked in that thread, re-wrote it in Swift and adapted it a bit for my needs, but as I've looked at the system log, I haven't found the right combination of environment variables to use/customize for it to launch an archived xctest bundle. I'll go check out your branch and see what you're doing. Thanks for all or your work on this, it's really great stuff.

from idb.

gblotter avatar gblotter commented on August 15, 2024

@lawrencelomax After much digging and inspecting of the system.log, I've not been able to find a way to get it to successfully inject the dylib into the App-under-test to have it load the xctest bundle at runtime. I created a demo project doing what I think you're talking about here. You can see that I set the arguments and environment params when creating the FBApplicationLaunchConfiguration object.

I'd appreciate it if you could look at it and tell me what I'm doing wrong. It sounds like this may have stopped working sometime after the Xcode 7.1 release?

from idb.

foulkesjohn avatar foulkesjohn commented on August 15, 2024

I've looked at xctool and what parameters its passing and brought over the XCTestConfiguration stuff. Its hardcoded right now for the bundle but I didn't really have any joy getting tests to run with my test app. Still looks like something is missing but I can't see what: https://github.com/foulkesjohn/FBSimulatorControl/tree/xctest-xctestconfig

from idb.

lawrencelomax avatar lawrencelomax commented on August 15, 2024

It's possible that we could find what is missing in terms of the bootstrapping of the application process by comparing the environment & arguments of an xctest-launched process in #72

I believe that xctool also uses a shim, but I'd need to look to confirm what reason it has this shim for.

from idb.

oliverhu avatar oliverhu commented on August 15, 2024

shim should be only a hack to reformat xcode's output to a xctool json format?

from idb.

oliverhu avatar oliverhu commented on August 15, 2024

I was able to make xctest (application test) work with FBSimulatorControl. It is a combination of bundle injection settings plus XCTestConfiguration setup. I copied some code from XCTool to make it work, here is the draft commit.
https://github.com/oliverhu/FBSimulatorControl/commit/929813a10519ceaa6aba8f7e9f85f59e42bdaf72
A demo .. https://youtu.be/uUDDSrC89gM
Also, you would have to wait for the simulator to boot before run the tests.

from idb.

lawrencelomax avatar lawrencelomax commented on August 15, 2024

@oliverhu Looks great :) would certainly like to see this in FBSimulatorControl. We can work on the details and how to make this as flexible as possible for users of the Framework in a PR. Also cc @ExtremeMan

from idb.

lawrencelomax avatar lawrencelomax commented on August 15, 2024

Closing due to inactivity. If there are remaining issues that need discussion, please open a new task.

from idb.

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.