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

Fix warnings about NSStringPboardType being deprecated in macOS 10.14 #3022

Closed
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@ajh17

ajh17 commented Jun 16, 2018

I got warnings about NSStringPboardType being deprecated when compiling vim in macOS 10.14.

You can wait to merge this when macOS 10.14 is officially released.

The suggested replacement to use by Apple is the "NSPasteboardTypeString", which as far as I know and tested, work the same as the older type.

Here are the warnings for reference:


os_macosx.m:67:6: warning: 'NSStringPboardType' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
            NSStringPboardType, nil];
            ^~~~~~~~~~~~~~~~~~
            NSPasteboardTypeString
/System/Library/Frameworks/AppKit.framework/Headers/NSPasteboard.h:320:32: note: 'NSStringPboardType' has been explicitly marked deprecated here
APPKIT_EXTERN NSPasteboardType NSStringPboardType NS_DEPRECATED_WITH_REPLACEMENT_MAC("NSPasteboardTypeString", 10_0, 10_14);
                               ^
os_macosx.m:98:22: warning: 'NSStringPboardType' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
                [[pb stringForType:NSStringPboardType] mutableCopy];
                                   ^~~~~~~~~~~~~~~~~~
                                   NSPasteboardTypeString
/System/Library/Frameworks/AppKit.framework/Headers/NSPasteboard.h:320:32: note: 'NSStringPboardType' has been explicitly marked deprecated here
APPKIT_EXTERN NSPasteboardType NSStringPboardType NS_DEPRECATED_WITH_REPLACEMENT_MAC("NSPasteboardTypeString", 10_0, 10_14);
                               ^
os_macosx.m:182:3: warning: 'NSStringPboardType' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
                NSStringPboardType, nil];
                ^~~~~~~~~~~~~~~~~~
                NSPasteboardTypeString
/System/Library/Frameworks/AppKit.framework/Headers/NSPasteboard.h:320:32: note: 'NSStringPboardType' has been explicitly marked deprecated here
APPKIT_EXTERN NSPasteboardType NSStringPboardType NS_DEPRECATED_WITH_REPLACEMENT_MAC("NSPasteboardTypeString", 10_0, 10_14);
                               ^
os_macosx.m:189:31: warning: 'NSStringPboardType' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
        [pb setString:string forType:NSStringPboardType];
                                     ^~~~~~~~~~~~~~~~~~
                                     NSPasteboardTypeString
/System/Library/Frameworks/AppKit.framework/Headers/NSPasteboard.h:320:32: note: 'NSStringPboardType' has been explicitly marked deprecated here
APPKIT_EXTERN NSPasteboardType NSStringPboardType NS_DEPRECATED_WITH_REPLACEMENT_MAC("NSPasteboardTypeString", 10_0, 10_14);
                               ^
4 warnings generated.
Fix warnings about NSStringPboardType being deprecated in macOS 10.14
Use the replacement NSPasteboardTypeString instead, which was introduced
in Mac OS X 10.6 and is suggested as a replacement for
NSStringPboardType.
@chdiza

This comment has been minimized.

Show comment
Hide comment
@chdiza

chdiza Jun 16, 2018

Is this going to break compilation on older versions of macOS?

chdiza commented Jun 16, 2018

Is this going to break compilation on older versions of macOS?

@ajh17

This comment has been minimized.

Show comment
Hide comment
@ajh17

ajh17 Jun 16, 2018

On systems older than OS X 10.6.

If needed, I can check for OS X < 10.6 and use the older type to maintain compatibility.

ajh17 commented Jun 16, 2018

On systems older than OS X 10.6.

If needed, I can check for OS X < 10.6 and use the older type to maintain compatibility.

@codecov-io

This comment has been minimized.

Show comment
Hide comment
@codecov-io

codecov-io Jun 16, 2018

Codecov Report

Merging #3022 into master will increase coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3022      +/-   ##
==========================================
+ Coverage   75.83%   75.86%   +0.03%     
==========================================
  Files          92       92              
  Lines      135320   135320              
==========================================
+ Hits       102614   102665      +51     
+ Misses      32706    32655      -51
Impacted Files Coverage Δ
src/version.c 81.42% <0%> (-0.96%) ⬇️
src/channel.c 83.13% <0%> (-0.08%) ⬇️
src/syntax.c 78.4% <0%> (+0.02%) ⬆️
src/term.c 59.84% <0%> (+0.05%) ⬆️
src/screen.c 76.68% <0%> (+0.06%) ⬆️
src/if_xcmdsrv.c 84.35% <0%> (+0.17%) ⬆️
src/os_unix.c 54.43% <0%> (+0.18%) ⬆️
src/gui_gtk_x11.c 47.98% <0%> (+0.19%) ⬆️
src/gui.c 49.56% <0%> (+0.41%) ⬆️
src/window.c 82.22% <0%> (+0.51%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc5020a...7f5ecbc. Read the comment docs.

codecov-io commented Jun 16, 2018

Codecov Report

Merging #3022 into master will increase coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3022      +/-   ##
==========================================
+ Coverage   75.83%   75.86%   +0.03%     
==========================================
  Files          92       92              
  Lines      135320   135320              
==========================================
+ Hits       102614   102665      +51     
+ Misses      32706    32655      -51
Impacted Files Coverage Δ
src/version.c 81.42% <0%> (-0.96%) ⬇️
src/channel.c 83.13% <0%> (-0.08%) ⬇️
src/syntax.c 78.4% <0%> (+0.02%) ⬆️
src/term.c 59.84% <0%> (+0.05%) ⬆️
src/screen.c 76.68% <0%> (+0.06%) ⬆️
src/if_xcmdsrv.c 84.35% <0%> (+0.17%) ⬆️
src/os_unix.c 54.43% <0%> (+0.18%) ⬆️
src/gui_gtk_x11.c 47.98% <0%> (+0.19%) ⬆️
src/gui.c 49.56% <0%> (+0.41%) ⬆️
src/window.c 82.22% <0%> (+0.51%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc5020a...7f5ecbc. Read the comment docs.

@chdiza

This comment has been minimized.

Show comment
Hide comment
@chdiza

chdiza Jun 16, 2018

If needed, I can check for OS X < 10.6 and use the older type to maintain compatibility.

Yes.

chdiza commented Jun 16, 2018

If needed, I can check for OS X < 10.6 and use the older type to maintain compatibility.

Yes.

@ajh17

This comment has been minimized.

Show comment
Hide comment
@ajh17

ajh17 Jun 16, 2018

Done. I don't have a system with 10.5 or older though so I can't guarantee that it doesn't break compilation on 10.5 or older.

ajh17 commented Jun 16, 2018

Done. I don't have a system with 10.5 or older though so I can't guarantee that it doesn't break compilation on 10.5 or older.

@kencu

This comment has been minimized.

Show comment
Hide comment
@kencu

kencu Oct 7, 2018

Hi! Turns out this does break 10.5 and older, and over at MacPorts we have some avid users of those older PPC machines that are still humming along pleasantly, and who love vim. Please see https://trac.macports.org/ticket/56994 and macports/macports-ports#2740

I have always found Apple's nomenclature for this rather vague and non-obvious, but the macro you want to use to see if you can use features that exist only in a newer SDK would be this:

#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
   do_new_sdk_stuff();
#else
    do_old_sdk_stuff();
#endif

kencu commented Oct 7, 2018

Hi! Turns out this does break 10.5 and older, and over at MacPorts we have some avid users of those older PPC machines that are still humming along pleasantly, and who love vim. Please see https://trac.macports.org/ticket/56994 and macports/macports-ports#2740

I have always found Apple's nomenclature for this rather vague and non-obvious, but the macro you want to use to see if you can use features that exist only in a newer SDK would be this:

#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
   do_new_sdk_stuff();
#else
    do_old_sdk_stuff();
#endif
@ajh17

This comment has been minimized.

Show comment
Hide comment
@ajh17

ajh17 Oct 7, 2018

@kencu: Thanks for the heads up. You're right, Apple wasn't really clear on which macro to use and I no longer had a 10.5 system to test it on.

Here's a patch that uses your suggestion, please test if you do have access to a 10.5 system or older:

diff --git a/src/os_macosx.m b/src/os_macosx.m
index 752bdae11..50ca361fb 100644
--- a/src/os_macosx.m
+++ b/src/os_macosx.m
@@ -63,7 +63,7 @@ clip_mch_request_selection(VimClipboard *cbd)
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
     NSPasteboard *pb = [NSPasteboard generalPasteboard];
-#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
     NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
 	    NSPasteboardTypeString, nil];
 #else
@@ -99,7 +99,7 @@ clip_mch_request_selection(VimClipboard *cbd)
     {
 	/* Use NSPasteboardTypeString.  The motion type is detected automatically.
 	 */
-#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
 	NSMutableString *mstring =
 		[[pb stringForType:NSPasteboardTypeString] mutableCopy];
 #else
@@ -188,7 +188,7 @@ clip_mch_set_selection(VimClipboard *cbd)
 
 	/* See clip_mch_request_selection() for info on pasteboard types. */
 	NSPasteboard *pb = [NSPasteboard generalPasteboard];
-#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
 	NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
 		NSPasteboardTypeString, nil];
 #else
@@ -201,7 +201,7 @@ clip_mch_set_selection(VimClipboard *cbd)
 	NSArray *plist = [NSArray arrayWithObjects:motion, string, nil];
 	[pb setPropertyList:plist forType:VimPboardType];
 
-#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
 	[pb setString:string forType:NSPasteboardTypeString];
 #else
 	[pb setString:string forType:NSStringPboardType];

ajh17 commented Oct 7, 2018

@kencu: Thanks for the heads up. You're right, Apple wasn't really clear on which macro to use and I no longer had a 10.5 system to test it on.

Here's a patch that uses your suggestion, please test if you do have access to a 10.5 system or older:

diff --git a/src/os_macosx.m b/src/os_macosx.m
index 752bdae11..50ca361fb 100644
--- a/src/os_macosx.m
+++ b/src/os_macosx.m
@@ -63,7 +63,7 @@ clip_mch_request_selection(VimClipboard *cbd)
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
     NSPasteboard *pb = [NSPasteboard generalPasteboard];
-#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
     NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
 	    NSPasteboardTypeString, nil];
 #else
@@ -99,7 +99,7 @@ clip_mch_request_selection(VimClipboard *cbd)
     {
 	/* Use NSPasteboardTypeString.  The motion type is detected automatically.
 	 */
-#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
 	NSMutableString *mstring =
 		[[pb stringForType:NSPasteboardTypeString] mutableCopy];
 #else
@@ -188,7 +188,7 @@ clip_mch_set_selection(VimClipboard *cbd)
 
 	/* See clip_mch_request_selection() for info on pasteboard types. */
 	NSPasteboard *pb = [NSPasteboard generalPasteboard];
-#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
 	NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
 		NSPasteboardTypeString, nil];
 #else
@@ -201,7 +201,7 @@ clip_mch_set_selection(VimClipboard *cbd)
 	NSArray *plist = [NSArray arrayWithObjects:motion, string, nil];
 	[pb setPropertyList:plist forType:VimPboardType];
 
-#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
 	[pb setString:string forType:NSPasteboardTypeString];
 #else
 	[pb setString:string forType:NSStringPboardType];
@ajh17

This comment has been minimized.

Show comment
Hide comment
@ajh17

ajh17 Oct 7, 2018

I can't seem to re-open this PR, but @brammool: Can you please include the patch?

Thanks!

ajh17 commented Oct 7, 2018

I can't seem to re-open this PR, but @brammool: Can you please include the patch?

Thanks!

@kencu

This comment has been minimized.

Show comment
Hide comment
@kencu

kencu Oct 7, 2018

Great! - that patch looks identical to mine, except for the MacPorts default patchlevel. macports/macports-ports@b918f32#diff-23aa6c80a367a2dec5cedb6c1cffe901. I confirm it works on 10.4 and 10.5, and also does the right thing on 10.14

kencu commented Oct 7, 2018

Great! - that patch looks identical to mine, except for the MacPorts default patchlevel. macports/macports-ports@b918f32#diff-23aa6c80a367a2dec5cedb6c1cffe901. I confirm it works on 10.4 and 10.5, and also does the right thing on 10.14

brammool added a commit that referenced this pull request Oct 8, 2018

patch 8.1.0467: cannot build with Mac OS X 10.5
Problem:    Cannot build with Mac OS X 10.5.
Solution:   Change #ifdef into #if. (Akshay Hegde, closes #3022)

ntak added a commit to ntak/vim that referenced this pull request Oct 12, 2018

patch 8.1.0467: cannot build with Mac OS X 10.5
Problem:    Cannot build with Mac OS X 10.5.
Solution:   Change #ifdef into #if. (Akshay Hegde, closes vim#3022)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment