Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allocate simulator by UUID #275

Closed
sapieneptus opened this issue Jun 29, 2016 · 6 comments
Closed

Allocate simulator by UUID #275

sapieneptus opened this issue Jun 29, 2016 · 6 comments

Comments

@sapieneptus
Copy link

Suppose we would like a reference to a simulator with a specific UUID (e.g., because we know we have put that exact instance in a particular state we want).

I can do this by creating a very generic FBSimulatorSet

FBSimulatorControlConfiguration *controlConfig = [FBSimulatorControlConfiguration configurationWithDeviceSetPath:nil
                                                                                                             options:0];
FBSimulatorSet *sims = [FBSimulatorSet setWithConfiguration:controlConfig
                                                    control:self.control
                                                     logger:nil
                                                      error:&e];

And then running a query on the result:

FBiOSTargetQuery *query = [FBiOSTargetQuery udids:@[deviceID]];
NSArray <FBSimulator *> *results = [sims query:query];

However, when I try to use one of the resulting simulators I get odd memory behavior, such as the simulator's set being nil or the processFetcher being nil. When I use lldb, sometimes these values are present.

The behavior is consistent when I obtain a simulator using the recommended approach (allocating a particular FBSimulatorConfiguration), but the configurations don't seem to allow for specifying a particular UUID.

@lawrencelomax
Copy link
Contributor

I should probably make the FBSimulatorSet constructor 'private' as you should not be using it directly. You should obtain the FBSimulatorSet from the FBSimulatorControl principal class.

Call the FBSimulatorControl class constructor then get the FBSimulatorSet from the set property.

@sapieneptus
Copy link
Author

Well, that was the magic bullet :)

@sapieneptus
Copy link
Author

So this no longer works for iPadPro after pulling the latest master:

+ (FBSimulator *)simulatorWithDeviceID:(NSString *)deviceID {
    FBSimulatorSet *sims = [self control].set;
    if (!sims) { return nil; }

    FBiOSTargetQuery *query = [FBiOSTargetQuery udids:@[deviceID]];
    NSArray <FBSimulator *> *results = [sims query:query];
    if (results.count == 0) {
        NSLog(@"No simulators found for ID %@", deviceID);
        return nil;
    }
    FBSimulator *sim = results[0];
    return sim;
}

The simulator reports having no deviceConfiguration and therefore no simulatorArchitecture and so is unable to do anything. Worked on at least one iPhone 5 sim, still testing others.

@sapieneptus sapieneptus reopened this Jul 8, 2016
@lawrencelomax
Copy link
Contributor

We need to create a configuration for each kind of device, the reason that we do this is to decouple the available runtimes that are loaded from CoreSimulator from the API that allows you to specify a query for each of them. Sounds like we have to add a configuration for the iPad Pro in order to get this working.

@lawrencelomax
Copy link
Contributor

8191e91 should fix the iPad Pro on Xcode 8 issues.

@lawrencelomax
Copy link
Contributor

Closing as it appears the iPad Pro issue was resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants