| 80 | |
| 81 | |
| 82 | == Xcode version checking == #xcode_version |
| 83 | |
| 84 | MacPorts [ticket:12794 does not check the version of Xcode] being used at runtime, but many ports will fail to build if the version of Xcode is too old. If you discover that your port requires a particular minimum version of Xcode, add this code to the port to print an error if the user's Xcode is too old: |
| 85 | |
| 86 | {{{ |
| 87 | pre-extract { |
| 88 | if {"darwin" == ${os.platform} && 9 == ${os.major}} { |
| 89 | set minimum_xcodeversion 3.1 |
| 90 | set current_xcodeversion [exec defaults read /Developer/Applications/Xcode.app/Contents/Info CFBundleShortVersionString] |
| 91 | if {[rpm-vercomp ${current_xcodeversion} ${minimum_xcodeversion}] < 0} { |
| 92 | ui_error "On Mac OS X ${macosx_version}, ${name} ${version} requires Xcode ${minimum_xcodeversion} or later but you have Xcode ${current_xcodeversion}." |
| 93 | return -code error "incompatible Xcode version" |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | }}} |
| 98 | |
| 99 | This example is from [browser:trunk/dports/multimedia/x264 x264]. |
| 100 | Note that the check [http://lists.macosforge.org/pipermail/macports-dev/2009-April/008112.html is done at pre-extract time]. |
| 101 | |
| 102 | You can change the "9" in the os.major check to "8" if you're checking Tiger (Xcode 2.x) or "7" for Panther (Xcode 1.x) and update the minimum_xcodeversion accordingly. |
| 103 | If you don't know what minimum version of Xcode would work, it's ok to just put whatever version you found that the port worked with. |
| 104 | For example, libpixman is known to work with Xcode 1.5 but fail with 1.1, so [changeset:45892 libpixman now requires Xcode 1.5] on Panther, even though compatibility with Xcode 1.2 was not tested. |
| 105 | It is better to make a user upgrade to a newer Xcode than for a port maintainer to spend time testing old versions. |
| 106 | |
| 107 | |