Comments (27)
- Are you certain that the arch of the binary matches the Simulator? The
FBSimulatorApplication
instance you create will have an arch property. This should bei386
orx86_64
(or both) depending on the target simulator.FBSimulatorControl
does not currently check archs when launching. - 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 onFBSimulator
. - 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.
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.
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.
- Yes you need to install an Application before launching it. I'll update the documentation to clarify this.
- "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. - 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.
- 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.
Check out MacErrors.h for descriptions of the error numbers.
from idb.
also happens for me, output is the same as @jaredly 's
from idb.
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.
I'm now using xcrun simctl
for installing + running the app, and it works fine. no arch issues
from idb.
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.
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.
another question is how to run xctest with this tool? Any sample code for that?
from idb.
@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.
@oliverhu you should also hopefully see that cryptic message go away after #48 is landed.
from idb.
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.
@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.
@foulkesjohn no ..
from idb.
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.
Any update on this? I'd be interested to know how to run tests from the FBApplicationLaunchConfiguration...
from idb.
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.
@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.
@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.
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.
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.
shim should be only a hack to reformat xcode's output to a xctool json format?
from idb.
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.
@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.
Closing due to inactivity. If there are remaining issues that need discussion, please open a new task.
from idb.
Related Issues (20)
- idb interact Commands are not working in real devices HOT 2
- Noobie instalation question.
- Is it necessary to additionally define BASE_IDB_FILE_PATH under Windows?
- IDB Launch command not working HOT 1
- Stream not working
- Your CLT does not support macOS 13.4
- [Question] It is possible to control the device from the browser HOT 1
- video-stream :- help required to dynamically compress or scale down minicap framess
- The --fps option for video-stream doesn't work.
- when use idb and ffmepg to record video, Appium Session lose HOT 1
- Cannot build idb_companion in Xcode 15.0 on the current master (2022-09-19) HOT 4
- [Request] Support app icon PNG data command HOT 4
- [iOS 17] idb screenshot not working HOT 4
- Maps permission pop-up not shown
- iOS 17 support HOT 16
- idb list-targets return "No targets available" HOT 2
- Are there any plans to release a new version?
- Build companion via github actions workflow HOT 6
- Does idb automate the real devices ?
- Does idb's screen recording command support record sound?
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 idb.