Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.
Add Make rules, CONTRIBUTING.md (#70)
Kabir Oberaida745aa33795
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdnew file mode 100644index 0000000..8d3e63a--- /dev/null+++ b/CONTRIBUTING.md@@ -0,0 +1,31 @@+# Contributing to xtool++## Bug reports and feature requests++We welcome all bug reports and feature requests! Please create a [new issue](https://github.com/xtool-org/xtool/issues/new/choose) via GitHub.++## Documentation++The xtool documentation at <https://xtool.sh> is built with [swift-docc](https://github.com/swiftlang/swift-docc) and resides at [Documentation/xtool.docc](/Documentation/xtool.docc). It's hosted on Netlify, the configuration for which is in [netlify.toml](/netlify.toml).++When editing the DocC bundle, you can preview it with `make docs-preview`.++Once you make a pull request with your changes, we'll also generate a [Netlify Deploy Preview](https://docs.netlify.com/site-deploys/deploy-previews/) under your pull request. You can open this preview to see how the changes will look in production.++## Code++When making code changes, please make sure to test them on both macOS and Linux if possible. If you can also test on Windows with WSL, that is ideal.++To build xtool for debugging, run `make` in the project directory. There are a few considerations depending on your host OS:++### macOS++On macOS, you'll firstly need to have Xcode set up.++The first time you run `make`, we'll try to detect your codesigning identity. If you have multiple, you'll see an interactive prompt to select the team you want to use. The team ID is saved to `./macOS/Support/Private-Team.xcconfig`. You can run `make team` to update it (or do so by hand).++After building, a symlink to the product will be created at `./macOS/Build/xtool`. We generate an Xcode project at `./macOS/XToolMac.xcodeproj` that you can open in order to work in Xcode.++### Linux++You need to have a few dependencies on Linux; see [Dockerfile](/Dockerfile) for specifics. It's often easiest to develop within Docker itself: see [Linux/README.md](/Linux/README.md) for details.diff --git a/Makefile b/Makefileindex 4954ccb..da5d26d 100644--- a/Makefile+++ b/Makefile@@ -1,7 +1,115 @@-SPEC_URL = https://developer.apple.com/sample-code/app-store-connect/app-store-connect-openapi-specification.zip+ifeq ($(shell uname -s),Darwin)++IS_MAC = 1++ifneq ($(VERBOSE),1)+ifeq ($(shell type -p xcbeautify &>/dev/null && echo 1),1)+XC_FORMAT = | xcbeautify+endif+endif++endif++ifeq ($(RELEASE),1)+INTERNAL_SWIFTFLAGS = -c release+INTERNAL_XCFLAGS = -configuration Release+else+INTERNAL_SWIFTFLAGS = -c debug+INTERNAL_XCFLAGS = -configuration Debug+endif++ALL_SWIFTFLAGS = $(INTERNAL_SWIFTFLAGS) $(SWIFTFLAGS)+ALL_XCFLAGS = $(INTERNAL_XCFLAGS) $(XCFLAGS)++TEAM_CONFIG = macOS/Support/Private-Team.xcconfig++.PHONY: all+# dev build for the current platform+all:+ifeq ($(IS_MAC),1)+ @+$(MAKE) mac+else+ @+$(MAKE) linux+endif++.PHONY: linux+# dev build for Linux+linux:+ swift build --product xtool $(ALL_SWIFTFLAGS)++.PHONY: linux-dist+# dist build for Linux+linux-dist:+ docker compose run --build --rm xtool Linux/build.sh-.PHONY: api update-api+.PHONY: mac+# dev build for macOS+mac: project+ @rm -rf macOS/Build/XcodeInstall+ @set -o pipefail && cd macOS && \+ xcodebuild build install \+ -skipMacroValidation -skipPackagePluginValidation \+ -scheme XToolMac -destination generic/platform=macOS \+ DSTROOT="$$PWD"/Build/XcodeInstall INSTALL_PATH=/ \+ $(ALL_XCFLAGS) $(XC_FORMAT)+ @ln -fs XcodeInstall/xtool.app/Contents/Resources/bin/xtool macOS/Build/xtool+ @echo "Output: ./macOS/Build/xtool"++.PHONY: mac-dist+# dist build for macOS+# requires a few secrets in the env (see .github/workflows/release.yml)+mac-dist:+ @echo "bundle exec fastlane package"+ @cd macOS && bundle exec fastlane package++.PHONY: reload+# update Xcode project and restart Xcode+reload:+ killall Xcode || :+ @+$(MAKE) project+ xed macOS/XToolMac.xcodeproj++.PHONY: project+# update Xcode project+project: $(TEAM_CONFIG)+ @echo "xcodegen"+ @cd macOS && xcodegen++.PHONY: team+# update development team+team:+ @+$(MAKE) -B $(TEAM_CONFIG)++# update development team if needed.+#+# will prompt interactively if there are multiple valid options.+# set DEVELOPMENT_TEAM=... to force a specific value.+$(TEAM_CONFIG):+ifeq ($(DEVELOPMENT_TEAM),)+ @mkdir -p macOS/Support+ @team=$$(./scripts/select-identity.sh); \+ echo "echo \"DEVELOPMENT_TEAM = $$team\" > $@"; \+ echo "DEVELOPMENT_TEAM = $$team" > $@+else+ @mkdir -p macOS/Support+ echo "DEVELOPMENT_TEAM = $(DEVELOPMENT_TEAM)" > $@+.PHONY: $(TEAM_CONFIG)+endif++.PHONY: docs+# build documentation+docs:+ ./Documentation/build.sh++.PHONY: docs-preview+# preview documentation+docs-preview:+ ./Documentation/build.sh preview++SPEC_URL = https://developer.apple.com/sample-code/app-store-connect/app-store-connect-openapi-specification.zip+.PHONY: api+# Regenerate the OpenAPI client codeapi: openapi/openapi.jsonswift run swift-openapi-generator generate \openapi/openapi.json \@@ -11,6 +119,8 @@ api: openapi/openapi.jsonsed -i '' -e 's/[[:<:]]Client[[:>:]]/DeveloperAPIClient/g' $$file; \done+.PHONY: update-api+# Update OpenAPI spec and regenerate the client codeupdate-api:@+$(MAKE) -B apidiff --git a/macOS/Support/Base.xcconfig b/macOS/Support/Base.xcconfigindex a23580f..5b122f2 100644--- a/macOS/Support/Base.xcconfig+++ b/macOS/Support/Base.xcconfig@@ -6,4 +6,5 @@ ENABLE_HARDENED_RUNTIME = YESPRODUCT_NAME = xtoolPRODUCT_MODULE_NAME = XToolMac+#include? "Private-Team.xcconfig"#include? "Private.xcconfig"diff --git a/scripts/select-identity.sh b/scripts/select-identity.shnew file mode 100755index 0000000..e79e363--- /dev/null+++ b/scripts/select-identity.sh@@ -0,0 +1,31 @@+#!/bin/bash++# we can't simply extract the portion in brackets because some times the Organizational Unit is different from that+# so extract that info from the certificate+function get_team {+ security find-certificate -pc "$1" | openssl x509 -noout -subject | grep -o 'OU=[A-Z0-9]*' | cut -d= -f2+}++IFS=$'\n' names=($(security find-identity -vp codesigning | grep -E '(?:iPhone Developer|Apple Development):' | cut -d'"' -f2 | uniq))+if [[ "${#names[@]}" -eq 1 ]]; then+ identity="${names[0]}"+else+ echo "Select identity" >&2+ for i in "${!names[@]}"; do+ cur_identity="${names[$i]}"+ cur_team="$(get_team "$cur_identity")"+ printf "%s. %s '%s'\n" $((i + 1)) "$cur_team" "$cur_identity" >&2+ done+ # ask for choice until the user supplies a valid answer+ function select_identity {+ read -p "Choice (enter number): " identity_idx >&2+ if [[ "$identity_idx" -lt 1 || "$identity_idx" -gt "${#names[@]}" ]]; then+ select_identity+ else+ identity="${names[$((identity_idx - 1))]}"+ fi+ }+ select_identity+fi++get_team "$identity"