Skip to content

Commit 4f3197b

Browse files
committed
Modernize code to not rely on deprecations and old behavior
1 parent 5a80967 commit 4f3197b

17 files changed

+35
-22
lines changed

CoreFoundation/Base.subproj/CFPlatform.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ static _CFThreadSpecificKey __CFTSDIndexKey;
733733
static void *__CFThreadSpecificData;
734734
#endif
735735

736-
CF_PRIVATE void __CFTSDInitialize() {
736+
CF_PRIVATE void __CFTSDInitialize(void) {
737737
#if !TARGET_OS_WASI
738738
static dispatch_once_t once;
739739
dispatch_once(&once, ^{

CoreFoundation/Base.subproj/CFUtilities.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,7 @@ CF_EXPORT Boolean _CFExtensionIsValidToAppend(CFStringRef extension) {
16641664

16651665
#if DEPLOYMENT_RUNTIME_SWIFT && !TARGET_OS_WASI
16661666

1667-
CFDictionaryRef __CFGetEnvironment() {
1667+
CFDictionaryRef __CFGetEnvironment(void) {
16681668
static dispatch_once_t once = 0L;
16691669
static CFMutableDictionaryRef envDict = NULL;
16701670
dispatch_once(&once, ^{
@@ -1719,7 +1719,7 @@ CFDictionaryRef __CFGetEnvironment() {
17191719
return envDict;
17201720
}
17211721

1722-
int32_t __CFGetPid() {
1722+
int32_t __CFGetPid(void) {
17231723
return getpid();
17241724
}
17251725

CoreFoundation/RunLoop.subproj/CFRunLoop.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ static CFStringRef __CFRunLoopCopyDescription(CFTypeRef cf) {
806806
return result;
807807
}
808808

809-
CF_PRIVATE void __CFRunLoopDump() { // __private_extern__ to keep the compiler from discarding it
809+
CF_PRIVATE void __CFRunLoopDump(void) { // __private_extern__ to keep the compiler from discarding it
810810
CFStringRef desc = CFCopyDescription(CFRunLoopGetCurrent());
811811
CFShow(desc);
812812
CFRelease(desc);

Darwin/Foundation-swiftoverlay/DataThunks.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static NSInteger _NSWriteToFileDescriptor(int32_t fd, const void *buffer, NSUInt
7575

7676
static NSError *_NSErrorWithFilePath(NSInteger code, id pathOrURL) {
7777
NSString *key = [pathOrURL isKindOfClass:[NSURL self]] ? NSURLErrorKey : NSFilePathErrorKey;
78-
return [NSError errorWithDomain:NSCocoaErrorDomain code:code userInfo:[NSDictionary dictionaryWithObjectsAndKeys:pathOrURL, key, nil]];
78+
return [NSError errorWithDomain:NSCocoaErrorDomain code:code userInfo:@{pathOrURL: key}];
7979
}
8080

8181
static NSError *_NSErrorWithFilePathAndErrno(NSInteger posixErrno, id pathOrURL, BOOL reading) {
@@ -106,7 +106,7 @@ static NSInteger _NSWriteToFileDescriptor(int32_t fd, const void *buffer, NSUInt
106106
}
107107

108108
NSString *key = [pathOrURL isKindOfClass:[NSURL self]] ? NSURLErrorKey : NSFilePathErrorKey;
109-
NSDictionary *userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:pathOrURL, key, [NSError errorWithDomain:NSPOSIXErrorDomain code:posixErrno userInfo:nil], NSUnderlyingErrorKey, nil];
109+
NSDictionary *userInfo = @{pathOrURL : key, [NSError errorWithDomain:NSPOSIXErrorDomain code:posixErrno userInfo:nil] : NSUnderlyingErrorKey};
110110
NSError *error = [NSError errorWithDomain:NSCocoaErrorDomain code:code userInfo:userInfo];
111111
[userInfo release];
112112
return error;

Foundation.xcodeproj/project.pbxproj

+11-3
Original file line numberDiff line numberDiff line change
@@ -2703,7 +2703,7 @@
27032703
isa = PBXProject;
27042704
attributes = {
27052705
LastSwiftUpdateCheck = 1130;
2706-
LastUpgradeCheck = 1130;
2706+
LastUpgradeCheck = 1310;
27072707
ORGANIZATIONNAME = Swift;
27082708
TargetAttributes = {
27092709
5B5D885C1BBC938800234F36 = {
@@ -3831,6 +3831,7 @@
38313831
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
38323832
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
38333833
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
3834+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
38343835
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
38353836
CLANG_WARN_STRICT_PROTOTYPES = YES;
38363837
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -3893,6 +3894,7 @@
38933894
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
38943895
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
38953896
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
3897+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
38963898
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
38973899
CLANG_WARN_STRICT_PROTOTYPES = YES;
38983900
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -4183,6 +4185,7 @@
41834185
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
41844186
CLANG_ENABLE_MODULES = YES;
41854187
CLANG_ENABLE_OBJC_ARC = YES;
4188+
CODE_SIGN_IDENTITY = "-";
41864189
COMBINE_HIDPI_IMAGES = YES;
41874190
FRAMEWORK_SEARCH_PATHS = "";
41884191
HEADER_SEARCH_PATHS = (
@@ -4213,6 +4216,7 @@
42134216
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
42144217
CLANG_ENABLE_MODULES = YES;
42154218
CLANG_ENABLE_OBJC_ARC = YES;
4219+
CODE_SIGN_IDENTITY = "-";
42164220
COMBINE_HIDPI_IMAGES = YES;
42174221
FRAMEWORK_SEARCH_PATHS = "";
42184222
HEADER_SEARCH_PATHS = (
@@ -4245,7 +4249,7 @@
42454249
CLANG_ENABLE_MODULES = YES;
42464250
CLANG_ENABLE_OBJC_ARC = YES;
42474251
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
4248-
CODE_SIGN_IDENTITY = "";
4252+
CODE_SIGN_IDENTITY = "-";
42494253
COMBINE_HIDPI_IMAGES = YES;
42504254
HEADER_SEARCH_PATHS = (
42514255
"$(CONFIGURATION_BUILD_DIR)/usr/local/include",
@@ -4276,7 +4280,7 @@
42764280
CLANG_ENABLE_MODULES = YES;
42774281
CLANG_ENABLE_OBJC_ARC = YES;
42784282
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
4279-
CODE_SIGN_IDENTITY = "";
4283+
CODE_SIGN_IDENTITY = "-";
42804284
COMBINE_HIDPI_IMAGES = YES;
42814285
HEADER_SEARCH_PATHS = (
42824286
"$(CONFIGURATION_BUILD_DIR)/usr/local/include",
@@ -4301,6 +4305,7 @@
43014305
buildSettings = {
43024306
CLANG_ENABLE_MODULES = YES;
43034307
CLANG_ENABLE_OBJC_ARC = YES;
4308+
CODE_SIGN_IDENTITY = "-";
43044309
HEADER_SEARCH_PATHS = "";
43054310
LD_RUNPATH_SEARCH_PATHS = (
43064311
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
@@ -4319,6 +4324,7 @@
43194324
buildSettings = {
43204325
CLANG_ENABLE_MODULES = YES;
43214326
CLANG_ENABLE_OBJC_ARC = YES;
4327+
CODE_SIGN_IDENTITY = "-";
43224328
HEADER_SEARCH_PATHS = "";
43234329
LD_RUNPATH_SEARCH_PATHS = (
43244330
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
@@ -4342,6 +4348,7 @@
43424348
CLANG_ENABLE_OBJC_WEAK = YES;
43434349
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
43444350
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
4351+
CODE_SIGN_IDENTITY = "-";
43454352
CODE_SIGN_STYLE = Automatic;
43464353
GCC_C_LANGUAGE_STANDARD = gnu11;
43474354
HEADER_SEARCH_PATHS = "";
@@ -4365,6 +4372,7 @@
43654372
CLANG_ENABLE_OBJC_WEAK = YES;
43664373
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
43674374
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
4375+
CODE_SIGN_IDENTITY = "-";
43684376
CODE_SIGN_STYLE = Automatic;
43694377
GCC_C_LANGUAGE_STANDARD = gnu11;
43704378
HEADER_SEARCH_PATHS = "";

Foundation.xcodeproj/xcshareddata/xcschemes/CFURLSessionInterface.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1130"
3+
LastUpgradeVersion = "1310"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Foundation.xcodeproj/xcshareddata/xcschemes/CFXMLInterface.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1130"
3+
LastUpgradeVersion = "1310"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Foundation.xcodeproj/xcshareddata/xcschemes/CoreFoundation.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1130"
3+
LastUpgradeVersion = "1310"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "NO"

Foundation.xcodeproj/xcshareddata/xcschemes/GenerateTestFixtures.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1130"
3+
LastUpgradeVersion = "1310"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Foundation.xcodeproj/xcshareddata/xcschemes/SwiftFoundation.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1130"
3+
LastUpgradeVersion = "1310"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "NO"

Foundation.xcodeproj/xcshareddata/xcschemes/SwiftFoundationNetworking.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1130"
3+
LastUpgradeVersion = "1310"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Foundation.xcodeproj/xcshareddata/xcschemes/SwiftFoundationXML.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1130"
3+
LastUpgradeVersion = "1310"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Foundation.xcodeproj/xcshareddata/xcschemes/TestFoundation.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1130"
3+
LastUpgradeVersion = "1310"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "NO"

Foundation.xcodeproj/xcshareddata/xcschemes/plutil.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1130"
3+
LastUpgradeVersion = "1310"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "NO"

Foundation.xcodeproj/xcshareddata/xcschemes/xdgTestHelper.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1130"
3+
LastUpgradeVersion = "1310"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Sources/Foundation/Process.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ open class Process: NSObject {
11441144
// convenience; create and launch
11451145
open class func launchedProcess(launchPath path: String, arguments: [String]) -> Process {
11461146
let process = Process()
1147-
process.launchPath = path
1147+
process.executableURL = URL(fileURLWithPath:path)
11481148
process.arguments = arguments
11491149
process.launch()
11501150

Tests/Foundation/Tests/TestProcess.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class TestProcess : XCTestCase {
1818
// Fallback on earlier versions
1919
process.launchPath = executableURL.path
2020
}
21-
XCTAssertEqual(executableURL.path, process.launchPath)
21+
XCTAssertEqual(process.launchPath, executableURL.path)
2222
process.arguments = ["--exit", "0"]
2323
try process.run()
2424
process.waitUntilExit()
@@ -971,7 +971,12 @@ internal func runTask(_ arguments: [String], environment: [String: String]? = ni
971971
let process = Process()
972972

973973
var arguments = arguments
974-
process.launchPath = arguments.removeFirst()
974+
if #available(OSX 10.13, *) {
975+
process.executableURL = URL(fileURLWithPath:arguments.removeFirst())
976+
} else {
977+
// Fallback on earlier versions
978+
process.launchPath = arguments.removeFirst()
979+
}
975980
process.arguments = arguments
976981
// Darwin Foundation doesnt allow .environment to be set to nil although the documentation
977982
// says it is an optional. https://developer.apple.com/documentation/foundation/process/1409412-environment

0 commit comments

Comments
 (0)