How to test the purpose string of NSPhotoLibraryUsageDescription in iOS using Expo? - ios

I've been struggling to verify if the purpose string for photo library access really is working as expected. It started with the application got rejected because it wasn't set.
Using expo-image-picker, it says in the docs that adding this into the plugins section in app.json should set the NSPhotoLibraryUsageDescription:
[
"expo-image-picker",
{
"photosPermission": "This allows you to upload a photo to your Appname profile."
}
]
Before I added this, I basically added NSPhotoLibraryUsageDescription to the plist key inside ios section in app.json. What I can see, both do exactly the same thing.
After building ios using expo build:ios I was able to verify that that the string existed in the Info.plist file:
<key>NSPhotoLibraryUsageDescription</key>
<string>This allows you to upload a photo to your Appname profile.</string>
Using Expo Go doesn't really help since when requesting permissions, it says "Expo Go" in the alert.
Also, I only have experience working with Expo / React Native, and have no access to a mac (or xcode).
When apple test this, it looks like this (according to their screenshot):
While the expected text should be:
This allows you to upload a photo to your Appname profile.
How can I verify that the purpose string is really set (and works) before submitting an application to App store?

My solution:
First I set up my app for an EAS build. If you're not familiar with that you should check out the docs: https://docs.expo.dev/build/introduction/
Basically you do this:
install eas-cli: npm install -g eas-cli
run eas build:configure to initialize an eas.config file.
configure your eas build profiles. Mine look like this:
I collapsed the submit block to hide my credentials. Sorry for the photo instead of code/text. The formatter kept messing it up.
Any way, trigger a build using eas build -p ios --profile development. Notice the simulator flag set to true. This will allow you to run this as a stand-alone binary in your simulator.
When your build completes, go to expo.io and log into your account. Click on your project and download the binary for your ios build (under the builds tab). Unzip the binary and drag it into your simulator. You may be prompted with a message that says that you need to start up your development server. Just follow those simple instructions and there you go. You'll be able to see if your NSPhotoLibraryUsageDescription string updated.
Admittedly, this can be a pain in the (insert donkey emoji here - still don't have one yet Apple....😡) and you're kind of executing outside of the expo environment, but it solves the problem of wondering if your string has updated before posting to the store again.
Best of luck. Hope that helps.

Related

Can't get debug token for Firebase App Check for my Flutter iOS App

So I recently started setting up app check for my existing Flutter project (for both android and iOS platforms). I've had no problem with android's "Play Integrity", got the necessary debug token, and can successfully send and retrieve data to/from firestore (app check for firestore is currently enforced for my project).
The problem is, I can not get such a debug key for my iOS app. I will list the sources I've used and what I've tried so far.
I have firebase_app_check: ^0.1.1+8 installed via pubspec.yaml
I also added pod 'FirebaseAppCheck' to my Podfile
I have the necessary initialization code in my main.dart: await FirebaseAppCheck.instance.activate(...);
For "DeviceCheck", I am using THE SAME private key that I am using
for "Sign in With Apple" (which I have implemented successfully). I
have also enabled the checkbox for DeviceCheck in the settings of
that private key (in Apple Developer).
For my App ID (Apple Developer > Identifiers > App IDs), I have also
enabled the checkbox for "App Attest".
I have put "-FIRDebugEnabled" as an argument passed on launch in
XCode > Product > Scheme > Edit Scheme.
I always uninstall my app from my iOS simulator (iOS 16.2) or real device (iOS 16.1.2),
before trying again, because I have read across multiple forums that
the debug token only gets printed to the output the first time you
run your app.
I have also added these 4 lines of code in my AppDelegate.swift from here:
#if DEBUG
let providerFactory = AppCheckDebugProviderFactory()
AppCheck.setAppCheckProviderFactory(providerFactory)
#endif
Official firebase docs "iOS+ (App Attest)":
I have NOT copied ANY code from this page of the official docs, as I assume it's for native iOS apps only, and not for flutter, and I don't know where exactly I would have to put that code. I have only added the pod dependency and run pod install.
I don't have a .entitlements file.
So after all those steps, I'm apparently supposed to expect to find a debug token in my run output, as in:
Yet the only relevant output I can find is the following:
Runner[72719:33546579] 10.3.0 - [FirebaseFirestore][I-FST000001] AppCheck failed: 'The operation couldn’t be completed. (com.apple.devicecheck.error error 1.)'
If it matters:
I have NOT YET uploaded my iOS app to apple developer, app store connect or whatever (I'm not yet familiar with the process of publishing to the app store).
Neither have I uploaded my android app to Google Play console or created an app there (for this project).
Don't tell me anything about firestore rules. I already had that set up long ago, and everything worked just fine before I started integrating App Check.
Don't recommend any 3rd party plugins to me, I will only use official ones.
The firebase documentation says:
Tip: Confirm in your Xcode project's build settings that it passes the DEBUG flag to the Swift compiler
Try removing the '#if DEBUG' and '#endif' and run the app.
If it works, it mean you have missed that step
I was not able to find that build setting, so i just removed those lines from the AppDelegate, but i need to keep in mind to remove the other 2 lines while building the release mode
See this answer on the flutterfire Github issues page. Basically, call setAppCheckProviderFactory before GeneratedPluginRegistrant.register(with: self) in the app delegate file. I was investigating the same issue and it fixed it for me (the debug token was instantly printed out in Xcode's debug output). Hope it helps you as well!

UnexpectedAppleResponse Error when trying to publish app to App Store

I'm trying to publish my first app to the Apple App Store. It's an Expo React Native App.
I'm currently submitting the build to the app store with eas submit -p ios --latest. However, I'm getting the error:
Failed to create App Store Connect API Key.
UnexpectedAppleResponse: The specified resource does not exist - There is no resource of type 'apiKeys' with id 'XXXXXXXXXX'
I'm watching an online tutorial and I've been able to follow every step until now. Any advice on how to fix this error would be greatly appreciated. Thank you in advance!
You need update your EAS to 0.60.0
npm install -g eas-cli
I had the same problem.
Work for me, friend
We fixed this issue by next steps
1: Upgrade your eas-cli running: npm install -g eas-cli
2: If you're publishing by first time your app, you need request access in to your App Store Connet, by this link,
https://appstoreconnect.apple.com/access/api
Select Users and Access, and then select the API Keys tab.
Then, click in "Request access" blue button, and then, your api keys generated will appear there.
Then download any key, open whit text editor and paste the path of file in eas terminal, by selecting "[Enter an App Specific Password]"
Important: Is not necessary creare a new key if you has already downloaded your key
We hope this works for you.
And that's it.
There is a bug in Apple's infrastructure that does not propagate newly created objects for a long time (up to 14 seconds in my experiments). Apple responds saying the resource does not exist when the cli tries to download the key and it hasn't fully propagated. I just released a fix in eas-cli to retry in this scenario, it should be available in v1.1.1.

Custom Expo Development Client for Simulator

I had a specific question about installing a custom expo development client on a simulator, specifically an iOS simulator. I know that there is a way to install an expo build in a simulator (outlined here: https://docs.expo.dev/build-reference/simulators/), but this is just a build and not a development client, which are two very different things. The concept of an expo development client is outlined here: https://docs.expo.dev/development/introduction/. That means there is no Fast Refresh available, and I cannot modify my app in real-time by changing my code. This is a really important feature for me because I need to make sure my app is compatible with all iPhone sizes, and I need to be able to see the changes quickly without having to make a build every single time. Does anyone know how to do this, or if this is currently even possible?
A more detailed explanation of the issue can be found here: https://expo.canny.io/feature-requests/p/custom-dev-clients-for-simulator
Essentially the issue that I had was I did not set up my eas.json file correctly. I needed to change the preview build profile in the eas.json file so that it contained these parameters: "developmentClient": true and "ios": { "simulator": true } I then built my project using the command eas build --profile preview. I then followed the steps of downloading the tar.gz file, extracting the .app file, dragging it into the simulator, and I was able to successfully open the app and connect it to Metro where I could then see live changes.
Like #Raamiz Abbasi said, you can set developmentClient and simulator to true in your eas.json however if you want to go further, you can also use expo-dev-client to create a "custom expo go app" which is basically a customized expo go which you can publish updates to with the eas-update.
Expo Go and this new "development client" are both clients which serve the purpose of displaying your JS bundles. But, with the expo-dev-client you can do cool things like add extra debug buttons into the menu, or run publishes (or eas updates in this case) which would automatically feed into the dev client.
The reasoning for doing this, besides adding extra debug stuff in the debug menu, would be to avoid the pain of only being able to expo publish a "release" build. Right now expo publish builds used with expo go cannot be debuggable.

Expo Ios Build Does Not Contain Valid Info.plist?

I have built a react native project with expo. Whenever I drag the finished .app file into my xcode window I get this error.
How would I go about fixing this?
We will need more info about your app to really help with this. As you are using Expo, you have no direct access to the Info.plist file for iOS. That would have to be maneuvered using the app.json.
You would need a specific configuration property based on what exactly is believed to be requiring a "Valid Info.plist" the message says.
See Expo's documentation on this here: app.json

Publish Android Application does not work

Just created an .apk with the Publish Android Application option, created a keystore with key and uploaded to the Google Play app store. Everything worked, but when I tried to download the app from the app store i got an error message resembling "The application has an incorrect signature". I thought the "Publish Android Application" part of Xamarin.Studio was supposed to fix everything?
I ran the following command on the .apk afterwards: jarsigner -verify -verbose -certs app.apk At the bottom it said the following: This jar contains entries whose certificate chain is not validated.
Please help, would love to have the app out today :)
My problem was simple. XamarinStudio was setup to use Java1.7, setting it to use Java1.6 fixed it :)

Resources