【发布时间】:2013-12-20 04:24:49
【问题描述】:
我有 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
键设置为真。也对 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.
【问题讨论】:
-
您确定
[[NSBundle mainBundle] bundleIdentifier]会返回您的捆绑包ID吗?我没记错,它不适用于纯二进制应用程序,因为没有包,因此没有包 ID。它适用于普通应用程序,因为它们是作为捆绑包安装的。尝试只传递一些字符串,如@"com.company.myapp"作为捆绑 ID。当我想在守护进程中获取位置时,这就是我所做的。 -
我把 Info.plist 文件放在二进制文件附近,所以当我启动二进制文件时,我有 bundleId 和状态 0。如果我删除 Info.plist,那么我没有 bundleId 和状态 1。你知道,关于 setAuthorizationStatus 的编译器警告:找不到类方法“+setAuthorizationStatus:forBundleIdentifier:”(返回类型默认为“id”)可以吗?我没有在任何地方声明。
-
是的,这很正常。做了一个快速测试 - 它对我有用。使用与您完全相同的代码并获得
kCLAuthorizationStatusAuthorized作为状态。不知道didUpdateLocation但location属性确实包含位置。 -
location 属性可以,但纬度和经度为 0.0。你使用 iOSOpenDev 吗? Semitethered越狱会影响它吗?另外我想我应该补充一点,我在使用 ldid 构建后添加了权利: ldid -S/
/entitlements.xml /binary -
不,我只是使用 Xcode 将它构建为一个普通的 iOS 应用程序。 “Semitethered越狱会影响它吗”我不这么认为。使用
ldid -e检查权限是否确实在二进制文件中。启动应用程序时还要检查控制台。有时 iOS 会在其中记录一些有用的信息。
标签: ios cllocationmanager jailbreak