From 347dc51b50809d896e022b8db56732f68f46f576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Sa=CC=81nchez=20Pardo?= Date: Fri, 27 Nov 2026 10:37:18 +0100 Subject: [PATCH 01/17] Tier 1 modernization: GitHub URLs, SPM-only, pinned CommonFastfile version, updated defaults and README Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 17 ++++ README.md | 170 ++++++++++++++++++---------------- create_setup_build_scripts.sh | 134 +++++++++++++-------------- fastlane/CommonFastfile | 3 +- samples/setup_match.sh | 19 ++-- xcinstall/install.sh | 12 +-- 6 files changed, 186 insertions(+), 169 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8353cc8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,17 @@ +# Changelog + +## 2.0.0 (unreleased) + +Breaking: generated projects are now SPM-only, and the repo moved to GitHub. + +- All URLs moved from the retired gitlab.inqbarna.com to https://github.com/InQBarna/xcode-scripts (HTTPS). +- Generated Fastfile imports `CommonFastfile` with `version: '~> 2.0'`. Releases are git tags. +- Removed CocoaPods: no `pod init`/`pod install`, no Podfile/workspace lookup; build uses `-project`. `slather` kept for coverage. +- Ruby 3.3.7, Homebrew prefix detected (Apple Silicon), bash shebangs, `exit 1` instead of `exit -1`. +- `build.sh`: simulator runtime and device default to the newest installed ones (override with `RUNTIME`, `DEVICE`). +- `CommonFastfile`: removed `compileBitcode`, `fastlane_version` raised to 2.220.0. +- `setup_match.sh`: fixed inverted check that tried to re-import the common Fastfile when already present. + +## 1.x + +See git history (`renew_certs` lane added Nov 2026). diff --git a/README.md b/README.md index 0f890e9..e66d912 100644 --- a/README.md +++ b/README.md @@ -1,90 +1,100 @@ -# Goals +# xcode-scripts -We want to start a fresh project ready for CICD, which means +Common tooling to start a **new iOS project ready for CI/CD** (Swift Package Manager only). +It generates the scripts and fastlane setup so every project builds, tests and ships the same way. - - Easily build te project in any (CICD) machine (with some minimum requirements). And guarantee 0 warnings! - - Easily run the tests and guarante they pass. And report coverage! - - Easily send a test version to stakeholders - - Easily send a vertion to AppStoreConnect for a new release +## What you get -## How to set up a new project +- `scripts/setup.sh`: installs what a machine needs (rbenv, Ruby, bundler, gems). Idempotent. +- `scripts/build.sh`: builds the project with **0 warnings allowed**; with `INTENT=test` also runs unit/UI tests and reports coverage. +- `fastlane/Fastfile` importing the shared lanes from this repo (`fastlane/CommonFastfile`), pinned to a major version. +- Build number build phase (`YYYYMMddHHmm`), match setup, `.gitignore`. -1. Grab the requirements: - - Have the repository created on github/your platform - - App name - - Bundle identifier created on dev portal - - Apple team id (from dev portal) - - Match git repo url - - Firebase app id (from firebase, looks like: 1:XXXX:ios:XXXX) - - Auth p8 file (from dev portal) - - Key id - - Issuer id - - Auth p8 file (from dev portal) - - App created on appstoreconnect +### Shared lanes (`fastlane/CommonFastfile`) + +| Lane | What it does | +|---|---| +| `update_devices_and_profiles` | Registers `fastlane/devices.txt` on the dev portal and regenerates development/adhoc/appstore profiles with match | +| `install_profiles` | Installs existing profiles read-only (no dev portal access needed) | +| `renew_certs` | Renews expired certificates and regenerates profiles. `dry_run:true` only lists what would be deleted | -2. Seriously... grab the requirements above or it will be harder to setup this later +Helper methods used from your project's lanes: `iq_beta` (TestFlight) and `iq_firebase_v2` (Firebase App Distribution). +Both build, upload, upload dSYMs to Crashlytics, bump the version, and push a git tag. -3. Clone your project repository +## Versioning -4. Create the xcode project on the root of the repository. - - Create an iOS project - - Choose an existing bunddle id in dev portal - - Close it before moving to step 3. +Generated Fastfiles import this repo with `version: '~> 2.0'`, so projects only receive compatible changes. +Releases are git tags (`v2.x.y`); see [CHANGELOG.md](CHANGELOG.md). To pick up a new major version, bump the version in your Fastfile. -5. Run the scripts setup script by executing: +## Set up a new project + +1. Grab the requirements (seriously, grab them first): + - Repository created on GitHub + - App name + - Bundle identifier created on the dev portal + - Apple team id + - Match git repo url + - Firebase app id (looks like `1:XXXX:ios:XXXX`), if using Firebase distribution + - App Store Connect API key: key id, issuer id and the `.p8` file + - App created on App Store Connect + +2. Clone your project repository and create the Xcode project at its root (iOS app, existing bundle id). Close Xcode. + +3. From the project root, run the generator (it asks for some input, so use process substitution, not `curl | bash`): ``` -../xcode-scripts/create_setup_build_scripts.sh +bash <(curl -fsSL https://raw.githubusercontent.com/InQBarna/xcode-scripts/master/create_setup_build_scripts.sh) ``` - - Setup script should now be ready to be used, you can test it by executing: `./scripts/setup.sh` - - Build script is created at: `./scripts/build.sh`. This is not ready to be used yet. - - A build phase should now be added to the project to set the build number correctly with format: YYYYMMddHHmm. - - If no fastlane folder is found, Fastfile and Appfile will have been generated at fastlane/FastFile fastlane/Appfile, please check they're created correctly - - MANUALLY: firebase id should be manually added to fastlane/Fastfile - - MANUALLY: the p8 file (key id and issuer id) should be manually downloaded and configured at fastlane/Fastfile - - MANUALLY: we recommend moving the scheme files to the workspace, and mark them as "shared", and deleting the file at \*.xcodeproj/project.xcworkspace - - MANUALLY: in the scheme -> test: please mark "gather coverage" for 'all targets' - -At this point you should be able to run `./scripts/build.sh` correctly and it will build the project. It can also run the tests when setting the INTENT env variable like this: `export INTENT="test"` - -6. Appstore - - (OPTIONAL) MANUALLY write at least one device to `fastlane/devices.txt`, either MANUALLY or ... - - If you have correct credentials for it (doesn't work with keys, plain username/password), you can download the devices registered by running: `bundle exec ruby ../xcode-scripts/samples/read_devices_from_developer_portal.rb"` - - Create the provisioning profiles using: `bundle exec fastlane update_devices_and_profiles` - - (OPTIONAL) MANUALLY unset "Automatically manage signing" - - (OPTIONAL) MANUALLY select the newly created prov profiles for every config - -If you correctly commit all your work, now `bundle exec fastlane beta` should work ! (unless your project doesn't even compile :D ) - -7. (Optional) Firebase - - `pod 'Firebase/Crashlytics'` - - Setup the project on firebase, following the steps from console.firebase.com: Pods, addition of GoogleServices to project, appdelegate setup... - - Right now adding firebase with SPM does not work correctly when uploading the debug symbols to crashlytics, please avoid SPM for firebase until solved - - Enable beta distribution on firebase website - - Setup beta distribution fastlane plugin on project running: `fastlane add_plugin firebase_app_distribution` - - Check the correct firebaseid on Fastfile (if not done in step 5) - - If you want to run the firebase distribution script locally, get sure you're logged in to firebase using `firebase login` - -If you correctly commit all your work, now `bundle exec fastlane firebase` should work ! (unless your project doesn't even compile :D ) - -8. (Optional) Configure desired pods - - Add Swiftlint to pods - - `pod 'SwiftLint'` - - `pod 'SwiftFormat/CLI'` - - And run `./scripts/setup.sh` when done - -9. (Optional) Other usual project setup - - Add adhoc config to the project copying the Release config: `bundle exec ruby ../xcode-scripts/samples/add_adhoc_config.rb` - - MANUALLY unset "Automatically manage signing" - - MANUALLY select the correct prov profiles for adhoc config - - MANUALLY change the configuration in Fastfile's iq_firebase_v2 to adhoc - - Add swiftlint build phase `bundle exec ruby ../xcode-scripts/samples/add_swiftlint_build_phase.rb` - - Or add SwiftFormat build phase: `bundle exec ruby ../xcode-scripts/samples/add_swiftformat_build_phase.rb` - -TODO for setup_gem.sh: - - - Change name beta to "testflight" - - Grab firebase id from env variable - - Check current xcode version and target - - Check for firebase pods - - Check firebase plugin on fastlane - - Check coverage is added to target + or, with this repo cloned next to your project: `../xcode-scripts/create_setup_build_scripts.sh`. + Use `XCODE_SCRIPTS_REF=` to test another version of the helper scripts. + +4. Finish the manual bits: + - Put the Firebase id in `fastlane/Fastfile` + - Download the `.p8` file to `fastlane/` and set key id and issuer id in `fastlane/Fastfile` + - Make sure the scheme is **shared** (Product > Scheme > Manage Schemes) and committed + - Scheme > Test: enable "Gather coverage" for **all targets** + +5. Verify: `./scripts/setup.sh` and then `./scripts/build.sh` (`INTENT=test ./scripts/build.sh` to run tests). + + Simulator defaults to the newest installed iOS runtime and iPhone; override with `RUNTIME=18.2 DEVICE="iPhone 16"`. + Xcode other than `/Applications/Xcode.app`: `XCODE_EXTRA_PATH=-16.2` (uses `/Applications/Xcode-16.2.app`). + +## App Store / TestFlight + +- (Optional) Write devices to `fastlane/devices.txt`, or download them with + `bundle exec ruby ../xcode-scripts/samples/read_devices_from_developer_portal.rb` (needs username/password credentials, not API keys). +- Create the profiles: `bundle exec fastlane update_devices_and_profiles` +- (Optional) Unset "Automatically manage signing" and select the new profiles for each configuration. +- Ship: `bundle exec fastlane beta` + +## Firebase App Distribution (optional) + +- Add Firebase with SPM following console.firebase.com (add `GoogleService-Info.plist`, etc.). + If Crashlytics symbol upload fails with SPM, set `UPLOAD_SYMBOLS_PATH` (see the commented example in `scripts/build.sh`). +- Enable beta distribution on the Firebase website. +- Add the plugin: `bundle exec fastlane add_plugin firebase_app_distribution` +- Locally, be logged in with `firebase login`. +- Ship: `bundle exec fastlane firebase` + +## Other usual setup (`samples/`) + +| Script | Purpose | +|---|---| +| `add_adhoc_config.rb` | Adds an AdHoc config copying Release (then select profiles and point `iq_firebase_v2` to `adhoc`) | +| `add_appstore_config.rb` | Adds an AppStore config | +| `add_swiftlint_build_phase.rb` / `add_swiftformat_build_phase.rb` | Adds the lint/format build phase | +| `add_bundleversion_build_phase.rb` | Build number build phase (done by the generator) | +| `add_settings_bundle.rb`, `add_fluent.rb` | Settings bundle / Fluent localization | +| `read_devices_from_developer_portal.rb` | Downloads registered devices into `fastlane/devices.txt` | + +Run them with `bundle exec ruby ../xcode-scripts/samples/