Building a Position Independent Executable
Q: I received a "Non-PIE Binary - The executable '<appname>.app' is not a Position Independent Executable. Please ensure that your build settings are configured to create PIE executables." warning after uploading my app to iTunes Connect. How do I build my app as Position Independent Executable (PIE)?
A: Position Independent Executable (PIE) applications can be loaded at a random memory address when run. This has security benefits for your application. iOS 4.3 or later, and OS X 10.7 or later, fully support PIE executables.
Steps for building your application as PIE
In Xcode, select your target in the "Targets" section, then click the "Build Settings" tab to view its settings.
For iOS apps, set
iOS Deployment Target
to iOS 4.3 or later. For Mac apps, setOS X Deployment Target
to OS X 10.7 or later.Verify that
Generate Position-Dependent Code
is set at its default value ofNO
.Verify that
Don't Create Position Independent Executables
is set at its default value ofNO
.
Verifying that your application was built as PIE
You can check whether your application is PIE by running otool -hv
on your executable in the Terminal. Your application is PIE if its header contains the PIE
flag. Listing 1 shows an example of how to do this for an iOS app.
Listing 1 Example of a PIE application
$ otool -hv /path/to/MyApp.app/MyApp |
MyApp: |
Mach header |
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags |
MH_MAGIC ARM V7 0x00 EXECUTE 23 2372 NOUNDEFS DYLDLINK TWOLEVEL PIE |
Document Revision History
Date | Notes |
---|---|
2014-02-20 | Clarified the notion of PIE for apps with dependencies. |
2013-05-23 | New document that addresses how to build a Position Independent Executable. |
Copyright © 2014 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2014-02-20