My technology blog

问题

近期,WWDC发布了最新版本的Xcode14,由于Github Action仍然停留在13.2.1,所以决定换到CircleCI。一顿操作后,不论如何设计swift test永远报错。

Build complete! (18.74s)
2022-06-11 09:20:13.934 xctest[2093:7863] The bundle “MagicDataPackageTests.xctest” couldn’t be loaded. Try reinstalling the bundle.
2022-06-11 09:20:13.935 xctest[2093:7863] (dlopen(/Users/distiller/project/.build/x86_64-apple-macosx/debug/MagicDataPackageTests.xctest/Contents/MacOS/MagicDataPackageTests, 0x0109): Symbol not found: _$s10Foundation11JSONDecoderC6decode_4fromxxm_AA4DataVtKSeRzlFTj
  Referenced from: /Users/distiller/project/.build/x86_64-apple-macosx/debug/MagicDataPackageTests.xctest/Contents/MacOS/MagicDataPackageTests
  Expected in: /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation)

Exited with code exit status 1

具体可见:https://discuss.circleci.com/t/circleci-failed-in-my-spa-project/44398

解决

在经过1天的搜索后,机缘巧合下发现创建Xcode Project可以解决,不过不支持仅仅支持macOS13的项目,因为Circle CI的Xcode是运行在macOS12上的。

# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
  test:
    macos:
      xcode: 14.0.0
    steps:
      - checkout
      - run: swift package generate-xcodeproj 
      - run: xcodebuild
      - run: xcodebuild test -scheme {Your_Package_name}-Package

# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
  test-workflow:
    jobs:
      - test
You’ve successfully subscribed to UTS Blog
Welcome back! You’ve successfully signed in.
Great! You’ve successfully signed up.
Your link has expired
Success! Check your email for magic link to sign-in.