我有6.1.3 iOS的越狱设备。我也有命令行工具,应该给我坐标。有关位置的代码与普通应用程序完美配合,但不能在命令行中使用。
我发现了类似的问题,但它似乎不起作用:Get GPS without alert view with ROOT permission(jailbreak)
- (void) start
{
NSLog(@"Started");
if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorized)
{
NSLog(@"%i", [CLLocationManager authorizationStatus]);
}
//[locationManager setAuthorizationStatus:YES forBundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]];
[CLLocationManager setAuthorizationStatus:YES forBundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]];
NSLog(@"%@", [[NSBundle mainBundle] bundleIdentifier]);
NSLog(@"%@", [[NSBundle mainBundle] bundlePath]);
if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorized)
{
NSLog(@"%i", [CLLocationManager authorizationStatus]);
}
[locationManager startUpdatingLocation];
}
因此它始终将0记录为授权状态= kCLAuthorizationStatusNotDetermined。
在使用
构建后,我还添加了带有ldid的应用权利com.apple.locationd.authorizeapplications
键设置为true。还有一些Info.plist的实验,但仍然是
didUpdatedLocation
永远不会触发。
提前致谢!
如果需要,这是我的主要内容:
#import <Foundation/Foundation.h>
#import "locateClass.h"
int main (int argc, const char * argv[])
{
@autoreleasepool
{
// insert code here...
NSLog(@"Hello, World!");
locateClass *loc = [[locateClass alloc] init];
[loc start];
}
return 0;
}
我也在使用iOSOpenDev
更新:
如果我不使用Info.plist,使用此代码我在控制台中有这个:
iPhone-AppServer Saimon[841] <Warning>: Hello, World!
iPhone-AppServer Saimon[841] <Warning>: Started
iPhone-AppServer Saimon[841] <Warning>: 1
iPhone-AppServer Saimon[841] <Warning>: (null)
iPhone-AppServer Saimon[841] <Warning>: /private/var/mobile/docs/fromMac/Debug-iphoneos
iPhone-AppServer Saimon[841] <Warning>: 1
iPhone-AppServer awdd[842] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
iPhone-AppServer awdd[842] <Error>: CoreLocation: CLClient is deprecated. Will be obsolete soon.
如果我这样做 - 这样的输出:
iPhone-AppServer Saimon[854] <Warning>: Hello, World!
iPhone-AppServer Saimon[854] <Warning>: Started
iPhone-AppServer locationd[362] <Warning>: Launch Services: Registering unknown app identifier com.apple.xcode.dsym.Saimon failed
iPhone-AppServer locationd[362] <Warning>: Launch Services: Unable to find app identifier com.apple.xcode.dsym.Saimon
iPhone-AppServer Saimon[854] <Warning>: 0
iPhone-AppServer Saimon[854] <Warning>: com.apple.xcode.dsym.Saimon
iPhone-AppServer Saimon[854] <Warning>: /private/var/mobile/docs/fromMac/Debug-iphoneos
iPhone-AppServer Saimon[854] <Warning>: 0
iPhone-AppServer awdd[855] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
iPhone-AppServer awdd[855] <Error>: CoreLocation: CLClient is deprecated. Will be obsolete soon.
答案 0 :(得分:0)
如何加载info.plist?因为它返回失败...
Registering unknown app identifier com.apple.xcode.dsym.Saimon failed
答案 1 :(得分:0)
我发现解决方法并不那么容易。
步骤一步。
要授权自己,请停止定位过程,但killall -9 locationd
无法帮助您。停止它:launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist
然后以这种方式编辑/var/root/Library/Caches/locationd/clients.plist文件:
Root
|__<your_bundleid> (Dictionary)
|__Whitelisted (Boolean) - NO
|__BundleId (String) - <yourBundleID>
|__Authorized (Boolean) - YES
|__Executable (String) - <path_to_your_binary>
|__Registered (String) - <path_to_your_binary>
然后开始定位:
launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist
在此之后可以获取位置,但是在命令行工具didUpdatedLocations
方法不会触发,还有一个问题:大约一分钟后你[CLLocationManager AuthenticationStatus]
会给你拒绝状态,所以你需要再次手动编辑plist并从你的bundleid字典中删除TimeMissing
键。
以下是自我注册后为我工作的代码:
while (1){
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
CLLocation *location = locationManager.location;
if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorized)
{
NSLog(@"%i", [CLLocationManager authorizationStatus]);
if( [CLLocationManager authorizationStatus] == 2)
{
system("ps ax | grep locationd");
system("launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist");
NSString* plistPath = [[NSString alloc] initWithString:@"/var/root/Library/Caches/locationd/clients.plist"];
NSMutableDictionary* plist = [NSMutableDictionary dictionaryWithContentsOfFile: plistPath];
NSMutableDictionary *myBundle = [plist objectForKey:[[NSBundle mainBundle] bundleIdentifier]];
[myBundle removeObjectForKey:@"TimeMissing"];
NSLog(@"Relaunching");
[plist setObject:myBundle forKey:[[NSBundle mainBundle] bundleIdentifier]];
[plist writeToFile:@"/var/root/Library/Caches/locationd/clients.plist" atomically:YES];
system("launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist");
}
}
NSLog(@"Coordinates are %f %f %f %f",
location.coordinate.latitude,
location.coordinate.longitude,
location.horizontalAccuracy,
location.verticalAccuracy);
if ( location.coordinate.latitude == 0 && location.coordinate.longitude == 0)
{
NSLog(@"Nulss");
system("launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist");
system("launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist");
}
else
{
NSLog(@"Got IT");
//[locationManager stopUpdatingLocation];
//break;
}
sleep(10);
}
在iOS6和iOS7上测试。