Skip to content

Commit

Permalink
Use SimDevice to set the location when possible
Browse files Browse the repository at this point in the history
Summary:
FBSimulatorBridge is gone in Xcode 12.5. The Simulator app now uses
[SimDevice setLocationWithLatitude:andLongitude:error:], and that's what the companion is using here too.

Reviewed By: lawrencelomax

Differential Revision: D29361280

fbshipit-source-id: b5cedbd7efacd25ff0c219fba388285ef2d18627
  • Loading branch information
fgasperij authored and facebook-github-bot committed Jun 28, 2021
1 parent f436b92 commit ac8ee79
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions FBSimulatorControl/Commands/FBSimulatorLocationCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import <CoreSimulator/SimDevice.h>
#import "FBSimulatorLocationCommands.h"

#import "FBSimulator.h"
Expand Down Expand Up @@ -41,6 +42,18 @@ - (instancetype)initWithSimulator:(FBSimulator *)simulator

- (FBFuture<NSNull *> *)overrideLocationWithLongitude:(double)longitude latitude:(double)latitude
{
if ([self.simulator.device respondsToSelector:(@selector(setLocationWithLatitude:andLongitude:error:))]) {
return [FBFuture onQueue:self.simulator.workQueue resolve:^ FBFuture<NSNull *> * () {
NSError *error = nil;
BOOL succeeded = [self.simulator.device setLocationWithLatitude:latitude andLongitude:longitude error:&error];
if (!succeeded) {
return [FBFuture futureWithError:error];
}

return FBFuture.empty;
}];
}

return [[self.simulator
connectToBridge]
onQueue:self.simulator.workQueue fmap:^ FBFuture<NSNull *> * (FBSimulatorBridge *bridge) {
Expand Down
1 change: 1 addition & 0 deletions PrivateHeaders/CoreSimulator/SimDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
- (BOOL)disconnectIDSRelayToDevice:(id)arg1 error:(id *)arg2;
- (BOOL)connectIDSRelayToDevice:(id)arg1 disconnectMonitorPort:(unsigned int *)arg2 error:(id *)arg3;
- (id)setHardwareKeyboardEnabled:(_Bool)arg2 keyboardType:(unsigned char)arg2 error:(NSError **)arg3;
- (BOOL)setLocationWithLatitude:(double)arg1 andLongitude:(double)arg2 error:(NSError **)arg3;

// In Xcode 12, this replaces SimulatorBridge related accessibility requests .

Expand Down

0 comments on commit ac8ee79

Please sign in to comment.