Skip to content

Commit 66b6590

Browse files
Add actual refinements of our NS_REFINED_FOR_SWIFT bits.
1 parent a62b5db commit 66b6590

File tree

5 files changed

+72
-2
lines changed

5 files changed

+72
-2
lines changed
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright (c) 2024 Project CHIP Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// TODO: MTR_NEWLY_AVAILABLE, but figure out the version numbers to go in here:
18+
// @available(iOS NNN, macOS NNN, watchOS NNN, tvOS NNN, *)
19+
extension MTRCluster {
20+
public var endpointID: UInt16 {
21+
get {
22+
return self.__endpointID.uint16Value
23+
}
24+
}
25+
}

src/darwin/Framework/CHIP/MTRDefines.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
// clang-format on
7474

7575
#define _MTR_DEPRECATED _MTR_IMPLICIT_EXPORT MTR_SWIFT_DISFAVORED_OVERLOAD
76-
#define _MTR_UNAVAILABLE _MTR_IMPLICIT_EXPORT NS_UNAVAILABLE
76+
#define _MTR_UNAVAILABLE _MTR_IMPLICIT_EXPORT API_UNAVAILABLE(ios, macos, tvos, watchos)
7777

7878
// clang-format off
7979
#if MTR_NO_AVAILABILITY
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright (c) 2024 Project CHIP Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// TODO: MTR_NEWLY_AVAILABLE, but figure out the version numbers to go in here:
18+
// @available(iOS NNN, macOS NNN, watchOS NNN, tvOS NNN, *)
19+
extension MTRDevice {
20+
public var nodeID: UInt64 {
21+
get {
22+
return self.__nodeID.uint64Value
23+
}
24+
}
25+
}

src/darwin/Framework/CHIPTests/MTRSwiftDeviceTests.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class MTRSwiftDeviceTests : XCTestCase {
185185
{
186186
let device = MTRDevice(nodeID: DeviceConstants.deviceID as NSNumber, controller:sController!)
187187
let queue = DispatchQueue.main
188-
188+
189189
// Given reachable state becomes true before underlying OnSubscriptionEstablished callback, this expectation is necessary but
190190
// not sufficient as a mark to the end of reports
191191
let subscriptionExpectation = expectation(description: "Subscription has been set up")
@@ -486,10 +486,14 @@ class MTRSwiftDeviceTests : XCTestCase {
486486
let device = MTRDevice(nodeID: DeviceConstants.deviceID as NSNumber, controller:sController!)
487487
let queue = DispatchQueue.main
488488

489+
XCTAssertEqual(device.nodeID, UInt64(DeviceConstants.deviceID));
490+
489491
let opcredsCluster = MTRClusterOperationalCredentials(device: device, endpointID: 0, queue: queue)!
490492
let onOffCluster = MTRClusterOnOff(device: device, endpointID: 1, queue: queue)!
491493
let badOnOffCluster = MTRClusterOnOff(device: device, endpointID: 0, queue: queue)!
492494

495+
XCTAssertEqual(onOffCluster.endpointID, 1);
496+
493497
// Ensure our existing fabric label is not "Test". This uses a "base"
494498
// cluster to ensure read-through to the other side.
495499
let baseOpCredsCluster = MTRBaseClusterOperationalCredentials(device: sConnectedDevice!, endpointID: 0, queue: queue)!

src/darwin/Framework/Matter.xcodeproj/project.pbxproj

+16
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@
131131
510470FB2A2F7DF60053EA7E /* MTRBackwardsCompatShims.mm in Sources */ = {isa = PBXBuildFile; fileRef = 510470FA2A2F7DF60053EA7E /* MTRBackwardsCompatShims.mm */; };
132132
510A07492A685D3900A9241C /* Matter.apinotes in Headers */ = {isa = PBXBuildFile; fileRef = 510A07482A685D3900A9241C /* Matter.apinotes */; settings = {ATTRIBUTES = (Public, ); }; };
133133
510CECA8297F72970064E0B3 /* MTROperationalCertificateIssuerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 510CECA6297F72470064E0B3 /* MTROperationalCertificateIssuerTests.m */; };
134+
5114A83A2C935DF700F7A4F1 /* MTRDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5114A8392C935DF700F7A4F1 /* MTRDevice.swift */; };
135+
5114A83C2C935FA700F7A4F1 /* MTRCluster.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5114A83B2C935FA700F7A4F1 /* MTRCluster.swift */; };
134136
5117DD3829A931AE00FFA1AA /* MTROperationalBrowser.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5117DD3629A931AD00FFA1AA /* MTROperationalBrowser.mm */; };
135137
5117DD3929A931AE00FFA1AA /* MTROperationalBrowser.h in Headers */ = {isa = PBXBuildFile; fileRef = 5117DD3729A931AE00FFA1AA /* MTROperationalBrowser.h */; };
136138
511913FB28C100EF009235E9 /* MTRBaseSubscriptionCallback.mm in Sources */ = {isa = PBXBuildFile; fileRef = 511913F928C100EF009235E9 /* MTRBaseSubscriptionCallback.mm */; };
@@ -567,6 +569,8 @@
567569
510470FA2A2F7DF60053EA7E /* MTRBackwardsCompatShims.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRBackwardsCompatShims.mm; sourceTree = "<group>"; };
568570
510A07482A685D3900A9241C /* Matter.apinotes */ = {isa = PBXFileReference; lastKnownFileType = text.apinotes; name = Matter.apinotes; path = CHIP/Matter.apinotes; sourceTree = "<group>"; };
569571
510CECA6297F72470064E0B3 /* MTROperationalCertificateIssuerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTROperationalCertificateIssuerTests.m; sourceTree = "<group>"; };
572+
5114A8392C935DF700F7A4F1 /* MTRDevice.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MTRDevice.swift; sourceTree = "<group>"; };
573+
5114A83B2C935FA700F7A4F1 /* MTRCluster.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MTRCluster.swift; sourceTree = "<group>"; };
570574
5117DD3629A931AD00FFA1AA /* MTROperationalBrowser.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTROperationalBrowser.mm; sourceTree = "<group>"; };
571575
5117DD3729A931AE00FFA1AA /* MTROperationalBrowser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTROperationalBrowser.h; sourceTree = "<group>"; };
572576
511913F928C100EF009235E9 /* MTRBaseSubscriptionCallback.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRBaseSubscriptionCallback.mm; sourceTree = "<group>"; };
@@ -1314,6 +1318,7 @@
13141318
1ED276E326C5832500547A89 /* MTRCluster.h */,
13151319
7596A84E2877E6A9004DAE0E /* MTRCluster_Internal.h */,
13161320
1ED276E126C5812A00547A89 /* MTRCluster.mm */,
1321+
5114A83B2C935FA700F7A4F1 /* MTRCluster.swift */,
13171322
93E610A92B626E290077F02A /* MTRClusterNames.h */,
13181323
5ACDDD7927CD129700EFD68A /* MTRClusterStateCacheContainer.h */,
13191324
5ACDDD7B27CD14AF00EFD68A /* MTRClusterStateCacheContainer_Internal.h */,
@@ -1333,6 +1338,7 @@
13331338
7596A84A287636C1004DAE0E /* MTRDevice_Internal.h */,
13341339
7596A84228762729004DAE0E /* MTRDevice.h */,
13351340
7596A84328762729004DAE0E /* MTRDevice.mm */,
1341+
5114A8392C935DF700F7A4F1 /* MTRDevice.swift */,
13361342
9B5CCB5A2C6EC890009DD99B /* MTRDevice_XPC.h */,
13371343
D4288E862C8A273F002FEC53 /* MTRDevice_XPC_Internal.h */,
13381344
9B5CCB5B2C6EC890009DD99B /* MTRDevice_XPC.mm */,
@@ -1825,6 +1831,7 @@
18251831
};
18261832
B202528C2459E34F00F97062 = {
18271833
CreatedOnToolsVersion = 11.4.1;
1834+
LastSwiftMigration = 1530;
18281835
};
18291836
B20252952459E34F00F97062 = {
18301837
CreatedOnToolsVersion = 11.4.1;
@@ -2008,7 +2015,9 @@
20082015
9B5CCB602C6EE29E009DD99B /* MTRDeviceControllerXPCParameters.mm in Sources */,
20092016
75B765C32A1D82D30014719B /* MTRAttributeSpecifiedCheck.mm in Sources */,
20102017
AF5F90FF2878D351005503FA /* MTROTAProviderDelegateBridge.mm in Sources */,
2018+
5114A83C2C935FA700F7A4F1 /* MTRCluster.swift in Sources */,
20112019
516415FF2B6B132200D5CE11 /* DataModelHandler.cpp in Sources */,
2020+
5114A83A2C935DF700F7A4F1 /* MTRDevice.swift in Sources */,
20122021
75139A6F2B7FE5E900E3A919 /* MTRDeviceControllerLocalTestStorage.mm in Sources */,
20132022
51E95DFC2A78443C00A434F0 /* MTRSessionResumptionStorageBridge.mm in Sources */,
20142023
514C79ED2B62ADCD00DD6D7B /* ember-compatibility-functions.cpp in Sources */,
@@ -2362,6 +2371,7 @@
23622371
BA09EB742474881D00605257 /* Debug */ = {
23632372
isa = XCBuildConfiguration;
23642373
buildSettings = {
2374+
CLANG_ENABLE_MODULES = YES;
23652375
CODE_SIGN_STYLE = Automatic;
23662376
DEFINES_MODULE = YES;
23672377
DEVELOPMENT_TEAM = "";
@@ -2421,6 +2431,8 @@
24212431
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
24222432
SDKROOT = iphoneos;
24232433
STRIP_STYLE = "non-global";
2434+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
2435+
SWIFT_VERSION = 5.0;
24242436
SYSTEM_HEADER_SEARCH_PATHS = (
24252437
"$(TEMP_DIR)/out/gen/include",
24262438
"$(CHIP_ROOT)/src/darwin/Framework/CHIP/",
@@ -2441,6 +2453,7 @@
24412453
BA09EB752474881D00605257 /* Debug */ = {
24422454
isa = XCBuildConfiguration;
24432455
buildSettings = {
2456+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
24442457
CLANG_ENABLE_MODULES = YES;
24452458
CODE_SIGN_STYLE = Automatic;
24462459
DEVELOPMENT_TEAM = "";
@@ -2532,6 +2545,7 @@
25322545
BA09EB782474882200605257 /* Release */ = {
25332546
isa = XCBuildConfiguration;
25342547
buildSettings = {
2548+
CLANG_ENABLE_MODULES = YES;
25352549
CODE_SIGN_STYLE = Automatic;
25362550
DEFINES_MODULE = YES;
25372551
DEVELOPMENT_TEAM = "";
@@ -2593,6 +2607,7 @@
25932607
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
25942608
SDKROOT = iphoneos;
25952609
STRIP_STYLE = "non-global";
2610+
SWIFT_VERSION = 5.0;
25962611
SYSTEM_HEADER_SEARCH_PATHS = (
25972612
"$(TEMP_DIR)/out/gen/include",
25982613
"$(CHIP_ROOT)/src/darwin/Framework/CHIP/",
@@ -2613,6 +2628,7 @@
26132628
BA09EB792474882200605257 /* Release */ = {
26142629
isa = XCBuildConfiguration;
26152630
buildSettings = {
2631+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
26162632
CLANG_ENABLE_MODULES = YES;
26172633
CODE_SIGN_STYLE = Automatic;
26182634
DEVELOPMENT_TEAM = "";

0 commit comments

Comments
 (0)