Skip to content

Commit f30fc0b

Browse files
committed
Modernize code to not rely on deprecations and old behavior
1 parent 558c1d5 commit f30fc0b

18 files changed

+38
-23
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-Tests/FoundationBridge.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ - (BOOL)verifyAutoupdatingLocale:(NSLocale *)locale {
267267
@implementation NumberBridgingTester
268268

269269
- (BOOL)verifyKeysInRange:(NSRange)range existInDictionary:(NSDictionary *)dictionary {
270-
for (NSUInteger i = 0; i < range.length; i += 1) {
270+
for (NSUInteger i = 0; i < range.length; i++) {
271271
if (!dictionary[@(range.location + i)]) {
272272
return NO;
273273
}

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

+13-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;
@@ -3914,13 +3916,15 @@
39143916
GCC_WARN_UNUSED_FUNCTION = YES;
39153917
GCC_WARN_UNUSED_VARIABLE = YES;
39163918
LD_RUNPATH_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx";
3919+
LLVM_LTO = YES;
39173920
MACOSX_DEPLOYMENT_TARGET = 10.12;
39183921
MTL_ENABLE_DEBUG_INFO = NO;
39193922
SDKROOT = macosx;
39203923
SWIFT_COMPILATION_MODE = wholemodule;
39213924
SWIFT_FORCE_DYNAMIC_LINK_STDLIB = YES;
39223925
SWIFT_FORCE_STATIC_LINK_STDLIB = NO;
39233926
SWIFT_OPTIMIZATION_LEVEL = "-O";
3927+
SWIFT_OPTIMIZE_OBJECT_LIFETIME = YES;
39243928
VERSIONING_SYSTEM = "apple-generic";
39253929
VERSION_INFO_PREFIX = "";
39263930
};
@@ -4183,6 +4187,7 @@
41834187
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
41844188
CLANG_ENABLE_MODULES = YES;
41854189
CLANG_ENABLE_OBJC_ARC = YES;
4190+
CODE_SIGN_IDENTITY = "-";
41864191
COMBINE_HIDPI_IMAGES = YES;
41874192
FRAMEWORK_SEARCH_PATHS = "";
41884193
HEADER_SEARCH_PATHS = (
@@ -4213,6 +4218,7 @@
42134218
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
42144219
CLANG_ENABLE_MODULES = YES;
42154220
CLANG_ENABLE_OBJC_ARC = YES;
4221+
CODE_SIGN_IDENTITY = "-";
42164222
COMBINE_HIDPI_IMAGES = YES;
42174223
FRAMEWORK_SEARCH_PATHS = "";
42184224
HEADER_SEARCH_PATHS = (
@@ -4245,7 +4251,7 @@
42454251
CLANG_ENABLE_MODULES = YES;
42464252
CLANG_ENABLE_OBJC_ARC = YES;
42474253
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
4248-
CODE_SIGN_IDENTITY = "";
4254+
CODE_SIGN_IDENTITY = "-";
42494255
COMBINE_HIDPI_IMAGES = YES;
42504256
HEADER_SEARCH_PATHS = (
42514257
"$(CONFIGURATION_BUILD_DIR)/usr/local/include",
@@ -4276,7 +4282,7 @@
42764282
CLANG_ENABLE_MODULES = YES;
42774283
CLANG_ENABLE_OBJC_ARC = YES;
42784284
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
4279-
CODE_SIGN_IDENTITY = "";
4285+
CODE_SIGN_IDENTITY = "-";
42804286
COMBINE_HIDPI_IMAGES = YES;
42814287
HEADER_SEARCH_PATHS = (
42824288
"$(CONFIGURATION_BUILD_DIR)/usr/local/include",
@@ -4301,6 +4307,7 @@
43014307
buildSettings = {
43024308
CLANG_ENABLE_MODULES = YES;
43034309
CLANG_ENABLE_OBJC_ARC = YES;
4310+
CODE_SIGN_IDENTITY = "-";
43044311
HEADER_SEARCH_PATHS = "";
43054312
LD_RUNPATH_SEARCH_PATHS = (
43064313
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
@@ -4319,6 +4326,7 @@
43194326
buildSettings = {
43204327
CLANG_ENABLE_MODULES = YES;
43214328
CLANG_ENABLE_OBJC_ARC = YES;
4329+
CODE_SIGN_IDENTITY = "-";
43224330
HEADER_SEARCH_PATHS = "";
43234331
LD_RUNPATH_SEARCH_PATHS = (
43244332
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
@@ -4342,6 +4350,7 @@
43424350
CLANG_ENABLE_OBJC_WEAK = YES;
43434351
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
43444352
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
4353+
CODE_SIGN_IDENTITY = "-";
43454354
CODE_SIGN_STYLE = Automatic;
43464355
GCC_C_LANGUAGE_STANDARD = gnu11;
43474356
HEADER_SEARCH_PATHS = "";
@@ -4365,6 +4374,7 @@
43654374
CLANG_ENABLE_OBJC_WEAK = YES;
43664375
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
43674376
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
4377+
CODE_SIGN_IDENTITY = "-";
43684378
CODE_SIGN_STYLE = Automatic;
43694379
GCC_C_LANGUAGE_STANDARD = gnu11;
43704380
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)