Post

Replies

Boosts

Views

Activity

clang in XCode 14.3 'carrying over' nullability of objects (objc/c++) with _auto_type/auto [despite assert or inline if]
Hi, i noticed a bigger change in the latest clang and wanted to check if this is intentional or a beta bug. clang in XCode 14.3 is 'carrying over' nullability of objects (objc/c++) with _auto_type/auto [despite assert or inline if] In 14.2 autotype/auto made an null_unspecified ptr allowing us to downcast / unwrap an object. In 14.3 this isnt possible anymore. => Is there still a way to do 'nullability unwrapping' of any reference in C(objC/C++) tried but failed workarounds: There is an easy workaround by looking at the dereferenced type but that doesnt work with dispatch bloks as they arent dereferencable There is also a workaround with objc generics but I cant use that as there might be objects not usable as generics example The following is a sample that worked with 14.2 but throws warnings in 14.3 clang: xcrun clang -fobjc-arc -Wnullable-to-nonnull-conversion -Werror test.m #import <Foundation/Foundation.h> #include <stdio.h> #include <stddef.h> #include <stdint.h> #define typename(x) _Generic((x), /* Get the name of a type */ \ id: "id", \ default: "other") #define fmt "%20s is '%s'\n" _Pragma("clang diagnostic ignored \"-Wauto-var-id\"") int main(int argc, char *argv[]) { @autoreleasepool { int temp = 666; NSString *_Nullable s = @""; id _Nullable s2 = @""; dispatch_block_t _Nullable s3 = dispatch_block_create(0, ^{}); CFStringRef _Nullable s4 = CFSTR(""); int *_Nullable s5 = &temp; printf( fmt, "NSString (_Nullable", typename(s)); printf( fmt, "id _Nullable", typename(s2)); printf( fmt, "block _Nullable", typename(s3)); printf( fmt, "CFStringRef _Nullable", typename(s4)); printf( fmt, "int _Nullable", typename(s5)); assert(s != nil); assert(s2 != nil); assert(s3 != nil); assert(s4 != nil); assert(s5 != nil); //no modifier works if type is given // NSString *u = s; // id u2 = s2; // dispatch_block_t u3 = s3; // CFStringRef u4 = s4; // int *u5 = s5; // __auto_typeauto carries _nullable in 14.3 but not 14.2 __auto_type u = s; __auto_type u_with_default = s != nil ? s : @"DEFAULT"; __auto_type u2 = s2; __auto_type u3 = s3; __auto_type u4 = s4; __auto_type u5 = s5; //auto and decltype have the same behaviour for C++ and even if we use an inline if //Q: how can I unwrap an optional [not just objc!] NSString *_Nonnull d = u; NSString *_Nonnull d_with_default = u_with_default; id _Nonnull d2 = u2; dispatch_block_t _Nonnull d3 = u3; CFStringRef _Nonnull d4 = u4; int *_Nonnull d5 = u5; printf( "-------\n"); printf( fmt, "NSString", typename(d)); printf( fmt, "NSString", typename(d_with_default)); printf( fmt, "id", typename(d2)); printf( fmt, "block", typename(d3)); printf( fmt, "CFStringRef", typename(d4)); printf( fmt, "int", typename(d5)); } }
2
1
1k
Mar ’23
Can I set NSURLIsExcludedFromBackupKey on my whole AppGroup?
Hi, im using an app group to communicate between app and extensions. I dont want any part of the AppGroup to be backed up to iCloud/iTunes: The data shouldn't be purgable on update of app but it should also stay on device Can I apply NSURLIsExcludedFromBackupKey to the app group's root folder I get from [fileManager containerURLForSecurityApplicationGroupIdentifier:appGroupIdentifier];
1
0
645
Sep ’21
Which field does 'ITMS-90814: Missing SDK Version' relate to? (I have DTSDK* fields set already)
Hi, uploading the latest build of my app, I got the error 'ITMS-90814: Missing SDK Version' for my watch extension Now I do have the fields DTSDKBuild & DTSDKName so im confused as to what field this pertains to I submitted with XCode 11.6 last week and it worked fine and today a 11.6 submit fails :) Thanks
1
0
693
Sep ’20
How can I add platform specific code to the new cross-platform swiftUI app
XCode 12 offers a new cross-platform swiftUI app - awesome I would like to add platform specific code conditionals e.g. if(isMacos()) &#9;doLoginMacos() else &#9;doLoginIOS() or var body = macos ? ComplexNonMobileContentView() : Text("blabla mobile") or func onLoad { &#9;if(isMacos) addStatusbarItem } //note i dont even know if the new App Protocol has a onLoad ;) Happy to add fully separate AppDelegates and all too
2
0
3.9k
Jun ’20
How can I handle incoming URLS in the new cross-platform swiftUI app
XCode 12 offers a new cross-platform swiftUI app - awesome I would like to handle incoming URLs. How can I do this in the Cross Platform App? (in 'old world' id implement os' appdelegate to do this) Does App protocol provide any 'overrides' I didnt see? OR Can I somehow implement platform specific AppDelegates that then expose Environment? [same as openURLAction] but vice versa? :)]
4
0
1.5k
Jun ’20