diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml new file mode 100644 index 00000000..63fed2a8 --- /dev/null +++ b/.github/workflows/swift.yml @@ -0,0 +1,70 @@ +name: Swift Build and Test +on: + push: + pull_request: + +jobs: + macos-build: + name: Build and Test on macOS + runs-on: macos-15 + steps: + - name: Select Xcode 16.3 + run: | + XCODE_PATH=$(ls -d /Applications/Xcode_16.3*.app | head -n 1) + echo "Using Xcode at $XCODE_PATH" + sudo xcode-select -s "$XCODE_PATH/Contents/Developer" + xcodebuild -version + - uses: actions/checkout@v4 + with: + submodules: true + - name: Build + run: swift build --package-path Core + - name: Test + run: swift test --package-path Core + + xcodebuild-test: + name: Xcodebuild test on macOS + runs-on: macos-15 + steps: + - name: Select Xcode 16.3 + run: | + XCODE_PATH=$(ls -d /Applications/Xcode_16.3*.app | head -n 1) + echo "Using Xcode at $XCODE_PATH" + sudo xcode-select -s "$XCODE_PATH/Contents/Developer" + xcodebuild -version + - uses: actions/checkout@v4 + with: + submodules: true + - name: Verify xcodebuild installation + run: xcodebuild -version + - name: List available schemes + run: xcodebuild -project azooKeyMac.xcodeproj -list + - name: Test building azooKeyMac (Release configuration) + run: | + xcodebuild \ + -project azooKeyMac.xcodeproj \ + -scheme azooKeyMac \ + -configuration Release \ + -destination 'generic/platform=macOS' \ + CODE_SIGNING_ALLOWED=NO \ + CODE_SIGNING_REQUIRED=NO \ + CODE_SIGN_IDENTITY="" + + swiftlint: + name: SwiftLint + runs-on: macos-15 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Install SwiftLint + run: | + brew update + brew install swiftlint + - name: Check SwiftLint version + run: swiftlint version + - name: Run SwiftLint + run: | + swiftlint --fix --format + swiftlint --quiet --strict + \ No newline at end of file diff --git a/azooKeyMac.xcodeproj/project.pbxproj b/azooKeyMac.xcodeproj/project.pbxproj index 53bbe3a1..a13c4692 100644 --- a/azooKeyMac.xcodeproj/project.pbxproj +++ b/azooKeyMac.xcodeproj/project.pbxproj @@ -420,7 +420,6 @@ SDKROOT = macosx; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SYMROOT = build; }; name = Debug; }; @@ -478,7 +477,6 @@ SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; - SYMROOT = build; }; name = Release; }; diff --git a/azooKeyMac/Extensions/KeychainHelper.swift b/azooKeyMac/Extensions/KeychainHelper.swift index 59a36896..dbac537b 100644 --- a/azooKeyMac/Extensions/KeychainHelper.swift +++ b/azooKeyMac/Extensions/KeychainHelper.swift @@ -33,7 +33,7 @@ enum KeychainHelper { let status = SecItemCopyMatching(query as CFDictionary, &dataTypeRef) if status == errSecSuccess, let data = dataTypeRef as? Data { - return String(decoding: data, as: UTF8.self) + return String(bytes: data, encoding: .utf8) } return nil diff --git a/azooKeyMac/InputController/OpenAIClient.swift b/azooKeyMac/InputController/OpenAIClient.swift index 0012f6df..4554de49 100644 --- a/azooKeyMac/InputController/OpenAIClient.swift +++ b/azooKeyMac/InputController/OpenAIClient.swift @@ -271,7 +271,7 @@ enum OpenAIClient { } guard httpResponse.statusCode == 200 else { - let responseBody = String(decoding: data, as: UTF8.self) + let responseBody = String(bytes: data, encoding: .utf8) ?? "Body is not encoded in UTF-8" throw OpenAIError.invalidResponseStatus(code: httpResponse.statusCode, body: responseBody) }