Lock screen on device programmatically - ios

I have read the other questions regarding the same, but everyone is just saying 'Jailbreak', 'that'll never be approved by Apple', 'It's not possible' and 'private API, GraphicsServices.framework'.
Let me just clear something up, I am not doing this for a jailbroken phone, I am doing this because the lock-button on my phone is broken, and I simply want to not have to wait 1 minute for the screen to lock. So I figured I could have an app which called lockScreen in the beginning of AppDelegate.h. This is not going on AppStore, it's just for me.
I've seen people saying they can use GSEventLockDevice(); when importing GSEvent.h from GraphicsServices.framework, but when I try running it (both on device and simulator) I get this, and it won't build:
Undefined symbols for architecture armv7s:
"_GSEventLockDevice", referenced from:
-[AppDelegate application:didFinishLaunchingWithOptions:] in AppDelegate.o
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm not completely sure what this means. If I remove the line GSEventLockDevice(); but still import GSEvent.h, everything is running fine.
Does my device need to be jailbroken for this to work or something?

This has already been resolved by somebody else. You can find it on Github: https://github.com/neuroo/LockMeNow
char *gsDylib = "/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices";
void *handle = dlopen(gsDylib, RTLD_NOW);
if (handle) {
BOOL locked = FALSE;
void (*_GSEventLockDevice)() = dlsym(handle, "GSEventLockDevice");
if (_GSEventLockDevice) {
_GSEventLockDevice();
//...
}
dlclose(handle);
//...
}

There is no reason to code an app to lock your phone. Use Assistive Touch in Accessibility settings to accomplish hardware button tasks from a button on screen. This button is accessible on screen (but can be easily hidden) from anywhere on the phone, where as your "lock app" is only accessible from the home screen. Check out this support article. Trust me, my lock button is broken too.

You are getting the undefined symbol error because you are not linking to the private framework in your app. It needs to be included in your Build Phases Link Binary with Libraries step.
Since GraphicsServices.framework is not a public framework, it won't show up in the frameworks list. I found this answer that gives steps to link to a private framework. I haven't tried it, so YMMV.
How do I add the following private frameworks to my iPhone app?

Related

Using iOS 11 NEHotspotConfiguration capability on a Simulated Device and not just a physical device

I'm using the NEHotspotConfiguration Class in iOS 11 to connect to a known wifi network. This React Native app works fine on a physical device, and I'm able to programatically connect to a network using the NEHotspotConfiguration class on iOS 11. However, when I try and build/run it in a simulator I get the following error that prevents me from even launching the app:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_NEHotspotConfiguration", referenced from:
objc-class-ref in IOSWifiManager.o
"_OBJC_CLASS_$_NEHotspotConfigurationManager", referenced from:
objc-class-ref in IOSWifiManager.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Is there a way to keep using the Simulator to test the rest of my app with this capability enabled, even though I wouldn't be able to use the capability to change the wifi in the Simulator?
There may be other options, but I found the following potential answer in the comments of a medium article that led me to one solution:
https://medium.com/#ercp42/i-got-this-error-ceacd08191b3
"For anyone who experiences the same issue, I fixed it by wrapping the NetworkExtension import and the code where it’s used with #if !TARGET_IPHONE_SIMULATOR to side step this issue."
It was a bit more than that, at least for me, though.
I did indeed wrap the #implementation IOSWifiManager implementation in the IOSWifiManager.m file with an #if TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR and left a much simpler else statement to build it on the simulator:
#else
#implementation IOSWifiManager
RCT_EXPORT_MODULE();
#end
#endif
I also went into build settings and under Linking Other Linker Flags changed the values for the iOS Simulator and Any Architecture to the following:
"OTHER_LDFLAGS[arch=*]" = (
"$(inherited)",
"-ObjC",
"-lc++",
"-framework",
NetworkExtension,
);
"OTHER_LDFLAGS[sdk=iphonesimulator*]" = (
"$(inherited)",
"-ObjC",
"-lc++",
);
Finally, I changed the Network Extension Framework from being required to being optional and made sure that we were supporting the right build architectures. Hopefully that helps anyone who runs into the same issue!

dyld: Symbol not found: _UITransitionContextFromViewControllerKey

I've been getting reports of my app crashing on load in iOS 6. It's built with the iOS 8 SDK and works fine on 7 & 8.
I've just managed to get hold of an iOS 6 device to test and it does in fact crash on launch with the error:
dyld: Symbol not found: _UITransitionContextFromViewControllerKey
Referenced from:
/var/mobile/Applications/895BC1B3-A362-42C9-8560-5CF40A682A10/myapp.app/MyApp
Expected in: /System/Library/Frameworks/UIKit.framework/UIKit in
/var/mobile/Applications/895BC1B3-A362-42C9-8560-5CF40A682A10/myapp.app/MyApp
I understand that dyld is a linker problem, but have no idea where to start with this.
I've unlinked and re-added UIKit, but still doesn't work.
Thanks
This is because UITransitionContextFromViewControllerKey doesn't exist until iOS 7. Working around this probably isn't worth the effort--it means dropping all usage of UIViewControllerContextTransitioning, as the protocol is new in iOS 7, or creating a separate code path for iOS 6. If that's what you want, look into weak-linking UIKit, although this may result in slow startup.
Look like your using UIViewControllerContextTransitioning. It's available only on iOS 7+.
See this question for more details Restore pre-iOS7 UINavigationController pushViewController animation

dyld: Symbol not found: _OBJC_CLASS_$_NSNetService Error

So I have the following problem:
launching my application on iOS 8 on my iPhone 5s, I get no error, but launching my app on iOS 6.1.3 on my iPhone 3GS, I get this error:
dyld: Symbol not found: _OBJC_CLASS_$_NSNetService
Referenced from: /var/mobile/Applications/567E221A-FC5C-4011-90AD-E47E5FF033B1/BellyClient.app/BellyClient
Expected in: /System/Library/Frameworks/CFNetwork.framework/CFNetwork
in /var/mobile/Applications/567E221A-FC5C-4011-90AD-E47E5FF033B1/BellyClient.app/BellyClient
I imported a class named Server. The class uses the CFNetwork.framework, which contains the class NSNetService, which is avaiable since iOS 2.0.
Using NSClassFromString(#"NSNetService") is not really a solution I like.
I also don't know, why this error occurs, because the class NSNetService should be avaiable in iOS 6. Could it be the device?
I searched and found, that setting the framework to Optional, will solve this issue. But the problem is, that I cannot use the framework, when I run the application on iOS 6. When I do
if ([NSNetService class] == nil) {
NSLog(#"NSNetService is nil");
}
I get printed NSNetService is nil.
Is it possible to launch the app without crashing and without setting the framework as Optional
Thanks iComputerfreak
Try re-adding Foundation.framework:
Go to your project's target
Choose "General" tab
Under "Linked Frameworks an Libraries" look for Foundation.framework, select it and press the minus ('-') sign at the buttom to remove this framework.
Now press the plus sign ('+') and search for Foundation.framework - re-add it, and it's supposed to fix your crash.
Hope it works - it did for me.

After updating the app, user reports crash on iPad 1 running iOS 5.1.1

There is no crashalytics crash report that I get. And the user says that the app just hangs on the opening screen.
And this started happening only a few days ago. Would anyone know why this happens? And is there any reason why this started happening now?
When I run the app on my simulator with iOS 5.1 it works just fine.
I emailed you the crash logs & console logs. The immediate meat of it looks like you have a problem with ACFacebookAppIDKey...
Dyld Error Message:
Symbol not found: _ACFacebookAppIdKey
Referenced from: /var/mobile/Applications/<removed by D80buckeye>/BusinessPlan.app/BusinessPlan
Expected in: /System/Library/Frameworks/Accounts.framework/Accounts
in /var/mobile/Applications/<removed by D80buckeye>/BusinessPlan.app/BusinessPlan
Dyld Version: 199.6
EDIT:
With a little more research I think I found your problem. ACFacebookAppIDKey is only available in iOS6 and above. From ACAccountstore Class Reference
ACFacebookAppIdKey
The Facebook App ID, as it appears on the Facebook website.
Available in iOS 6.0 and later.
Declared in ACAccountStore.h.
Mark Social.framework, Accounts.framework as 'optional' in XCODE, NOT required, in Targets/Build Phases/Link Binary with Libraries.

deploying kony app in iphone device

I am facing some problem in kony platform. I can able to deploy the iphone app created using kony platform in simulator by using their guide. If i tried to deploy same app in iphone device i am getting some errors.
Undefined symbols:
"___divmodsi4", referenced from:
-[KonySlotView addImagesToGallery:urlString:userDataSize:userData:] in libkonylib.a(KonySlotView.o)
-[KonyImageGallery addImagesToGallery:urlString:userDataSize:userData:] in libkonylib.a(KonyImageGallery.o)
"_objc_terminate", referenced from:
-[KonyWebSQLTransaction performTransaction:SQLTransactionErrorCallback:SQLVoidCallback:IsReadTransaction:] in libkonylib.a(KonyWebSQL.o)
-[VMAppDelegate konyApplicationDidFinishLaunching:] in libkonylib.a(VMAppDelegate.o)
-[VMAppDelegate KonyExecute] in libkonylib.a(VMAppDelegate.o)
+[ClosureExecuter executeClosure:] in libkonylib.a(lglobals.o)
"___udivmodsi4", referenced from:
-[KonyImageGallery getPreferredHeight] in libkonylib.a(KonyImageGallery.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
error seems like some problem while linking library. can anyone help me to resolve this problem.
Thanks in Advance...
You will never resolve this, unless you contact Kony developer team, that I can tell you from experience. The issue is with the Kony API that is used to do the mappings with Lua code to objective-c code.

Resources