IOS app publishing details

Source: Internet
Author: User
Tags key string asymmetric encryption

IOS app publishing details
Introduction to iOS app Publishing

The biggest news in the past few days isParis terrorist attackNow, the blogger is so devout every year to make a "hope for peace in the world". He cannot think of achieving it every year. It is so hard to maintain peace in the world that the blogger is really powerless, in fact, what we can do is not to throw the red light, not to rob the little sister's cone, pull the shit, remember to wash the water, do not escape the ticket, do not urinate in the bathhouse, do not dig into the corner ...... It is actually to maintain world peace.

However, hacker organizationsAnonymousDeclared war on ISIS!

Figure 0

Mighty!

Back to the topic of this article, I will list some details that I think are easy to ignore during the release of the iOS app.

Once again, the blogger's blog has moved, with a new address, better layout and better reading experience !!

Bundle identifier

XcodeTarget -> GeneralInbundle identifier;

info.plistInBundle identifier;

Certificate center'sIdentifiersMediumApp IDsTheExplicit App ID;

AndiTunes ConnectApp InformationSet IDMust be consistent !!

There are many settings in info. plist or Xcode.$(XXX)This is something like a script, so add an environment variable in Xcode.

Certificates Certificate

Apple's certificate system has always been an endless nightmare for beginners of iOS, including developing certificates, publishing certificates, pushing certificates, ad hoc, internal testing and distribution, and debugging on real machines ...... I think that when I first started to get started with Apple's certificate system, my heart would be broken down, and I would not be able to get overwhelmed by the grass and horses in my heart .......

In fact, Apple's certificate is actually not that mysterious. Many friends don't understand it or don't know how to get it after a while. The essence is that it is caused by asymmetric encryption (public key encryption) does not understand ~~ Resulting ~~, Therefore, in order to fully control the apple certificate, these basic knowledge is your hurdle and must be crossed.

There are various explanations on the Internet about what the role of each certificate in the certificate center is, how to create and use it, but this can only teach people to fish, so the blogger won't introduce what each certificate is doing, because you saw one morePass Type ID CertificateLast yearWatchKit Services CertificateThis year, anotherApple Pay Certificate...... These certificates are not enough ~, Therefore, understanding the unified rules of these certificates is king! The so-called

Changing

Many documents divide certificates into two types: development Certificate and distribution Certificate ). However, bloggers think that such classification is not very scientific, and the understanding of bloggers is as follows:

Figure 1

    • Root CertificateIt corresponds to developers or enterprises, as long as it isRoot CertificateThe signed App can be understood as developed by the developer corresponding to this certificate. So oneRoot CertificateYou can sign multiple apps.

    • Other certificatesIt corresponds to a specific App. The push Certificate of one App cannot be used by another App.Other certificatesOnly one App can be signed. More specifically, this App needs to use an Apple service to generate thisOther certificates.

Therefore, the certificate that Apple adds every year belongsOther certificatesThese other certificates are not mandatory, but are required only when an apple service is used. WhileRoot CertificateIt is required. The signed APP belongs to the certificate owner.

Figure 2

In the figure, my account has two different functions by default.Root CertificateThere are two apps, App1 and APP2 respectively, and their corresponding push certificates for two purposes (belongOther certificates).

If I need to debug App1 push on a real machine, I only need to downloadDevelop root certificateAndApp1 development push CertificateDouble-click the import key string and create a profile to debug the machine;

If I want to release APP2 now, I only need to downloadPublish root certificateAndPublishing and pushing Certificate of APP2And then create the corresponding profile to package and upload the App Strore. (Because of the special nature of the release, the released computer must create thisPublish root certificate).

Profile (description file) is further described below.

I am confused by TM. It is a little complicated and complicated, and the iOS development threshold is really high, but I like it.

App IDs

You can add multiple APNs push certificates to the edit of the corresponding App (other certificates are similar)

Figure 3

Declare here,Other certificatesWhen other certificates are generatedcertSigningRequestFile generationRoot CertificateOfcertSigningRequestIs generated.Other certificatesNot necessarily requiredRoot CertificateSo there are countless people debugging and pushing here, which is detailed in the following sections.

Provisioning Profiles description file

Figure 4

I think when the interface is popped up, the egg is sad. Then furiousFix issueThen, your team was responsible for managing the certificate and suddenly found that the certificate center had a lot of messy certificates and descriptions, and then he burst into a sentence: what the huck! DeletedXcode *The certificate and description file, and then click it again.Fix issueAnd then you can't debug it, and then hit it again.Fix issueIn the end, the entire team only passesFix issueDebugging on a real machine .......

So be cautiousFix issueIf you click this option, it is smart (~~ Stupid crying ~~) Xcode manages the description file by itself, andXcode *Certificate and description file ......

In fact, as long as you firmly believe that the certificate, device ID, AppID, and description file are all correct, there will be no problems!

Describe how Files Work

Figure 5

    • In fact, the working principle of the description file is to let Xcode check whether the BundleID In the description file corresponds to the BundleID of the APP during APP packaging or debugging on the real machine.
    • ThenkeyChainFind out if there is a corresponding certificate (So download the certificate and import itkeyChain)
    • If a certificate exists, the type of the certificate is checked. If a certificate is developed, the system checks whether the debugged device is added to the list of trusted device IDs in the description file, debugging fails if the device is not in the description file list. If the certificate type is certificate publication, the device ID list is not checked.

Additionally, if the company adds a testing machine andDevicesThe ID of the new test machine is added, so the description file must be updated accordingly and then downloaded again, after downloading the file, you can delete the old description file (it seems that the description file is not updated in the way directly covered by the blogger). You can experiment on your own and describe the path of the file./Users/XXX/Library/MobileDevice/Provisioning\ Profiles

XXXYour user name.

Do not overwrite! Remember to delete it first to avoid many problems.

Push those things

If the PUSH Service of hundreds of millions of users is not customized by penguins but pushed by Apple APNs, Apple's push is really awesome, but sometimes it is tested and pushed, APNs is always dying. After pushing for half a day, it once pushed more than 1000 records in the APNs sandbox environment, and then the queue was pushed for half a month ~~. Therefore, the buckle must be a custom push. If you have money, you will hate it.

However, the development of Apple push is relatively simple. If there is no need for advanced push, you do not need to write code. You only need to configure the certificate.

In common background servers, you can generally export the private key of the push certificate and push certificate to p12 to the background staff.

PHP is a little naughty and needs to be converted to pem

Generate the Pem certificate required by PHP

Preparation:

Step 3. the private key of the root certificate is a pitfall! Because the creation of the push certificate of an App can be different from that of the Computer Created by the root certificate, that is,certSigningRequestDifferent, so the private key is also different. When you generate Pem here, be sure to use the private key of the push certificate!

Procedure:

Then, give the PHPPush. pem to the background friends and you will be able to get off work.

Of course, testing and pushing are also quite troublesome. We need to simulate the real push environment. We usually need to provide help in the background. However, some background colleagues who strongly believe in despising the chain, despise iOS, my heart has long called you "before death" for many years. There are so many things ......

So for debugging push, you can push yourself! Don't bother others.

Just copy this code

<? Php // devicetoken $ deviceToken = 'your devicetoken'; // the private key and password $ passphrase = '000000' entered when the pem is generated; // customize the push content, for more information, see the Apple documentation $ message = array ('body' => 'you have received a new Order '); $ body ['aps '] = array ('alert' => $ message, 'sound' => 'default', 'badge' => 100 ,); $ body ['type'] = 3; $ body ['msg _ type'] = 4; $ body ['title'] = 'new order notification '; $ body ['msg '] = 'you receive a new message'; $ ctx = stream_context_create (); stream_context_set_option ($ ctx, 'ssl ', 'local _ cert ', 'Push. pem'); // remember to push the generated push. put pem in the same directory as this PHP file stream_context_set_option ($ ctx, 'ssl ', 'passphrase', $ passphrase); $ fp = stream_socket_client (// pay special attention here, one is the sandbox environment for development and pushing, and the other is the formal environment for publishing and pushing. deviceToken is not commonly used in 'ssl: // gateway.sandbox.push.apple.com: 80', $ err, // 'ssl: // gateway.push.apple.com: 2195 ', $ err, $ errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ ctx); if (! $ Fp) exit ("Failed to connect: $ err $ errstr ". PHP_EOL); echo 'connectedto apns '. PHP_EOL; $ payload = json_encode ($ body); $ msg = chr (0 ). pack ('n', 32 ). pack ('H * ', $ deviceToken ). pack ('n', strlen ($ payload )). $ payload; $ result = fwrite ($ fp, $ msg, strlen ($ msg); if (! $ Result) echo 'message not delivered'. PHP_EOL; elseecho 'message successfully delivered'. PHP_EOL; fclose ($ fp);?>

Copy the above Code and save it as push. php.

Then, generate push. Pem according to the above "generate pem certificate required by PHP" step.

Put the two files in the same directory

Run the following command:

DavidDay$ php push.php 

Result:

Connected to APNSMessage successfully delivered

Is the push successful? Haha

Packaging, distribution and internal testing

There are many packaging styles. Everyone has their own preferences. Most of the rules are based on Xcode's one-stop service:

    • Select the corresponding description file and Certificate

    • Select an ARM architecture model (the simulator is based on Intel, and the real machine is based on ARM, and cannot be used universally)

    • product -> archive

    • Then you can choose to export the ipa for distribution testing on a third-party platform or upload the App Stroe for review.

This method is relatively safe becausearchiveOnly the binary code of the real machine is compiled, so you don't have to worry about the exported ipa.

Another way is to usexcodebuildTool, pure Shell compilation, it is not easy to handle errors, but it is full of code. If you want to know more about this kind of posture, please refer to the official documentation, or refer to this student's sharing.

Of course, as a loyal supporter of the drag-and-drop school, the main pack of ipa is as follows:

Figure 6

Build at any time to convert ipa.

Third-party platforms are generally used for internal distribution tests. fir and dandelion are good ~

Archive has passed and the certificate is correct. Check whether the private API is called by the project. If reveal is used before, forget to remove it when submitting the application, the upload tool of Xcode is used and no error is reported. The build version in iTunesConnect also appears, but the status is "being processed". Generally, this status lasts for 10 minutes ~ It will pass in two hours, and the blogger is confident that he will shut down from work. He can't think of the next day's build or "processing", and then wondered if there was a problem with iTunes and he was angry with passing N Packets, still "processing", and then prepare to send an email, open the mailbox, Nima!

Figure 7

I used to call a private interface and forgot to remove reveal ~, In retrospect, there are three major pitfalls,

The certificate of the packaged project must be correctly selected (Xcode7 and below select the project to compile target as the Iphone Device. Do not connect to the mobile phone; otherwise, the real machine does not need to be pulled out in Xcode7 because there is one morebuild only device)

The error ITMS-90530 "Invalid MinimumOSVersion is selected when the target is compiled. apps that only support 64-bit devices must specify a deplyment target of 8.0 or later "IMTS-90208" Invalid Bundle. the bundle xxx. app does not support the minimum OS version specified in the Info. plist "IMTS-90502" Invalid Bundle. apps that only contain the arm64 slice must also have 'arm64' in the list of UIRequiredDeviceCapabilities in Info. plist ")
Summary

I suddenly remembered what my brother said.

Sometimes some women are like dining-room meals. Although difficult to eat, they will not be late!

Cherish the people around you.

What is this summary? It's a bit sad. Well, every practitioner should be able to operate and handle iOS apps in an accident.

No money to get married.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.