Close Simulator from Xcode: Running AppleScript on iOS - ios

I have an AppleScript that I setup to close the iOS simulator after X amount of time. I know that in objective-c using the Cocoa framework for a Mac app, I would just easily do:
NSString *scriptSource = #"tell application \"iOS Simulator\" to quit";
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:scriptSource];
NSError *error = nil;
[script executeAndReturnError:&error];
Obviously I can't do this in iOS. Is there anything that will run my AppleScript in iOS? Or does anyone know of any workarounds or ways to do this?
Or, is there a way to close the iOS Simulator from within the app using natively Objective-C, another scripting language, or add it to the build phase?

No.
You can't run AppleScript on an iOS device.
And there is no way to quit the iOS simulator from an iOS app.
Sorry.

Related

Black screen when using ARGeoTrackingConfiguration on iOS 15.4?

I am trying to run this sample project from Apple that uses ARGeoTrackingConfiguration: https://developer.apple.com/documentation/arkit/content_anchors/tracking_geographic_locations_in_ar
This sample app is supposed to show an AR camera feed in the top part of the screen, and a map view in the lower part. However, I am not seeing the camera feed, it's just black.
I suspect this is something that changed in iOS 15.4, since my colleague was able to run the app successfully on a phone with iOS 15.3.1.
Some other details:
I am seeing this issue on an iPhone 12 Pro Max and an iPhone 13 mini.
Both these devices can support geotracking and are connected to the internet.
I am in a location that has geotracking support, according to these docs: https://developer.apple.com/documentation/arkit/argeotrackingconfiguration
I updated to iOS 15.4.1 but the issue is still occurring.
I tried updating to the iOS 15.5 beta 1 and the issue is still occurring.
Has anyone else noticed this issue? Am I doing something wrong? Is there a workaround?
I filed a radar ticket as well, just in case.
EDIT: I filed a TSI request for this issue, and I got back a response saying that there is no workaround for the issue. However, it looks like the bug has been fixed in iOS 15.5 beta 2.
// Class originalClass = NSClassFromString(#"NSXPCDecoder");
// Class swizzledClass = NSClassFromString(#"SwizzledDecoder");
// SEL originalSelector = #selector(_validateAllowedClass:forKey:allowingInvocations:);
// SEL swizzledSelector = #selector(__validateAllowedClass:forKey:allowingInvocations:);
#interface SwizzledDecoder : NSObject
- (void)__validateAllowedClass:(Class)arg1 forKey:(id)arg2 allowingInvocations:(bool)arg3;
#end
#implementation SwizzledDecoder
- (void)__validateAllowedClass:(Class)arg1 forKey:(id)arg2 allowingInvocations:(bool)arg3 {
if ([arg2 isEqualToString: #"collaborationData"]) {
return;
}
return [self __validateAllowedClass: arg1 forKey: arg2 allowingInvocations: arg3];
}
#end
https://developer.apple.com/forums/thread/703735?answerId=711909022#711909022
I could think of a few options to "fix" this using Private (Apple) APIs. This approach is not super terrible and at least would unblock you from testing on a 15.4.x device (I confirmed this works on Xcode 13.3.1 and iOS 15.4.1).
As far as whether or not Apple would approve #YOLO #FIDLAR code like this in an App Store review? I can't help you there.
The real fix (we can hope for) is the next version of Xcode ships with an SDK that builds and compiles with a retroactive fix for 15.4.x.
This issue has been fixed in iOS 15.5

Showing wifi network doesn't work depending on building env

This question is a bit generic about building app with xcode for IOS phone
I'm a Go backend engineer but recently my company had its mobile app developed by an agency (with React-Native) and we received the source code.
Until now, the builds they made had everything working.
On my side, my company asked me to change some icons and redo a build for the app store.
In the app, we have a screen that allow you to connect to a wifi you're already connected to or list available networks:
#implementation WifiManager
//export the name of the native module as 'Wifi' since no explicit name is mentioned
RCT_EXPORT_MODULE();
//exports a method getCurrentWifiName to javascript
RCT_EXPORT_METHOD(getCurrentWifiName:(RCTResponseSenderBlock)callback){
#try{
NSString *wifiName = nil;
NSArray *interFaceNames = (__bridge_transfer id)CNCopySupportedInterfaces();
for (NSString *name in interFaceNames) {
NSDictionary *info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)name);
if (info[#"SSID"]) {
wifiName = info[#"SSID"];
}
}
callback(#[[NSNull null], wifiName]);
}
#catch(NSException *exception){
callback(#[exception.reason, [NSNull null]]);
}
}
#end
But those interface (wifiname, interfacenames) are always nil when I compile for release with my xcode (Version 10.1 (10B61))
So my question is, as a non-ios developper, what are the things I should look for here when building with xcode?
Is there a parameter to check / uncheck? Also, I've found on a website that CNCopySupportedInterfaces isn't supposed to work on IOS12, but depending on the build (the agency / mine) it works or not.
Anyone could explain a bit what's happening?
Many thanks!
You need to enable the Access WiFi Information capability in your project.
Navigate to the project settings, choose the "Capabilities" tab and enable the option:
I don't know React so I can't comment on the implementation but as a general rule, the simulator is not going to give you accurate feedback on anything network-related. There are ways to simulate certain network conditions to allow for rough testing of network-heavy operations but the simulator is nothing but a macOS app so it's still limited to the underlying architecture and its sandbox.
This is a long way of saying, you should be testing this on a real device.

iPhone Jailbroken Issue with Xcode 9

Need to check whether device is jailbroken using cordova. I tried the cordova-plugin-jailbreak-detection plugin, but still can open the same in JAILBROKEN Device. then i got .m files from https://github.com/Shmoopi/AntiPiracy. it was working fine till XCode 8. In XCode 9, getting "System keyword is unavailable" error
Any latest plugin/class files to check Jailbroken compatible for latest XCode ?
system call is not available for ios, remove + (int)systemCheck and it should work for you. Also in + (void)killApplication method comment system call
The isJailbroken method performs various check and if the score is >= 3 then it marks it as Jail broken. Now as the system call is not available then we can live without the score of + (int)systemCheck and proceed without it.

Hand Off between iOS and Mac device is not working

I am implementing both iOS and Mac applications. I implemented Hand Off feature in both applications. When I test implementation it works well when:
start on iOS app and continue on iOS app
start on iOS app and continue on Mac app
But it doesn't work when I start on Mac app and want to continue on iOS app. Logically, the problem is when I create userActivity and becomeCurrent on Mac app. But the code for iOS and Mac is the same, so I don't know where the problem is.
// Create userActivity
_userActivity = [[NSUserActivity alloc] initWithActivityType:#"com.myapp.image"];
_userActivity.title = #"Image";
_userActivity.supportsContinuationStreams = YES;
_userActivity.delegate = self;
_userActivity.userInfo = #{
#"Key" : #"information from the other device",
#"URL" : #"http://www.apple.com"
};
[_userActivity becomeCurrent];
Thanks!
I submitted a bug report with ID: 41374510 with title: Handoff doesn't work from MacOS to iOS.
I tested it with the same code in reverse from iOS to MacOS and that worked great so I am assuming that it is a Apple's bug.

Cycript script to run app in background

I have a cycript backboardd script that works great on iOS 7 for modifying an app to continue running in the background.
app = [BKProcess processForPid:$PID];
alive = [[BKProcessAssertion alloc] initWithReason:7 identifier:"AppKeepAlive"];
[alive setFlags:0xF];
[sc addAssertion:alive];
This is all that's needed. However on iOS 8 this does't work as BKProcess is now BKSProcess and BKProcessAssertion is now BKSProcessAssertion and they have different methods.
There doesn't seem to be a way to attach the assertion to the app like on iOS 7.
Can some please help me get this working under iOS 8.
There is, however when I used this I simply used the initializer with the required PID.
- (id)initWithPID:flags:reason:name:withHandler:
Check out the BKSProcessAssertion header for reference.
If you want to see an implementation for reference, check out MessageBox (now deprecated, but for reference):

Resources