devicekit / DeviceKit

DeviceKit is a value-type replacement of UIDevice.
MIT License
4.4k stars 425 forks source link

Make source code buildable on macOS #342

Closed honghaoz closed 6 months ago

honghaoz commented 1 year ago

This PR updates the package buildable on macOS, to address the SwiftUI preview issue on macOS, see https://github.com/devicekit/DeviceKit/issues/341

NoemiRozpara commented 1 year ago

@JulesMoorhouse @honghaoz hey! First of all, thanks for taking your time to fix this issue - it's been bugging me for a while and getting SwiftUI canvas back would be awesome ✨ Will you have some time soon to take a look at the failing action? I just added the forked version to my project and seems to be fine 🤞

Archish27 commented 7 months ago

Hello @Zandor300 Can you please merge this PR?

honghaoz commented 7 months ago

@Archish27 Hi I have just updated the PR. I hope we can merge this change sooner. 🙇

honghaoz commented 7 months ago

@Zandor300 Thanks for triggering the build. However, it seems like danger action failed because it couldn't find commit 87f53f07, which is the commit from my forked repo:

bundler: failed to load command: danger (/Users/runner/work/DeviceKit/DeviceKit/vendor/bundle/ruby/2.6.0/bin/danger)
RuntimeError: Commit 87f53f07 doesn't exist. Are you running `danger local/pr` against the correct repository? Also this usually happens when you rebase/reset and force-pushed.

From the checkout action:

Fetching the repository
  /usr/local/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +028963b08f03943779[45](https://github.com/devicekit/DeviceKit/actions/runs/7345636611/job/20014482957#step:2:50)bba4b94f3c8df80a9585:refs/remotes/pull/342/merge
...
Checking out the ref
  /usr/local/bin/git checkout --progress --force refs/remotes/pull/342/merge
  HEAD is now at 028963b Merge 87f53f07e85393672c276411695faf25e40db13a into 43a9f9388636be506fed8b6b86f858d759a21178
/usr/local/bin/git log -1 --format='%H'
'028963b08f0394377945bba4b94f3c8df80a9585'

The head is 028963b, which is a new merge commit from my commit (87f53f07)

Looks like the checkout action only fetched the last commit (028963b) due to --depth=1, but danger action is trying to find the parent commit 87f53f07, which is not fetched.

Maybe we need to adjust the checkout action fetch more history? or maybe the danger action should smartly use the merging commit.

Zandor300 commented 6 months ago

@honghaoz @NoemiRozpara @Archish27 I've made another PR, that doesn't exclude the entire library when compiling. I'm unable to reproduce the actual issue you are having so could you try my PR or provide an example project where it is happening?

https://github.com/devicekit/DeviceKit/pull/376

honghaoz commented 6 months ago

@Zandor300 I just tried it out, unfortunately, both the master branch and feature/merge-prs are broken. It seems like you are still actively working on it? For the current master branch, it won't compile for two issues:

  1. In Package.swift, it should bump up the spm tool version to 5.8 // swift-tools-version:5.8 to support the privacy manifest file
  2. Bunch of compiling issues, like: CleanShot 2024-01-15 at 14 40 56@2x
honghaoz commented 6 months ago

@Zandor300 Here is a followup PR (https://github.com/devicekit/DeviceKit/pull/379) based on the latest master branch.

honghaoz commented 6 months ago

Closes this PR in favor of https://github.com/devicekit/DeviceKit/pull/379

honghaoz commented 6 months ago

I've made another PR, that doesn't exclude the entire library when compiling.

tbh, since the library doesn't support macOS, it seems unnecessary to include the code for macOS. unless we decided to include Macs.

honghaoz commented 6 months ago

I'm unable to reproduce the actual issue you are having so could you try my PR or provide an example project where it is happening?

@Zandor300 Here is an example project shows the issue: DeviceKit-Mac.zip. I tested on Xcode 15.2.