4
9
Fork
You've already forked libchewing
3

Introduce importability as a Swift package (C library). #790

Merged
ShikiSuen merged 9 commits from master into master 2025年12月29日 11:34:12 +01:00
ShikiSuen commented 2025年12月21日 13:36:00 +01:00 (Migrated from github.com)
Copy link

This allows macOS IME developers to simply import LibChewing as a Swift Package.

The added Swift Unit Test files are only for making sure that C APIs are accessible from Swift.

On macOS, as long as libchewing is compilable using cargo, one can always run swift tests to build and run Swift package on macOS with Xcode 26 installed (or standalone Swift 6.1+ installation). Earlier Xcode is okay as long as its shipped Swift is 6.1+.

This allows macOS IME developers to simply import LibChewing as a Swift Package. The added Swift Unit Test files are only for making sure that C APIs are accessible from Swift. On macOS, as long as libchewing is compilable using cargo, one can always run `swift tests` to build and run Swift package on macOS with Xcode 26 installed (or standalone Swift 6.1+ installation). Earlier Xcode is okay as long as its shipped Swift is 6.1+.
codecov[bot] commented 2025年12月21日 13:38:03 +01:00 (Migrated from github.com)
Copy link

Codecov Report

All modified and coverable lines are covered by tests.
Project coverage is 92.06%. Comparing base (c04ae27) to head (3a3df8b).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@
## master #790 +/- ##
=======================================
 Coverage 92.06% 92.06% 
=======================================
 Files 37 37 
 Lines 9253 9253 
=======================================
 Hits 8519 8519 
 Misses 734 734 

View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
## [Codecov](https://app.codecov.io/gh/chewing/libchewing/pull/790?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=chewing) Report :white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 92.06%. Comparing base ([`c04ae27`](https://app.codecov.io/gh/chewing/libchewing/commit/c04ae27e21ff112b3c56fa1567ac47fc7285fabb?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=chewing)) to head ([`3a3df8b`](https://app.codecov.io/gh/chewing/libchewing/commit/3a3df8b5bdf7e8377afab87825e1174c0d471c00?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=chewing)). :warning: Report is 1 commits behind head on master. <details><summary>Additional details and impacted files</summary> ```diff @@ Coverage Diff @@ ## master #790 +/- ## ======================================= Coverage 92.06% 92.06% ======================================= Files 37 37 Lines 9253 9253 ======================================= Hits 8519 8519 Misses 734 734 ``` </details> [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/chewing/libchewing/pull/790?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=chewing). :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=chewing). <details><summary> :rocket: New features to boost your workflow: </summary> - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems. </details>
kanru commented 2025年12月29日 03:11:05 +01:00 (Migrated from github.com)
Copy link

Thanks for the contribution!

I'm not familiar with Swift. Is it possible to put everything related to Swift under the swift/ top level directory?

It would be good to run the tests in the CI.

Thanks for the contribution! I'm not familiar with Swift. Is it possible to put everything related to Swift under the `swift/` top level directory? It would be good to run the tests in the CI.
ShikiSuen commented 2025年12月29日 05:54:15 +01:00 (Migrated from github.com)
Copy link
[画像:image]

@kanru I'm afraid that the Package.swift has to be situated at the root folder of the repo. You can fact-check this with Claude Opus, Codex, Raptor... or whatever AI coding agent you trust.

Other files are relocateable.

<img width="442" height="709" alt="image" src="https://github.com/user-attachments/assets/5e672f49-136b-4770-b61f-819cb258f4c7" /> @kanru I'm afraid that the `Package.swift` has to be situated at the root folder of the repo. You can fact-check this with Claude Opus, Codex, Raptor... or whatever AI coding agent you trust. Other files are relocateable.
ShikiSuen commented 2025年12月29日 05:55:16 +01:00 (Migrated from github.com)
Copy link

It would be good to run the tests in the CI.

I'll give it a try.

> It would be good to run the tests in the CI. I'll give it a try.
ShikiSuen commented 2025年12月29日 06:54:10 +01:00 (Migrated from github.com)
Copy link

@kanru

  • All files are relocated to {REPO_ROOT}/swift folder, excepting the mandatory Package.swift.
  • CI tests against this Swift Package are added. For now, these tests only run on macOS platform (macOS 26 image). If future modifications are needed, maintainers may delegate the modification tasks to GitHub copilot instead in case no one is available for this task.
  • All CI tests are green now: http://github.com/chewing/libchewing/actions/runs/20565593988/job/59063310287?pr=790 despite a useless warning "This header is deprecated. Include <chewing.h> directly.".
@kanru - All files are relocated to `{REPO_ROOT}/swift` folder, excepting the mandatory `Package.swift`. - CI tests against this Swift Package are added. For now, these tests only run on macOS platform (macOS 26 image). If future modifications are needed, maintainers may delegate the modification tasks to GitHub copilot instead in case no one is available for this task. - All CI tests are green now: http://github.com/chewing/libchewing/actions/runs/20565593988/job/59063310287?pr=790 despite a useless warning `"This header is deprecated. Include <chewing.h> directly."`.
ShikiSuen commented 2025年12月30日 11:39:11 +01:00 (Migrated from github.com)
Copy link

@kanru

  1. {REPO_ROOT}/tools/CargoBuildPlugin/Plugin.swift should be OK to be be removed. This is something I forgot to remove.
  2. In {REPO_ROOT}/swift/tools/CargoBuildPlugin/Plugin.swift we can simplify the following error message:
"`cargo` not found on the system. Please install Rust (https://rustup.rs/) to enable automatic builds, or disable automatic Cargo build by setting `LIBCHEWING_AUTO_BUILD_CARGO=0` and run `swift/scripts/build-cargo.sh` manually to produce the library before running `swift build`."

to the following (or whatever better to you):

"`cargo` not found on the system. Please install Rust (https://rustup.rs/) to enable automatic builds. Or, you may disable automatic Cargo build by setting `LIBCHEWING_AUTO_BUILD_CARGO=0` and manually compile the Rust library before running `swift build`."
@kanru 1. `{REPO_ROOT}/tools/CargoBuildPlugin/Plugin.swift` should be OK to be be removed. This is something I forgot to remove. 2. In `{REPO_ROOT}/swift/tools/CargoBuildPlugin/Plugin.swift` we can simplify the following error message: ``` "`cargo` not found on the system. Please install Rust (https://rustup.rs/) to enable automatic builds, or disable automatic Cargo build by setting `LIBCHEWING_AUTO_BUILD_CARGO=0` and run `swift/scripts/build-cargo.sh` manually to produce the library before running `swift build`." ``` to the following (or whatever better to you): ``` "`cargo` not found on the system. Please install Rust (https://rustup.rs/) to enable automatic builds. Or, you may disable automatic Cargo build by setting `LIBCHEWING_AUTO_BUILD_CARGO=0` and manually compile the Rust library before running `swift build`." ```
Sign in to join this conversation.
No reviewers
Labels
Clear labels
dictionary
duplicate
fixed
0.11.0

Archived

fixed
0.13.0
refactoring

Archived

rewrite in rust
Might be fixed by the rust rewrite
thirdparty
arch
aarch64
系統架構是 Aarch64
arch
x86_64
系統架構是 x86_64
cannot reproduce
無法重現問題 Cannot reproduce the issue
contribution welcome
歡迎來幫忙 Contributions are very welcome, get started here
duplicate
重複的問題回報 This issue or pull request already exists
good first issue
適合新手 Interested in contributing? Get started here.
help wanted
需要高手相助 Need some help
invalid
回報的問題無效 Something is wrong
kind
bug
有東西不正常運作 Something is not working
kind
doc
加強文件說明 Enhance documentation
kind
enhancement
新功能 New feature
kind
mega issue
同一個問題回報中包含多個問題 Multiple issues reported
kind
question
只是問問題 Asking a question
needinfo
需要更多資訊 More information is needed
os
apple
作業系統是 MacOS 或 iOS
os
linux
作業系統是 GNU Linux
os
windows
作業系統是 Windows
to be determined
還未被說服有需求 Can't decide whether this is needed
upstream
跟上游軟體相關 Related to an upstream repository, already reported there
wontfix
我們決定不處理 Won't be fixed
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
chewing/libchewing!790
Reference in a new issue
chewing/libchewing
No description provided.
Delete branch "master"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?