1Build ghostwriter on Mac without installing XCode 2================================================= 3 4 5### 1. Acknowledgements & License 6 7This guide is derived from [Qt without Xcode how-to][gist] by Peter Jonas ([shoogle]) / [CC BY 4.0][CC-BY] 8 9[gist]: https://gist.github.com/shoogle/750a330c851bd1a924dfe1346b0b4a08 "GitHub gist" 10[shoogle]: https://github.com/shoogle "shoogle's GitHub user profile" 11 12[![Creative Commons License][CC-BY-image]][CC-BY] 13 14This work is licensed under a [Creative Commons Attribution 4.0 International License][CC-BY]. 15 16[CC-BY]: http://creativecommons.org/licenses/by/4.0/ "View license text on the Creative Commons website" 17[CC-BY-image]: https://i.creativecommons.org/l/by/4.0/88x31.png "CC BY" 18 19 20### 2. Introduction. Why is this needed. 21 22Older Qt versions (<5.9.1) try to use `xcodebuild` to find out where the utilities are installed. 23This fails with the following error message unless Xcode is installed: 24 25> Project ERROR: Could not resolve SDK Path for 'macosx' 26> Error while parsing file `<filename.pro>`. Giving up. 27 28You need to tell QMake to use `xcrun` instead. 29 30 31### 3. Configure Qt 5.5 to use `xcrun` instead of `xcodebuild` 32 33Open a Terminal and change directory to where brew installed target mkspecs files. 34 35 ```bash 36 cd /usr/local/Cellar/qt@5.5/5.5.1_1/mkspecs/features/mac 37 38 ``` 39 40Now copy and paste these new commands **into the same Terminal window** 41to create backup copies of some files: 42 43 ```bash 44 function backup_files() { 45 for file in "$@"; do 46 [[ -f "${file}.backup" ]] || cp "${file}" "${file}.backup" 47 done 48 } 49 backup_files sdk.prf default_pre.prf default_post.prf 50 ``` 51Press the Return key after the final command. 52 53If that all went OK then run these commands to update the files: 54 55 ```bash 56 url_base='https://raw.githubusercontent.com/qt/qtbase' 57 commit='fa7626713b3a943609453459190e16c49d61dfd3' 58 dir='mkspecs/features/mac' 59 curl -O "${url_base}/${commit}/${dir}/sdk.prf" 60 curl -O "${url_base}/${commit}/${dir}/default_pre.prf" 61 old_line='cache(QMAKE_XCODE_VERSION, stash)' 62 new_line='!isEmpty(QMAKE_XCODE_VERSION): cache(QMAKE_XCODE_VERSION, stash)' 63 sed "s|^${old_line}\$|${new_line}|" <default_post.prf.backup >default_post.prf 64 ``` 65 66#### All done, please go back to the [main README](../README.md) and continue following the building steps for MacOS. 67