projectfiles/Xcode/README.md
This README describes the way to create the wesnoth release packages for macOS.
The default Xcode dependency workflow in this directory remains macOS-oriented.
For the iOS simulator dependency bootstrap and audit workflow, use:
projectfiles/Xcode/ios/build_ios_deps.shprojectfiles/Xcode/ios/audit_ios_linkage.shgitscons and gettext (if you want to compile translations)The Battle for Wesnoth: Builds the actual game, depends on wesnothd. If you don't want to build wesnothd, get info on the Wesnoth target, go to the General tab, and remove wesnothd from its dependencies.
wesnothd: Builds the multiplayer server. The MP server is needed for hosting a local MP server, not for connecting to the official one.
unit_tests: Builds the unit tests. This is mainly useful when trying to fix a failing Travis build.
campaignd: Builds the addons server.
liblua: Builds the lua library for Wesnoth.
Release: Builds for maximum (runtime) speed and compatibility; it builds for 64-bit, with the latest SDK, but targets 10.11. You do not however need 10.11 SDK to build it. This is what's used for official releases.
Debug: Builds for maximum compiling speed, and uses the current OS as the SDK. If you just want to compile for testing things yourself, this is the way to go.
To compile translations you need gettext-tools and scons. You can obtain these tools using brew install gettext scons. You also have to force-link Homebrew's gettext tools using brew link --force gettext command. In the Terminal, cd /PATH/TO/PROJECT and run scons translations. This will compile all the translations into a translations directory.
When compiling Wesnoth for an official release, the following steps should be taken. Packaging is separated into subchapters, one per distribution channel:
.dmg, and release to SourceForge.wesnothd, archive, and upload via App Store Connect.The release channel is recorded inside the archive in Contents/Resources/data/dist (a plain text file). Valid values are Steam, SourceForge, itch, and macOS App Store. Any other value is treated as an unknown / default channel by the game, and by the Check_xcarchive validation script.
git clone -b BRANCH --depth 10 https://github.com/wesnoth/wesnoth /PATH/TO/PROJECT or use your favourite git program.cd /PATH/TO/PROJECT ; git checkout TAG or use your favourite git program.Finder to navigate into /PATH/TO/PROJECT/projectfiles/Xcode.Fix_Xcode_Dependencies script and wait until it finishes.The Battle for Wesnoth.xcodeproj file in Xcode.dist file using touch /PATH/TO/PROJECT/data/dist.dist file in path /PATH/TO/PROJECT/data/dist. For Steam it must contain Steam.Product > Archive from the menubar.Distribute App, select Developer ID and select Upload.Distribute App again, select Developer ID and select export location.dist file in path /PATH/TO/PROJECT/data/dist. For SourceForge it must contain SourceForge.Product > Archive from the menubar.Distribute App, select Developer ID and select Upload.Distribute App again, select Developer ID and select export location./PATH/TO/PROJECT/packaging/macOS/Wesnoth_dmg_packaging_template.dmghdiutil convert /PATH/TO/TEMPLATE.dmg -format UDRW -o /PATH/TO/NEW/RW_IMAGE.dmg and mount it.cp -R /PATH/TO/THE/EXPORTED/PACKAGE.app "/Volumes/The Battle for Wesnoth/The Battle for Wesnoth.app".hdiutil convert /PATH/TO/RW_IMAGE.dmg -format ULFO -o /PATH/TO/NEW/IMAGE.dmg command.Wesnoth_1.15.2.dmgcodesign -s "Developer ID Application: Wesnoth, Inc (N5CYW96P9T)" /PATH/TO/NEW/IMAGE.dmg. (You must have Wesnoth's signing certificate.).dmg properly using spctl -a -t open --context context:primary-signature -v /PATH/TO/NEW/IMAGE.dmg..dmg image. You must have app specific password for your AppleID prepared.xcrun altool --notarize-app -f /PATH/TO/NEW/IMAGE.dmg --primary-bundle-id org.wesnoth.Wesnoth -u YOUR_APPLE_ID_EMAIL -p YOUR_APPLE_ID_APP_SPECIFIC_PASSWORD --asc-provider N5CYW96P9T and wait. After successful execution it should give you RequestUUID.xcrun altool --notarization-info REQUEST_UUID -u YOUR_APPLE_ID_EMAIL -p YOUR_APPLE_ID_APP_SPECIFIC_PASSWORD command. Wait until it returns the Package Approved status message.shasum -a 256 /PATH/TO/NEW/IMAGE.dmg > Wesnoth_x.x.x.dmg.sha256 command.dist file in path /PATH/TO/PROJECT/data/dist. For itch.io it must contain itch.Product > Archive from the menubar.Distribute App, select Developer ID and select Upload (to notarize).Distribute App again, select Developer ID and select an export location..app to itch.io using butler.wesnothd by swapping its entitlements file. The easiest way is to double click on the Prepare_for_MAS_release script in /PATH/TO/PROJECT/projectfiles/Xcode — it flips the Code Signing Entitlements build setting from Resources/wesnothd-nosandbox.entitlements to Resources/wesnothd-mas.entitlements for all three wesnothd configurations. If the Xcode project is open, close it first (or at least close the wesnothd target editor) so Xcode picks up the change.The Battle for Wesnoth project in the left sidebar, select the wesnothd target, open the Build Settings tab (with All and Combined selected), find Code Signing Entitlements, and change it from Resources/wesnothd-nosandbox.entitlements to Resources/wesnothd-mas.entitlements. Do NOT use the Signing & Capabilities tab to toggle App Sandbox — it can leave the build in an inconsistent state.Prepare_for_nosandbox_release (or revert the build setting manually) after the MAS archive is uploaded, before building any non-MAS package.dist file in path /PATH/TO/PROJECT/data/dist. For Mac AppStore it must contain macOS App Store.Product > Archive from the menubar.Distribute App, select App Store Connect and proceed with all steps by clicking Next.Before distributing any archive, you can validate it against its intended distribution channel (reads the dist file inside the bundled .app, then checks wesnothd's code signing entitlements to confirm the sandbox state matches):
Check_xcarchive in /PATH/TO/PROJECT/projectfiles/Xcode and drag one or more .xcarchive bundles (or a folder containing them) from Finder onto the Terminal window../Check_xcarchive /path/to/archive.xcarchive (also accepts a directory of archives).The script reports PASS / FAIL / WARN per archive. A MAS archive must have wesnothd sandboxed; Steam, SourceForge, and itch.io archives must not. In every case wesnothd must not carry com.apple.application-identifier (that entitlement on a nested binary triggers App Store rejection ITMS-90288 / 90286 / 90885).