Use macro definitions in IOS static library to differentiate iPhone simulators from real machines

Source: Internet
Author: User
Problem description

In general projects, macro definitions can be used to determine whether the simulator is a real machine, which is undoubtedly effective.

# If target_iphone_simulator # define simulator 1 # Elif target_ OS _iphone # define simulator 0 # endif

However, macros work during pre-compilation. Can macro definitions be used in static libraries to distinguish between simulators and real machines?

Analysis ideas

Macro definition does work during pre-compilation, but the static library is compiled. file a is usually divided into two types: simulator and real machine. It is merged into fat by using lipo in a timely manner. file A, which is used to run the call. file a is not the same.

Verification and conclusion

Through test and verification, the aboveCodeIt is indeed capable of distinguishing between the simulator and the real machine, that is, the macro definition can be used in the static library to distinguish between the iPhone simulator and the real machine

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.