healthStore.requestAuthorization() crashes Apple watch application - swift

I'm trying to collect health data in my Apple Watch application but when I call healthStore.requestAuthorization my app always crashes. I have set NSHealthShareUsageDescription and NSHealthUpdateUsageDescription in Info.plist as required but it still crashes.
I started a new project and am just trying to request authorisation, there is no other functionality that could affect it.
Any ideas why this is?
Thanks for any help.

I found what the issue was. There are two Info.plist files that need NSHealthShareUsageDescription and NSHealthUpdateUsageDescription. One in the project file and one in the watch extension file. I had only done one of these.
The strings for these also need to be a reasonable length and cannot be just a couple of words.

Related

is NSLog() stored on the device (iPhone etc)? If so, where?

Should all NSLog() calls be deleted in the final app for iTunes?
In my iOS app, I've got lots of NSLog() for debug.
Should I conditionally code them out before uploading to iTunes?
This is for an app for: iPhone, iPod, iPad
Thanks.
I'll answer the OP's question in the title about where the logs are stored on the device. NSLog() uses the ASL (Apple System Logger). Programmatically, you can only read the last 256 entries (which is what Xcode shows in the Organizer, for example).
However, if you want to access the full files, they are stored in:
/private/var/log/DiagnosticMessages
When you look into that directory (note: device must be Jailbroken), you'll find a long list of *.asl files.
I found a tool to parse those files, but I haven't tried it yet, so YMMV:
Parsing Apple System Log (ASL) files on iOS and OSX for Fun and Evidence (and a Python script to do it for you)
You don't have to remove all of them; in fact, they can be useful if your app crashes on a user's phone and you want them to send you a crash log. When a user syncs his/her phone, the crash log is located in the folder
~/Library/Logs/CrashReporter/MobileDevice/<DEVICE_NAME>
If you have NSLog()s you may gain useful information just as you would when debugging. As the others pointed out, don't overdo it, but it they could end up being useful.
Yes, We should remove all the NSLog() calls before uploading to iTunes. That is done mainly for better performance.
Even if u dont remove them, no problem. It will be approved. But if u have lot NSLog() s, the that will def. affect the performance.
Try using this for your NSLogs:
#define DEBUG
#ifdef DEBUG
NSLog(#"Your tests outputs");
#endif
Not all. You should keep the error logs. That will make it easy to locate if there is any error or crash.
Its possible to see NSLog messages using Organizer too.
You dont need to remove NSLogs if they added against DEBUG mode. So even if your app crashes and if it contains user personal data, it will be removed by ios. So do not worry about user data and NSLog. Refer https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AnalyzingCrashReports/AnalyzingCrashReports.html
Still if you want you can use this PJiOSAppConsole in your application. It will keep logs in your application only. You can use it at runtime by adding snippet in #ifdef then remove whenever you want to go to live. Easy to integrate and use.

iPhone app is region locked

First I need to mention that I'm not a developper, but I can probably work my way around enough in xcode to fix this little issue.
I submitted an application to the app store (that was developped by someone else who's not available right now), but it was rejected because it's "geolocked", meaning the application can only be accessed if you set your international "Region format" setting to Canada.
I need to know what modification I need to make in order for this app to work on all region formats. Is it a string I need to change or is it hidden in a plist file ? I have the feeling the fix is quite easy to apply.
I’ve never heard of an iPhone app using region formats to prohibit launches. I suspect your developer put this code in either out of naïveté or malice; either way, you’ll need to look for a section of code that inspects the region settings.
I'm not aware of something like "geolocking" of iOS application. The only thing you can do, which is quite close to your question, is to set in which countries is this application available. This can be set in iTunes Connect.

Browsing through all iPhone application

Hope You all are fine..
I have a query to ask regarding new features of iPhone 4.0
My Question is .. Is there any possibility to brows any document throughout the iPhone through the application ?
I mean, Suppose in one of my application have feature to share file using Bluettoth, Now When i run this application lastly, I received one file from my Friend. and its still there.
Now i Run my Second Application and i want to access those received file in relier application here in new application.. Is there any way to implement this?
If any one have any idea, kindly guide me.
Looking Forwards,
Arun Thakkar
From the Guidelines:
2.6 Apps that read or write data outside its designated container area will be rejected
There might be a global area where you can download and access.. I'll check

How to show related city name according to the incoming call on iPhone?

I want to add something (eg. the related city name) into the UI view when I make a phone call or received a phone call on iPhone. However, I can't figure out a good solution for this idea. Could anyone who has experience on this subject gives me some suggestions?
My currently solution is, try to write an extension based on mobile substrate and hook functions in SpringBoard. So many difficulties existed and following are my current big questions,
How to develop such a extension? I downloaded some examples from google, unfortunately they cann't even be compiled on my toolchain.
I can't figure out which ui view for the related screen I should use to insert my own component. I get header files of SpringBoard via class-dump, but no docs and no comments about its usage. Could someone share his discoveries with me?
How to build a trusted cross-compiling enviroment on leopard? All kinds of confusing errors pop up when I try to build others's codes. I've tried Zdziarski's instrunctions in his book, it works with iPhone OS 1 and can compile common projects with open sdk, but how should I do to make it works when comipiling ms plugins?
Also, is there any other solution to translate my ideas to codes? I start iPhone development one month ago, no experience with cocoa/Obj-C before. So your suggestions are very appriciated.
~ Link Bian (卞林扣)
Email/MSN: linkou.bian#gmail.com
I think you are asking for too much. It wont be possible to manipulate incoming/outgoing call screens. Ethically, that is.
Zdziarski is a hacker and from his book, you will get many undocumented API calls which will make Apple reject your app. Same goes for Erica Sadun's iPhone Developer's Cookbook.
Something that really helped me get dylibs compiled was using SkylarEC's Xcode template and just appended an extension of '.dylib' onto the binary and sshing it into /Library/MobileSubstrate/DynamicLibraries. I suggest hooking SBCallAlert or SBCallAlertDisplay to get the id of the caller which is usually just an NSString. Play around with it a little bit, those are all the visualizing methods of a call. If you put in an nslog in your custom override method, you can view the output in iPhoneConfgurationUtilitie (windows) or the console in Xcode. From there you would most likley need an index of area codes to comare the callers to. I don't believe you can add subviews to the call, on I intercept and reissue the strings for the views already there.
But you know, apple doesn't like this :P
lemme know if this helps

reading a file saved by another app in iphone

Is there a way to have an app write a into a file and then have another app read from that file?
I mean writting into the file system of the iPhone.
I want to do this without using an internet connection. So uploading the file and then downloading from the other app is not what i mean.
Thanks!
It appears that there are ways you can, but it won't get approved by Apple if you do.
See http://blogs.oreilly.com/iphone/2008/09/sandbox-think-like-apple.html for more information.
The current sand boxing of applications does not allow this, however it appears that this may be available in future iPhone OS versions. Reference
I'm not sure exactly what circumstances you're in here, but you could register app B as a handler for a particular protocol, and have app A try to open such a link (e.g. appB://yourinfohere). It depends on how much data you want to transfer and many other things, but it might work.