Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Build CareKit for macOS and visionOS #716

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: macos-14
strategy:
matrix:
destination: ['platform=iOS\ Simulator,OS=17.5,name=iPhone\ 15\ Pro\ Max', 'platform=watchOS\ Simulator,OS=10.5,name=Apple\ Watch\ Series\ 7\ \(45mm\)']
destination: ['platform=iOS\ Simulator,OS=17.5,name=iPhone\ 15\ Pro\ Max', 'platform=watchOS\ Simulator,OS=10.5,name=Apple\ Watch\ Series\ 7\ \(45mm\)', 'platform=macOS CODE_SIGN_IDENTITY=""', 'platform=visionOS\ Simulator,OS=1.2,name=Apple\ Vision\ Pro CODE_SIGN_IDENTITY=""']
scheme: ['CareKit', 'CareKitStore', 'CareKitUI', 'CareKitFHIR']
steps:
- uses: actions/checkout@v4
Expand Down
22 changes: 13 additions & 9 deletions CareKit/CareKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 53;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -1131,12 +1131,12 @@
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = Apple.CareKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "watchsimulator watchos iphonesimulator iphoneos";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx watchos watchsimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,4";
TARGETED_DEVICE_FAMILY = "1,2,4,7";
};
name = Debug;
};
Expand Down Expand Up @@ -1166,10 +1166,10 @@
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = Apple.CareKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "watchsimulator watchos iphonesimulator iphoneos";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx watchos watchsimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,4";
TARGETED_DEVICE_FAMILY = "1,2,4,7";
};
name = Release;
};
Expand Down Expand Up @@ -1238,6 +1238,7 @@
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = "$(VERSION_NUMBER)";
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
Expand All @@ -1252,6 +1253,7 @@
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 7.0;
XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Debug;
};
Expand Down Expand Up @@ -1314,6 +1316,7 @@
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = "$(VERSION_NUMBER)";
MTL_ENABLE_DEBUG_INFO = NO;
ONLY_ACTIVE_ARCH = NO;
Expand All @@ -1328,6 +1331,7 @@
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 7.0;
XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Release;
};
Expand Down Expand Up @@ -1365,13 +1369,13 @@
RUN_DOCUMENTATION_COMPILER = YES;
SDKROOT = auto;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator watchos watchsimulator";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx watchos watchsimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SUPPORTS_UIKITFORMAC = NO;
"SWIFT_ACTIVE_COMPILATION_CONDITIONS[arch=*]" = DEBUG;
SWIFT_TREAT_WARNINGS_AS_ERRORS = NO;
TARGETED_DEVICE_FAMILY = "1,2,4";
TARGETED_DEVICE_FAMILY = "1,2,4,7";
WATCHOS_DEPLOYMENT_TARGET = 7.0;
};
name = Debug;
Expand Down Expand Up @@ -1410,12 +1414,12 @@
RUN_DOCUMENTATION_COMPILER = YES;
SDKROOT = auto;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator watchos watchsimulator";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx watchos watchsimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SUPPORTS_UIKITFORMAC = NO;
SWIFT_TREAT_WARNINGS_AS_ERRORS = NO;
TARGETED_DEVICE_FAMILY = "1,2,4";
TARGETED_DEVICE_FAMILY = "1,2,4,7";
WATCHOS_DEPLOYMENT_TARGET = 7.0;
};
name = Release;
Expand Down
4 changes: 4 additions & 0 deletions CareKit/CareKit/Shared/Extensions/UIImage+Asset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if canImport(UIKit)

import Foundation
import UIKit

Expand All @@ -42,3 +44,5 @@ extension UIImage {
return otherUrlImage ?? appAssetsImage ?? symbol
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

import CareKitStore
import Foundation
import UIKit

extension OCKAnyReadOnlyEventStore {

Expand Down
23 changes: 20 additions & 3 deletions CareKit/CareKit/Shared/Task/OCKTaskEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ public struct OCKTaskEvents: Collection, Identifiable {

// First make sure there is no matching event already stored in the data structure.
let indexPath = self.indexPath(of: event)
guard indexPath == nil else { return (self[indexPath!.section][indexPath!.row], false) }
guard indexPath == nil else {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment below about row/item is handled for how iOS/macOS

let indexPathRowValue = rowValueOfIndexPath(indexPath!)
return (self[indexPath!.section][indexPathRowValue], false)
}

// Append the event to the matching section if one exists.
if let section = section(for: event.task) {
Expand All @@ -113,7 +116,8 @@ public struct OCKTaskEvents: Collection, Identifiable {
public mutating func remove(event: OCKAnyEvent) -> OCKAnyEvent? {
guard let indexPath = indexPath(of: event) else { return nil }
var updatedEvents = events[indexPath.section]
let removedEvent = updatedEvents.remove(at: indexPath.row)
let indexPathRowValue = rowValueOfIndexPath(indexPath)
let removedEvent = updatedEvents.remove(at: indexPathRowValue)

// If the removed event was the last one in the section, remove the whole section.
guard !updatedEvents.isEmpty else {
Expand All @@ -132,7 +136,8 @@ public struct OCKTaskEvents: Collection, Identifiable {
public mutating func update(event: OCKAnyEvent) -> OCKAnyEvent? {
// Update the matching event
if let matchIndexPath = indexPath(of: event) {
events[matchIndexPath.section][matchIndexPath.row] = event
let matchIndexPathRowValue = rowValueOfIndexPath(matchIndexPath)
events[matchIndexPath.section][matchIndexPathRowValue] = event
return event
// Else append the event
} else {
Expand All @@ -148,7 +153,19 @@ public struct OCKTaskEvents: Collection, Identifiable {
private func indexPath(of event: OCKAnyEvent) -> IndexPath? {
guard let section = section(for: event.task) else { return nil }
guard let row = events[section].firstIndex(where: { $0.matches(event) }) else { return nil }
#if !os(macOS)
return .init(row: row, section: section)
#else
return .init(item: row, section: section)
#endif
}

private func rowValueOfIndexPath(_ indexPath: IndexPath) -> Int {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this method because iOS and macOS use row/item respectively

#if !os(macOS)
return indexPath.row
#else
return indexPath.item
#endif
}

// MARK: - Collection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import CareKitStore
import CareKitUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import CareKitStore
import CareKitUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import CareKitStore
import CareKitUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import CareKitStore
import CareKitUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import CareKitStore
import CareKitUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import CareKitStore
import CareKitUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import CareKitStore
import CareKitUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import CareKitStore
import Foundation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS) && !os(visionOS)

import CareKitStore
import CareKitUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS) && !os(visionOS)

import CareKitStore
import CareKitUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS) && !os(visionOS)

import CareKitStore
import CareKitUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS) && !os(visionOS)

import CareKitStore
import CareKitUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import CareKitStore
import CareKitUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import CareKitStore
import CareKitUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import CareKitStore
import CareKitUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if !os(watchOS)
#if !os(watchOS) && !os(macOS) && !os(visionOS)

import CareKitStore
import CareKitUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS) && !os(visionOS)

import CareKitStore
import Foundation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS) && !os(visionOS)

import CareKitStore
import Foundation
Expand Down
2 changes: 1 addition & 1 deletion CareKit/CareKit/iOS/Details/OCKDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS) && !os(visionOS)

import CareKitUI
import UIKit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import UIKit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import CareKitUI
import UIKit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import CareKitUI
import UIKit
Expand Down
2 changes: 1 addition & 1 deletion CareKit/CareKit/iOS/Higher Order/View/OCKListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import CareKitUI
import UIKit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !os(watchOS)
#if !os(watchOS) && !os(macOS)

import CareKitStore
import CareKitUI
Expand Down
Loading
Loading