What is calling requestWhenInUseAuthorization? - xcode

I am working on a react-native app. I send it to Testflight. Apple says it's missing NSLocationAlwaysUsageDescription. However, I don't see where is my app asking for location data? The app doesn't show a prompt for it. I looked at the code, and nowhere is it actually calling requestAlwaysAuthorization nor requestWhenInUseAuthorization.
How can I find out what is calling requestAlwaysAuthorization or requestWhenInUseAuthorization? Does XCode allow to have some breakpoint for those functions?
Thank you,
Slackware

Related

Xcode Debugger Doesn't Begin Session When App Runs

I'm using version 12.4 of Xcode, and when I run my app to test it, the debugger never starts a session. When I open the Debug Navigator, the message "No Debug Session" stays, and none of the normal analytics data appears.
I am running my app through Xcode onto my iPhone 12 Pro. It requires the use of the camera, and in fact the part I need the debugger for also requires the camera, so I can't use a simulator to see if that magically fixes it.
I also looked through every setting I could find that mentioned "Debug" or "Debugger", but nothing I could find changed anything.
Also, I downloaded a random tutorial app and ran that through Xcode on my iPhone, and the debugger boots up as expected.
I am completely lost and really need a GDB/LLDB tool to debug my code, so any help is greatly appreciated, as I could not find a single person or post with a similar problem to mine, and all of the Debugger tutorials and Apple Documentation are outdated and useless.
EDIT: Here is the Scheme info I have set, I have nothing in the Arguments tab. (This is a new account so I'm not allowed to embed images RIP)
Scheme Info
Scheme Options
Scheme Diagnostics
As Matt pointed out, the debugger will not point at the app target if the Executable dropdown (in Scheme Info) is "Ask On Launch". It must have the app itself selected.

Xamarin iOS Library can't get location

I have a vendor provided .framework file that I created an iOS binding project for using Objective Sharpie. I can call into the library, get callbacks, pull data, mostly everything works except the library being able to access the current location. The public headers for that project are here StripeTerminal
In my C# code, I used the Xamarin.Essentials to pull the current location.
var location = await Geolocation.GetLastKnownLocationAsync();
This returns with my location both in the simulator and on a real iPhone. I can see the access is granted to my app in the Privacy-> Location Services menu.
I have the below in my info.plist file, which I have tried targeting 9.0 SDK and 12.0 SDK.
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location required for accepting payments.</string>
In an example XCode project provided by the vendor, that is able to pull the location by inspecting their verbose logs. In the Xamarin app, their logs get stuck on a requestLocation and never continue past it. I even tried setting the Link option to Don't Link and the result is the same.
What is wrong with my binding project that would prevent a native framework library from being able to access the location?
The issue was a mix of how Xamarin works and iOS. I created a CLLocationManager object in my C# code and setup a listener for location changes, except it never worked. So I tried the Xamarin.Essentials package to get the current location using GetLastKnownLocationAsync and that worked every time, so it wasn't a permission issue or a simulator issue. Digging into the Xamarin.Essentials code I found the below.
NSRunLoop.Main.InvokeOnMainThread(() => manager = new CLLocationManager());
Reading more documentation, I found that the CLLocationManager can only be successfully created from an active run loop. Wrapping calls into the Stripe Terminal iOS SDK in the NSRunLoop.Main.InvokeOnMainThread allowed things to work as they were creating a CLLocationManager expecting the call to be in an active run loop without checking first, or documenting that behavior. Stripe's internal code waited on a callback, which never happened, thus hanging the SDK in a weird state.

iOS9 Share Extension can not debug on Xcode

When I build share extension from Xcode for the real device, Xcode arbitrarily stop debug. But when I launch for simulator, the problem does not occur.
Environment
Xcode 7.1.1
iOS 9.1
Details
When I build share extension, Xcode shows "Finished running MobileSafari.app on iPhone", but Safari does not run. And, The square stop button is arbitrarily gray. So, I launch Safari by myself and choose my extension and post. The debug section does not show anything. Also, URL request is not sent Rails server.
This is the picture when I build the share extension for the real device.
I do not know why the real device can not launch share extension at Xcode.
If anyone know the answer about this problem, please tell me.
Typically you can debug a share extension by going to Debug -> Attach to process or PID and entering the name of your share extension. From there you can open the share extension on your device or simulator and Xcode's debugger should attach and hit breakpoints correctly. However, I've noticed that log messages do not show up when doing this, nor do values populate for variables in the debugger view.
Here's how I got the debugging to work correctly. Run the share extension scheme. When it asks you what app to run, chose 'Photos' (because that's the app your extension will operate in). The Photos app will then launch on your device and you may proceed to use your extension. The debugger in Xcode should then work as expected.
I encountered this issue as well, though unfortunately I don't know the exact solution, maybe I can offer some information that might be helpful.
I (like you, judging by your screenshot) was using Cocoapods, and Cocoapods was copying resources from the pods into the bundle of the app extension after it was code signed. If memory serves, this was interfering with the code signing in some way, and therefore preventing the app from running under the debugger.
I believe that one of the symptoms of this was that logs appeared in the mac's console (or the device's console, can't remember which) saying something about "blasting onto the device using the old skool[sic] method."
You could confirm that this is the case by removing Cocoapods from your project, or any pods that require resources to be copied after compilation. I believe that the solution was to add some kind of special build phase to the extension project to copy the bundle resources, and disabling whatever Cocoapods uses by default.
As a temporary solution, I believe that deleting your app from the device should allow you to attach the debugger once, on the run where the app is installed for the first time. You might also try deleting derived data for your project.

Cloudkit error when querying public database from simulator

I'm working on an app where I recently decided to go with CloudKit and am now at the point where I need to implement the backend functionality. In a nutshell, this app will use a collectionview to display images retrieved from a CK database. Up until now, I just dumped some images in a folder on my desktop and retrieved/parsed the images from there to render the collectionview. I then used the CK dashboard to create some records and wrote an initialization method to try and retrieve them. I was getting various CKErrors, such as network failure, error completion without receiving a response from the server, could not send a valid signature, etc. I immediately assumed the issue was with my code since it was my first attempt with CloudKit. However, I ran the latest code on my device before posting on SO and it worked! I got a successful response with the number of records in the results array that I was expecting.
So now I know longer need help with fetching CKRecords like I initially thought. But how do I resolve this issue with the simulator? I saw some other post about making sure you're signed into iCloud on the simulator. I believe I am, but do not know how to check to be sure. Also, I'm running Yosemite and Xcode 6.1.
Any help is appreciated!
on the simulator go to the settings app. You can do that with menu hardware, home and then open the settings app, select iCloud and make sure that you are logged in.
To use your Apple ID on iCloud on the iPhone Simulator, make sure you turn off Two-way authentication. It should then work on the simulator.

Obtaining OS X app store receipts on test builds

Been trying tonight to obtain a receipt for my app. However, I've been unsuccessful. Here's the steps I've done:
Code signed with developer cert
Made sure minimum version in the info.plist is 10.7
Checked for the presence of the receipt file and called exit(173) if not found
Built from XCode 4.2
Added a new version of the app and some in-app metadata in itunesconnect. The app status is now waiting for a new binary.
I've then done clean, build, right clicked on the app in XCode's project view and opened it in finder to launch it, hopefully failing validation and pulling a receipt back from the store.
However, this never seems to happen (don't get asked for any itunes login etc) and the app terminates immediately.
I've also gone through an entire build/archive/create installer type process as well but that didn't pop up the login either.
Am I missing something obvious?
Thanks!
I've finally got it working. In case anyone else has a similar problem, the real help for me was finding out about console.app. In running this I could see my app didn't appear to be signed.
I deleted all the certificates etc and re-installed new ones. Seems it HAS to be the Mac 3rd party developer. Nothing else seemed to work.

Resources