環境構築めんどくさいですよね。 だからシェルを流してバババってやりたいと思っています。
osascriptとはAppleScriptを実行するためのコマンドです
まずはカレントディレクトリでのシェル
#!/bin/sh echo "\n**********************" echo "Xcodeのセットアップ" echo "************************\n" xcode-select --install echo "\n**********************" echo "Homebrewのインストール" echo "************************\n" which -s brew if [[ $? != 0 ]] ; then # Install Homebrew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" else brew update fi echo "\n**********************" echo "Carthageのインストール" echo "************************\n" which -s carthage if [[ $? != 0 ]] ; then brew install carthage else echo "Carthage Found, Skipping Install. \n" echo "Updating Carthage if Necessary. \n" brew upgrade carthage fi echo "\n**********************" echo "Checking for SwiftFormat and SwiftFormat Plugin for Xcode" echo "(you can access from xcode→editor→swift format menu item)" echo "************************\n" which -s swiftformat if [[ $? != 0 ]] ; then brew install swiftformat brew install --cask swiftformat-for-xcode else brew upgrade swiftformat brew upgrade --cask swiftformat-for-xcode fi echo "\n**********************" echo "Xcode用SwiftFormatとSwiftFormatプラグインのチェック" echo "(xcodeの[editor]-[swift format menu item]で確認できます" echo "************************\n" which -s swiftlint if [[ $? != 0 ]] ; then brew install swiftlint brew install --cask swiftformat-for-xcode else brew upgrade swiftlint brew upgrade --cask swiftformat-for-xcode fi # SwiftLintForXcodeのファイルが残っている場合は、ダウンロードを続行する前に削除 rm "SwiftLintForXcode.zip" # SwiftFormat xcode プラグインをダウンロード wget https://github.com/norio-nomura/SwiftLintForXcode/releases/download/0.1/SwiftLintForXcode-0.1.zip -O SwiftLintForXcode.zip # 前のバージョンがインストールされている場合は上書き unzip -o SwiftLintForXcode.zip -d /Applications/ sleep 1; # SwiftLintForXcodeのファイルを削除 rm "SwiftLintForXcode.zip" open -a Finder /Applications/SwiftLintForXcode.app; sleep 3; # xcodeで使用する前に、これらのアプリを一度開く必要がある open ".swiftformat" -a "SwiftFormat for Xcode"; osascript -e 'tell application "Terminal" to activate'; sleep 3; osascript -e 'tell application "SwiftFormat for Xcode" to quit'; open -a "SwiftLintForXcode"; osascript -e 'tell application "Terminal" to activate'; sleep 3; osascript -e 'tell application "SwiftLintForXcode" to quit'; # プラグインを有効にする osascript -e 'tell application "System Preferences" to activate' osascript -e 'tell application "System Preferences" to set current pane to pane "com.apple.preferences.extensions"' osascript -e 'display alert "Please Check `SwiftFormat` to Enable XcodePlugin!"' echo "\n**********************" echo "初期設定完了" echo "************************\n"
そのあと、プロジェクフォルダに移動して以下を実行します
cd [プロジェクフォルダ]
#!/usr/bin/env sh if ! command -v carthage > /dev/null; then printf 'Carthage is not installed.\n' printf 'See https://github.com/Carthage/Carthage for install instructions.\n' exit 1 fi set -euo pipefail xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX) trap 'rm -f "$xcconfig"' INT TERM HUP EXIT CURRENT_XCODE_VERSION=$(xcodebuild -version | grep "Build version" | cut -d' ' -f3) echo "EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1500__BUILD_$CURRENT_XCODE_VERSION = arm64 arm64e armv7 armv7s armv6 armv8" >> $xcconfig echo 'EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1500 = $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1500__BUILD_$(XCODE_PRODUCT_BUILD_VERSION))' >> $xcconfig echo 'EXCLUDED_ARCHS = $(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT)__XCODE_$(XCODE_VERSION_MAJOR))' >> $xcconfig export XCODE_XCCONFIG_FILE="$xcconfig" carthage "$@" # Workaround for Carthage build error END carthage bootstrap --platform iOS --cache-builds --no-use-binaries
抜け、漏れがあるかもしれません Carthageや、その他、プロジェクトに応じて、修正してみてください。