Where will get Location Updates feature in XCode? - xcode

I can not show/get the "XCode project (Project > Signing and Capabilities > "+ Capability" button) and select the Location Updates" feature in my XCode.
it is in the link
https://pub.dev/packages/geolocator
On iOS you'll need to add the following entries to your Info.plist file (located under ios/Runner) in order to access the device's location. Simply open your Info.plist file and add the following (make sure you update the description so it is meaningfull in the context of your App):
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location when open.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access to location when in the background.</string>
If you would like to receive updates when your App is in the background, you'll also need to add the Background Modes capability to your XCode project (Project > Signing and Capabilities > "+ Capability" button) and select Location Updates. Be careful with this, you will need to explain in detail to Apple why your App needs this when submitting your App to the AppStore. If Apple isn't satisfied with the explanation your App will be rejected.
When using the requestTemporaryFullAccuracy({purposeKey: "YourPurposeKey"}) method, a dictionary should be added to the Info.plist file.
<key>NSLocationTemporaryUsageDescriptionDictionary</key>
<dict>
<key>YourPurposeKey</key>
<string>The example App requires temporary access to the device&apos;s precise location.</string>
</dict>
The second key (in this example called YourPurposeKey) should match the purposeKey that is passed in the requestTemporaryFullAccuracy() method. It is possible to define multiple keys for different features in your app. More information can be found in Apple's documentation.
NOTE: The first time requesting temporary full accuracy access it might take several seconds for the pop-up to show. This is due to the fact that iOS is determining the exact user location which may take several seconds. Unfortunately, this is out of our hands.

you need to click + Capability then select background mode and then select location update

Related

NSCameraUsageDescription key error in Xcode

I'm trying to access a webcam for a project using OpenCV in Xcode, but I keep getting this error:
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.
I'm using a command line tool which doesn't come with a default Info.plist file, so I created an Info.plist file and added it to my project directory and added the correct key and description, but it's still showing me the same error.
The key I'm using is: Privacy - Camera Usage Description
The value I'm using is: App requires camera use to do edge and line detection.
If you added the entry to the correct info.plist file, but it still failed, it may be because Xcode sometimes fails to notice changes to resource files like info.plist, images, audio, movies, etc. You may need to perform a clean or delete the app build product from the Derived Data folder to force Xcode to use the latest version
Alternatively open Info.plist as source code and add this:
<key>NSCameraUsageDescription</key>
<string>Camera usage description</string>

Automatically allow app (built & run by Xcode) to control your computer

I am developing an assistive MacOS app in Xcode / ObjC.
It intercepts keystrokes using event-taps.
When I run it from Xcode, I get:
2019-07-05 06:20:32.423783+0300 mapper[8108:1191874] unable to create event tap. must run as root or add privileges for assistive devices to this app.
2019-07-05 06:20:32.423809+0300 mapper[8108:1191874] No Event tap in place! You will need to call listen after tapEvents to get events.
I have to go to system preferences -> security & privacy -> privacy -> {unlock the padlock putting my admin password} -> {locate, uncheck and recheck my executable from the list}, like so:
Every time I modify a line of code and run again I have to go through this process of checking and unchecking.
It is a very clumsy development cycle.
Is there any way to avoid this?
This project was using a 4-year-old Xcode project file.
Starting with a fresh Cocoa App template and copying the files in, the first time I build and run I am now automatically presented with:
... which takes me to the preferences pane and previous screenshot. Subsequent rebuilds do NOT require toggling the setting in this dialog. It is only if I "Clean Build Folder" that this process repeats.
My guess is that the improved behaviour may be because the new project is derived from a Cocoa App template (which inherits its base object from NSApplicationDelegate, whereas the old one inherited from a Commandline App template (and I had to manually manage the run loop with CFRunloop).
Getting mouse coordinates on Mojave contains an answer offering instructions on how to add a row to entitlements.plist:
The entitlement that allows an application to use the Accessibility API is the com.apple.private.tcc.allow entitlement (with a value of kTCCServiceAccessibility). As you can probably guess from the name it is only allowed on Apple signed binaries.

iOS UI test target is missing entitlement icloud-services

I have an app that uses iCloud. This works fine.
I now tried to write a UI test that checks first if the iCloud account is accessible, i.e. that the user is logged in to iCloud and iCloud is enabled for the app.
To do so, I tried to call (CloudKit is imported)
let container = CKContainer(identifier: kICloudContainerID)
container.accountStatus() { (status, error) in
// …
}
However as soon as I try to access CKContainer (1st line), I get the error
The application is missing required entitlement com.apple.developer.icloud-services
(null)
Of corse, my app has iCloud entitlements set, but such entitlements cannot be set for a test target.
I have read this post. The suggested solutions (disabling breakpoints, toggle iCloud capabilities, clearing out the code signing entitlements) did not work.
Any idea how to solve this problem?
EDIT:
For testing, I created a new Single View App with UI Tests included.
In the app target, I enabled only CloudKit:
In the app delegate, I imported CloudKit, and accessed CKContainer:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let container = CKContainer(identifier: "iCloud.com.zeh4soft.EntitlementUITest")
return true
}
This works.
In the UI Tests, I imported also CloudKit, and added the same line:
func testExample() {
let container = CKContainer(identifier: "iCloud.com.zeh4soft.EntitlementUITest")
}
This does not work, but gives the same error:
I contacted Apple, and they found the solution for a device, but not for a simulator.
I did the following steps:
Setup in Xcode a completely new Single View App project and include UI tests. Call it „EntitlementUITest“.
This will create in the project navigator a folder called „EntitlementUITestUITests“.
Select in this folder „EntitlementUITestUITests.swift“.
There is a function testExample(). Add in this function the line
let _ = CKContainer(identifier: "iCloud.com.yourid.EntitlementUITest")
yourid is e.g. your company name.
This is the statement that causes the run time error if the project has not been prepared as laid out below.
Select in the project navigator the project.
This will display an additional pane with the project and the targets.
There are 2 targets: The main target „EntitlementUITest“ and the UI test target „EntitlementUITestUITests“.
Select the main target „EntitlementUITest“.
In the top bar of the window right of the pane, select „Capabilities“. You will see that you can select iCloud usage.
Now select the test target „EntitlementUITestUITests“. The top bar now does not have „Capabilities“. This means, the setup that allows your UI tests to use iCloud is much more complicated, and has to be done manually.
First, one needs an entitlements file that specifies the capabilities that the app wants to use. I manually created the following file (actually, I copied the entitlements file of the main target and edited it):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.com.yourid.EntitlementUITest</string>
</array>
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudKit</string>
</array>
</dict>
</plist>
I added this file to the project.
In order to allow the UI test target to use iCloud, one needs now a few action in the development center.
In your web browser, open the development center, and open there „Certificates, Identifiers & Profiles“.
The test target is treated as a new app. Thus, it needs a separate app ID.
Open App IDs, and add a new ID „EntitlementUITestUITests“.
It should be an „Explicit App ID“ that uses the bundle ID of your test target, here
com.yourid.EntitlementUITest.
Enable iCloud and Push notifications.
I am not sure if Push Notifications are required, but Apple told me to do so. Probably, you can omit it in the entitlements file and here.
If it is present, please ensure that a valid certificate is specified for the push notification service.
When you enable iCloud, ensure that iCloud.com.yourid.EntitlementUITest is the only one selected among the assigned iCloud containers.
Create next a new development provisioning profile (one that uses your iOS developer certificate) and associate with com.yourid.EntitlementUITestUITests.
Download the profile.
Back in Xcode, select again target „EntitlementUITestUITests“ with tab General.
In the section Signing, uncheck Automatically manage signing, since this does not work.
In Signing (Debug), select in the drop down menu Provisioning profile to import your just downloaded profile. This will also be selected in the Signing (Release) section.
Now the project should build for testing without errors.
Run the testExample. It should run now without run time error.
Conclusion:
It is possible to access a CKContainer in an UI test, but this is incredibly complicated.
Why is this process not as easy as with the main targets?
Maybe too less developers UI test their iCloud apps, otherwise more enhancement requests to Xcode would have been written…
One more thing: If everything was done right, the test runs only on a device, not on a simulator. Apple said, running this test on a simulator gives unpredictable results. For me, it was predictable - it fails always.

How to get around Apple app ID insanity

As you all know, Apple changed how Xcode works such that you can't ever create an app with a previously used app ID, even if you're just writing test apps to use locally. Up until now I've just been typing in garbage IDs to get around this stupid antifeature, but today I was greeted with this gem:
So now I'm blocked from creating any more test apps, effectively stopping my development dead in its tracks (I write libraries and frameworks, and need to test them in test apps).
Does anyone know of a way to bypass or disable Apple's restrictions?
It is a kind of limit of free developer accounts, but you could figure out a solution for that:
1- Navigate to the project of any previous application that have been installed on the same device has the problem with .
2- Open Build Settings tab for the app project in Xcode .
3- Search for Bundle ID and copy it .
4- Open up your current app that has the problem and navigate to the same place > Paste and Replace the current Bundle ID with the old one.
5- Run the app.
!!! WALA
Same thing happened to me. I presume it's some kind of a new limit that Apple has put on "non-paying" developers, and that it limits you to 10 apps in 7 days.
Edit - To resolve this, I'll just make a random apple dev ID...
I faced the same situation in my new mackbook with xcode 7.3.1 version.
Even if I tried with old bundle identifier, it didnt worked.
Following below steps helped me to run the app in device.
Got to xcode preference
Click accounts and choose your apple id.
Click the View details
And Click download All.
This will download all the provisioning profile associated with given apple id.
And after that use any identifier that you have used before. You can easily get the old identifier from provisioning profile names.
Just use the bundle ID of any old app that you have already installed like this and change the bundle ID after 7 days. I think apple puts a limit for free developer accounts.
EDIT:
Its important about what #haquangvu mentioned in his answer that, your old app get replaced. So take care of it and thanks #haquangvu for your answer.
Use one of your old Bundle IDs.
It works.
But your old Application will be delete.
DO NOT MAKE ANOTHER ID thats not the solution!!!
To make it work thats what you need to do:
Window > Preferences - Account
Then choose your apple ID and your team, then click on View Detail... Button on the bottom right.
A new window will show up, click on Download all button on the bottom left and all of yours Provisioning Profile will show up.
After that just Left click on those ones you don't have to use anymore and click to move to trash.
after you delete enough profiles, you'll be able to build your project again!
I had this and the other answers here didn't fix the problem. I solved it by opening Window > Devices, finding my device, right-clicking it to "Show Provisioning Profiles", and then deleting a bunch of the profiles there.
Then it worked!
The workaround is to use an id that you previously created. As Xcode does not list the Bundle IDs via Apple ID Details any more, save this into your .bash_profile or ~/.zshrc and call it with list_xcode_provisioning_profile from a terminal
list_xcode_provisioning_profiles() {
while IFS= read -rd '' f; do
2> /dev/null /usr/libexec/PlistBuddy -c 'Print :Entitlements:application-identifier' /dev/stdin \
<<< $(security cms -D -i "$f")
done < <(find "$HOME/Library/MobileDevice/Provisioning Profiles" -name '*.mobileprovision' -print0)
}
To make this answer easier to find I just copied it from hyperknot here: Parsing mobileprovision files in bash?
I have a paid developer account and found this happening in Xcode 9 after creating a bunch of simple test/example apps. In the past, I would have simply selected a "wildcard" App ID. However, Xcode doesn't seem to have a way to do this anymore.
Researching based on the wildcard, I found Technical Q&A QA1713: When should I use a wildcard App ID?. Following these steps seems to have worked for me. (The signing errors are gone, but we'll see what happens in another 7 days or 10 apps, lol.)
Here are the steps, if you have a paid developer account:
Log into your developer account.
In the list on the left, click on Certificates, Profiles & IDs.
In the new list on the left, under Identifiers, click on App IDs.
Click the '+' symbol in the upper right of the page. (You're now at the 'Registering an App ID' page.)
In the box under App ID Description, enter something to describe your App ID. (Note that this description has to be purely alphanumeric; spaces seem to be allowed, but nothing else.)
Under App ID Suffix, select the radio button for Wildcard App ID.
In the box below that, enter the beginning of what you'd like to use as your app's bundle identifier, followed by a dot-asterisk. (For example, maybe your app bundle identifiers in Xcode are something like com.myname.appname. Then, in the box under Wildcard App ID, you'd enter com.myname.*.)
Under App Services, select any available items you think you might use in an app at some point in the near future. (Only a few of the items are available for selecting at this step.)
At the bottom of the page, click the Continue button.
At the resulting 'Confirm your App ID.' page, scan your selections to ensure they're okay; then, at the bottom of the page, click the Register button.
At the resulting 'Registration complete.' page, you can again review the registered options. Then, just scroll to the bottom, and click the Done button.
The new wildcard App ID will now appear in your list of App IDs.
Next, go into Xcode, and create your app, entering an Organization Identifier that matches the wildcard App ID you registered without the dot-asterisk. (For example, if you enter com.myname, Xcode completes what becomes the bundle identifier with a dot and the app name.)
When the project opens at the signing page, Xcode will "Automagically manage signing" correctly ;)
Note: If you have a free developer account, as of the date of this posting, you can't access the 'Certificates, Profiles & IDs' link in your account. ;(
Xcode>General>Identity
Copy Previous Bundle ID
Bundle Identifier : AppleDeveloperName-PreviousProjectName(or whatever)
Paste it in the new project's Bundle ID. It should be fine now.

What is the fastest/easiest way - step by step, from the beginning - to "code sign" my Qt app on OS X so that it can be distributed?

I am writing a cross-platform app in Qt (using Qt Creator). One of the target platforms is OS X.
The application is being packaged for installation on OS X by using the BitRock Installer system to create an .app file.
The application is intended for download and use by students and researchers in political science at various different colleges and universities. (A download either from the App Store, or from a product website, is fine.)
I do not need iCloud or any other features associated with the App Store. I just need to be able to distribute this application so that the warning (below) does not appear.
Currently the application is in an alpha-testing state - it is being tested by the product managers only. I would nonetheless prefer to offer the product managers an installation package for OS X that does not present them with the following warning:
The [installer application] can't be opened because it is from an
unidentified developer
(And, more importantly, when the application is released, I also don't want this warning to appear for end users.)
I understand that I need to prepare my application for distribution by using an Apple Developer account and properly signing the application.
I have created a developer account, and I am attempting to follow the steps in the link to sign my application and prepare it for distribution.
However, because the application is built in Qt, not Xcode, I do not know how to follow the steps through to completion, because some of the key steps assume that Xcode is being used.
I have searched for any questions that might describe how to prepare Qt applications on OS X for distribution, but come up empty.
(Further, I would also prefer to have a set of steps provided that is as simple as possible - preferably simpler than the steps provided in the above link - in any case.)
What is the simplest possible set of steps that will allow me to code sign my application, developed with Qt, on OS X, so that it can be distributed?
Prepare .app file
This is a step by step guide to create a signed package which can be uploaded to the Mac App Store, or distributed independently as a standalone application + installer:
Check app icon - it should have all sizes (16x16, 32x32, 64x64, 128x128, 256x256, 512x512, 1024x1024). (See https://stackoverflow.com/a/21028483/368896)
Add compile options for proper generation of debugging symbols:
QMAKE_CFLAGS += -gdwarf-2 QMAKE_CXXFLAGS += -gdwarf-2
(noting that QMAKE_CFLAGS may not be highlighted by Qt Creator as valid, but still may need to be included - see here)
Settings should be saved in a directory with same name as bundle identifier.
Check the application's Info.plist file. It should contain the correct bundle identifier and minimum MacOS X version of 10.6.6.
(Note: though Qt Creator automatically generates a default info.plist file that is placed inside the .app bundle, it is also possible to create your own file and have this automatically used instead. See this link for a sample info.plist file that works with Qt and the App Store, and note that QMAKE_INFO_PLIST does work to use a custom file (see comments in that link).)
(Also, see notes below about how to obtain a bundle identifier.)
(The minimum OS X version - which should be set to 10.6.6 or later - can be set with the following line in the .pro file: QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 - but if you use a custom info.plist file, this setting won't take effect, so you must include the proper setting in your custom info.plist anyways; see previous link for the entry that should be used in the file.)
You also need certificates to sign your application and installer: open “Keychain Access” (use Mac OS X search) -> double click on each certificate (look in the kind column for these) and enter password -> check added certificates in Keychain Access.
Register application in iTunesConnect
Log in to your developer account at http://itunesconnect.apple.com (which will reroute you to https://, but you may need to first enter http://)
(Note: If you do not already have one, you must first create a Mac Developer Account, $99/year, in order to proceed.)
Click on “Manage your apps” -> “Add new app”
If application has no Bundle ID - create it.
Creating a new Bundle ID is not intuitive.
To create a new Bundle ID:
-> Log in to the Developer Center website: This is a different site
(perhaps open it in a new tab): http://developer.apple.com.
-> Click Member Center near the very top right (next to the search bar)
-> Click on Manage your certificates, App IDs, devices, and provisioning profiles
(underneath Certificates, Identifiers & Profiles)
-> Click on App IDs in the left navigation bar (in the Identifiers section)
(This might already be selected.)
-> Click on + button
-> The screen you now see (Register Mac App ID / Registering an App ID)
is the screen you use to create a new bundle identifier
-> Enter the necessary information. Write anything for the
App ID Description (it can contain only a short line of text)
The Explicit App ID field is actually the new Bundle ID.
Type a reverse URL here, such as com.mydomain.myapp.
A website or server does not actually need to exist at this URL.
You just make one up here, but of course you can use one that
already exists if you wish.
-> Click Continue, then Submit if you're satisfied, then Done
Now be sure to go back to the previous section, and add the Bundle ID you have just created to the custom info.plist file.
Also save the Team ID in case you need it later - this is the string that precedes the Bundle > > ID (called the prefix) that you see when you look at the details of the Bundle ID you've just > > > created in the Developer Center.
Now, go back to the iTunesConnect website. (Perhaps in another tab - this is not the Developer Center website.)
In the App Information section, select language. Then, enter app name. Make up a random string of characters for the SKU field (I use something of the format 2436-7623-7782-8327). Finally, select the Bundle ID. Click Continue.
Select availability date (simply as far as possible, for now - currently, it's only possible to make it available for at most 2 years). Select price tier (can be any - customer can change later). Click Continue.
Enter detailed application information on the following screen, and click Save.
Click “View Details” in app page -> Click “Ready to upload binary” -> On summary page click on link “latest version of Application Loader” and download it -> Click “Continue”.
Creating and Uploading installer
Check application Info.plist - enter right bundle id, app name, category.
Build application in release mode.
Extract debug symbols. At the command line:
dsymutil MyApp.app/Contents/MacOS/MyApp -o MyApp.app.dSYM
Execute the helper program macdeployqt (included with Qt). At the command line:
/path/to/macdeployqt /path/to/myapp.app
(macdeployqt can be found in QTDIR/bin. See this link for a handful of official details.)
Running macdeployqt modifies your existing application by incorporating the necessary Qt frameworks internal to the .app bundle and changing various other internal settings in the application.
Codesign application:
Codesigning is a tricky step.
(1) Obtaining a DISTRIBUTION CERTIFICATE
You must first create a Distribution certificate, if you don't already have one. (Not a
Developer certificate.)
(The following steps are taken from this link, with a correction regarding the certificate
type)
-> Open Xcode (version 5 as of this writing)
-> Navigate to Xcode > Preferences
-> Click the Accounts tab
-> If you have not already done so, add the Apple ID that is registered in the Mac Developer
Program
-> Select the Apple ID that you want to use, and click View Details
-> In the window that opens, click Add (+) and then select Mac App Distribution.
(2) Code signing the application with the Distribution Certificate
To properly codesign, every .framework and .dylib inside the .app bundle must FIRST
be signed; and then the .app itself must be signed. See critical steps in bottom paragraph of
this grey block before you codesign the internal Qt frameworks - and be sure to do this first.
The command to sign the internal libraries/frameworks, and the command to sign the main .app,
is the same:
codesign -s "3rd Party Mac Developer Application: Daniel Nissenbaum (S6V5TT9QRL)" –-entitlements
MyEntitlements.plist MyApp.app
The --entitlements MyEntitlements.plist option is only necessary if you actually have
entitlements beyond the basic
defaults. I (Dan Nissenbaum) did not select additional privileges for my app when I created the
Bundle ID in Developer Center (such as ability to access iCloud, push notifications, etc.). So, I
left off the --entitlements option, and I have not looked into how to obtain a
MyEntitlements.plist file.
Note regarding the -s argument: See paragraph below for information about finding the correct
name to use (this is the Distribution Certificate "Common Name").
This codesign command is for the main .app. To codesign the internal (Qt)
libraries/frameworks,
which must be done first, use the proper path; i.e., in the command above, use
MyApp.app/Contents/Frameworks/QtCore.framework rather than MyApp.app - and note that
the path to the libraries/frameworks must be just to the root of the internal library/framework
bundle, not to inside the internal library/framework bundle.
Various other internal .dylibs or .frameworks may also need to be signed, in addition to the
Qt .frameworks - if you try to sign your main application but have not
signed all of the internal .dylibs/.frameworks, you will receive an error indicating another
internal
.dylib/.framework that needs signing. Just proceed through them all. In my case, there were
about
10 additional .dylibs that needed to be signed after I completed signing the Qt .frameworks.
Once you have the developer certificate, you need to find the name of the certificate for use with
the codesign process. Open "Keychain Access" (to find this, simply type "Keychain Access" into
the Search bar in the Finder, and locate the application from among the results returned). In the
main list that you see when Keychain Access runs, you will see your Developer certificate among
various other things. There will also be some other certificates - ignore those. It should be
obvious which certificate is the correct one. In my case (which is standard, I assume), the
certificate name is "3rd Party Mac Developer Application: Daniel Nissenbaum (S6V5TT9QRL)".
This is the official name of the certificate, to be
used as the -s argument to codesign, but to really confirm this, double-click on the
certificate and in the info window that appears, have a look at the "Common Name". The value of
Common Name is the official text to use as the -s argument of codesign.
Note regarding a complication with codesign'ing the internal Qt frameworks. As of today,
when macdeployqt is run, the Qt frameworks are not fully copied correctly into the .app bundle.
They are missing their Info.plist file. But these necessary Info.plist files DO exist inside
the Qt installation. You can simply use the Finder to copy them. (For example on my system, the
required Info.plist file for the QtWidgets.framework framework has this path (where "Qt"
corresponds to the root path of your Qt installation):
Qt/5.1.1/clang_64/lib/QtWidgets.framework/Contents/Info.plist. This is to be copied into
MyApp.app/Contents/Frameworks/QtWidgets.framework/Resources. Ditto for all of the other Qt
frameworks that were copied into the MyApp.app bundle by macdeployqt. See
https://stackoverflow.com/a/19639825/368896 for more details.exists and is enabled for code
Create installer (a different certificate is required; see comment):
productbuild –-component ./MyApp.app /Applications –-sign "3rd Party Mac Developer Installer: Daniel Nissenbaum (S6V5TT9QRL)" MyApp.pkg
Note that a different certificate is required to be used as the argument to the --sign parameter. The certificate has type "Mac Installer Certificate", rather than "Mac App Distribution" (the type of the certificate used with codesign, above). To create this certificate, follow the same steps above, but select Mac Installer Certificate as the type. Use its Common Name as the argument to the --sign parameter here.
The ./ preceeding the application name might be important. Also, use the same argument to the --sign parameter that you did when you ran codesign - the Common Name of your Developer certificate. See above.
Check the installer:
sudo installer -store -pkg MyApp.pkg -target /
If there are no errors, you now have a legitimate Mac application, packaged into a legitimate Mac installer, both of which can be distributed to anyone. You can distribute them by simply sending them the .pkg file (via website, Dropbox, etc.), or you can upload to the Mac App Store.
I have not confirmed these steps, which are for actually uploading the application to the Mac App Store: Open Application Loader and sign in with Apple Developer Account -> Select “Deliver Your App” -> Choose right AppID -> Click on “Choose…” button on “Application Information” page and select created pkg file -> Click “Send”.
Additional information
Information about entitlements
Information about Info.plist
Additional information about deploying app to Mac AppStore
First, see Sign Qt applications on Mac with Developer ID and Sign a Framework for OSX 10.9
Basically,
compile your application
run macdeployqt
check using otool -L ... the dependencies of all your frameworks, libraries and plugins
use install_name_tool -change ... to change any dependencies not properly deployed to inside the bundle
sign your frameworks and bundle (see the 2 links given above)
You will need to pay Apple for a developer ID to be able to sign your application otherwise your users will have to deal with Gatekeeper.
First of all, please, check the following link
As you wrote, you may distribute your application outside of the App Store. Such bundles or pkg installers should be signed with the Developer ID signing identity. This is the only signature that will pass checks by MacOS GateKeeper.
You must be a "Team Agent" to obtain this. If you are working alone this should be no problem for you. If you are not "Team Agent" you will need to create the certificate request and send it to your "Team Agent" who will generate the public key for you and send it back.
Once you will have a valid Developer ID signing identity (as people wrote in comments) you can just sign your app with similar command line command: codesign "Developer ID ...." myApplicationPath.app
P.S. Latest xCode provides a nice UI to obtain different types of signing identities. Just check the link at the top of answer.

Resources