IOS development Note 18: detailed compilation, development, debugging, and packaging, ios18

Source: Internet
Author: User

IOS development Note 18: detailed compilation, development, debugging, and packaging, ios18
1. Reference a third-party library as a chain library

In some special scenarios, you may need to use a third-party library using the blockchain library. The general settings are as follows:

① Set in Other Linker Flags in the format of-l + Library name

② Set the library path address in Libray Search Paths. Note that the relative path is used.

③ Set the path of the relevant Header file in Header Search Paths

2. Check static library support architecture and static library Packaging

When an error similar to Undefined symbols for architecture occurs in the static library provided by other departments, it is likely that the related settings are not correctly set during the package of the other party, in this case, you can use "lipo-info static library path" in the command line to confirm the supported architecture information.

When a package is exported to a third party in the form of a static library, in addition to the automatic compilation and packaging of CI, such as jenkins, when you need to manually and manually exit the package temporarily, perform the following two steps:

① Adjust the compilation mode. For example, set the target to the simulator and real machine, and set command + B to compile the two libraries.

② Execute the relevant commands in the command line to "static library path of lipo-create real machine version xxxx Simulator version after static library path xxxx-output merge"

3. Static library joint debugging

When a static library is provided for projects embedded in other business departments and some problems need to be debugged in their projects, if the log output method alone is not real-time enough, or you need to repeat the output log and compile the package again. In this case, you can put the static library project and project in the same workSpace, update the package results of the latest static library editing to the main project. At the same time, you can open a breakpoint at the target location of the static library and run the main project to access the relevant breakpoint location normally, observe related variable information.

4. Use the checkpoint to locate and debug other third-party Libraries

When a third-party library encounters a problem and you need to troubleshoot the problems related to the third-party library, but it is not convenient to conduct joint debugging, you can use a breakpoint-compliant method to locate the relevant methods for observation and debugging, if you know that the corresponding class name will be more accurate,

5. charles captures https requests

Whether for security reasons or apple once required https for all, many servers have already migrated services to https. When using charles to capture related requests, you also need to set the corresponding certificate, otherwise, you cannot view the relevant information.

The procedure is as follows:

① Install the corresponding root certificate on the pc first

② Install the corresponding root certificate on the real machine, pay attention to the need to connect to the pc proxy and then install according to the address prompted, if you use this address to install problems, you can try http://charlesproxy.com/getssl

6. Identify the cause of symbolic crash logs

Although we usually use third-party tools such as umeng and buugly to collect crash logs, sometimes the crash occurs and the third-party platform does not collect the relevant data. If there is a device crash log at this time, you can only manually resolve the cause using the symbolicatecrash that comes with Xcode.

The crash logs exported by the real machine and the packaged files must be put in the same directory for symbolic work.

Start the command line terminal to start symbolic:

① Find symbolicatecrash and copy it to the directory. Note that the iPhone symbolicatecrash is used.

Find/Applications/Xcode. app-name symbolicatecrash-type f

Cp symbolicatecrash path corresponds to the storage directory path

② Switch to the specified directory for symbolic

Corresponding command:./symbolicatecrash crash file path: dSYM file path> symbolic crash Log Path

If you encounter the not define problem in the middle, just execute the command setting separately. export using _dir = "/Applications/XCode. app/Contents/Developer"

7. Note that containsString is supported only after iOS8. You need to expand it on iOS7.

The method "containsString" used to determine the string is supported only in iOS8 and later versions. If it is less than 8, such as iOS7, this method cannot be found, leading to a crash.

The solution is to add a category extension.

8. Avoid repeated kvo listening removal and crash

In some special scenarios, repeated removal listening may crash. You can try catch to avoid the crash of repeated removal or fundamentally avoid repeated addition and removal operations, refer to iOS development-black technology to prevent multiple problems arising when you add or delete KVO

9. Use UIPasteboard in iOS10 and later versions to share data between apps

Previously, UIPasteboard was used to temporarily store some data to facilitate data sharing between apps. To avoid affecting the system's copy and paste information, pasteboardWithName: A clipboard was created separately. However, after a small version of iOS10, it is true that, this method is discarded and no longer supported. It is shown that the information set by app A in UIPasteboard is blank when it is read in app B.

Solution: use the system's default UIPasteboard, that is, [UIPasteboard generalPasteboard], or the officially recommended App Groups method for data sharing between apps. However, this method is later supported by ios8, you also need to manually enable this function. If the shared object app is not easy to set, it will be relatively troublesome.

10. Print method Caller information

During debugging, in addition to step-by-step tracing with breakpoints, you can use methods to quickly obtain Caller information of a method, for more information, see Print the name of the calling function to the debug log.

11. Status Bar adaptation-the height of the status bar changes due to hotspot usage, multimedia usage, and location.

The changes in the status bar height will affect the frame of the view and adapt accordingly. Of course, the new iPhone X exception will not cause this adaptation problem. There are two scenarios for the change in the status bar height:

① When you enter the page, the height of the status bar has increased. At this time, you need to determine its height and adapt it accordingly. At this time, the height of the status bar should be 40

② When browsing the current page, the height of the status bar increases. Therefore, you need to add a notification to listen to the height change of the status bar during page initialization. When the status bar changes, adapt accordingly.

12. Some details about string processing

① For scenarios such as reporting server information, if necessary or protecting special characters, encoding must be performed first to avoid garbled characters

② When using URLWithString to convert the string to NSURL, pay attention to the first UTF-8 encoding for character transmission, otherwise the string contains spaces and other conditions directly URLWithString conversion results returned nil

13. A relatively cost-effective Gaussian blur method without using third-party Libraries

VImage is used to implement fuzzy effects and execution time. See vImage Gaussian Blur (Blur)

14. Use character counting rules similar to Weibo

The punctuation, symbols, and numbers must be counted as 0.5 characters. In fact, these ascii characters are only recorded as 0.5 characters.

15. Use of some macros

① Remove warning. For example, tell the compiler to disable corresponding warnings in some fragments.

② Differentiate between a real machine and a simulator. For example, some functions or sdks do not support simulators, such as camera-related ones. To enable the simulator to compile and run, you may need to differentiate the simulator and skip the compilation of the relevant parts.

 

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.