Dive into the world of programming languages used for app development.

Posts under General subtopic

Post

Replies

Boosts

Views

Activity

Swift class in ObjC Project : "Receiver 'MySwift' for class message is a forward declaration" error even after adding @obj and open prefixes
After spending a few hours to integrate swift files successfully to my Objective-C based iOS project, I face the next challenge now :In one of my Objective-C class header (Say, MyObjCClass.h), I do the forward declaration for MySwiftClass.In the respective .m file, I define an instance of MySwiftClass _swiftClassInstance.In the init method of MyObjCClass, I try to instantiate it as follows : _swiftClassInstance = [[MySwiftClass alloc] init]; When I compile the code, I get 2 errors :Receiver 'SocketIOClient' for class message is a forward declarationReceiver type 'SocketIOClient' for instance message is a forward declarationI have already done following :Imported MyProject-Swift.h in the MyObjCClass.m file.Marked the swift class with @objc and openSo, what can be the reason for the issue?
3
0
7.9k
May ’22
How to delete WKWebview's Cache in iOS8?
Dear Apple,The requirement of my application is that can delete cache/cookies in WKWebview. I tried somthing and it working as well in iOS 9 upwards. But there are no way to do it in iOS 8. Please let me know if there is a way to remove cache/cookies in iOS 8 or it can not remove?#Note: I want to remove cookies immediately, ie stay at WKWebview but click url to another site it will delete.Thanks,Phong Tran.
2
0
4.5k
May ’22
Get SSID of current network for iOS 15.5
Below snippet is used to fetch SSID of current network. __block NSString *ssid = nil; dispatch_semaphore_t sem = dispatch_semaphore_create(0); [NEHotspotNetwork fetchCurrentWithCompletionHandler:^(NEHotspotNetwork * _Nullable currentNetwork) {       if( currentNetwork != nil) {         ssid = [currentNetwork SSID];       }       dispatch_semaphore_signal(sem); }]; We are getting proper currentNetwork information in the block. But when ssid is fetched from outside the block, it is getting invalid after the block exits. We are getting bad NSString object. This issue occurs only on iOS 15.5 beta version or later. Same code snippet worked perfectly for earlier versions of iOS. Can you help why it occurs only on iOS 15.5 or later versions? Note: Requirement according to https://developer.apple.com/forums/thread/679038 is fulfilled
3
0
820
Apr ’22
Programmatic way to find the language of an application
Hello, I would like to know if there is any way to programmatically find out the current language of an application(either budle info, plist,any function from CoreFoundation, etc ). Only information I found relating to this is in CFBundleDevelopmentRegion from plist of the app but its not reliable in all cases. We are coding in C++ but we can also run Objective-C code. Thank you in advance!
9
0
3.4k
Apr ’22
OpenVPNProvider
am using to NETunnelProvider in a openvpn client that is bridged in react-native but no luck there .. the connection to server keep disconnect every time. the Network Extension is configurated. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>NSExtension</key> <dict> <key>NSExtensionPointIdentifier</key> <string>com.apple.networkextension.packet-tunnel</string> <key>NSExtensionPrincipalClass</key> <string>$(PRODUCT_MODULE_NAME).PacketTunnelProvider</string> </dict> </dict> </plist> typescript side is getting events from vpnStateObserver connecting ... Object { "message": "The VPN is in the process of connecting", "state": 1, } Object { "message": "The VPN is in the process of disconnecting", "state": 3, } Object { "message": "The VPN is disconnected", "state": 0, } tunel: type = plugin identifier = xxxxxxxxx-6E77-47BA-B41C-52251D2D2C47 serverAddress = x.x.x.x:1194 identityDataImported = NO disconnectOnSleep = NO disconnectOnIdle = NO disconnectOnIdleTimeout = 0 disconnectOnWake = NO disconnectOnWakeTimeout = 0 includeAllNetworks = YES excludeLocalNetworks = NO enforceRoutes = NO authenticationMethod = 0 reassertTimeout = 0 providerConfiguration = { ovpn = {length = 8437, bytes = 0x636c6965 6e740a64 65762074 756e0a70 ... 732d6175 74683e0a } } providerBundleIdentifier = dev.***.xxxxxxx.vpn
1
0
634
Mar ’22
Cannot sign app
I am trying to sign an ios app using company cert. I get the below error.  /usr/bin/codesign --force --sign 6A29F3EED12E0F0152A7C7510E35EC72623C2F85 --entitlements /Users/afonsomiu/Library/Developer/Xcode/DerivedData/Firma-btcqegchqjjqvuevtxbkjydqgqkp/Build/Intermediates.noindex/ArchiveIntermediates/Firma/IntermediateBuildFilesPath/Firma.build/Release-iphoneos/Firma.build/Firma.app.xcent /Users/afonsomiu/Library/Developer/Xcode/DerivedData/Firma-btcqegchqjjqvuevtxbkjydqgqkp/Build/Intermediates.noindex/ArchiveIntermediates/Firma/InstallationBuildProductsLocation/Applications/Firma.app Please help.
1
0
718
Mar ’22
Memory allocation and deallocation issues in c++ code
I am porting an image processing app using a camera developed by Android to IOS, and try to use C++ code used by Android in IOS. Install the necessary library and link the target c++ code using objective-c wrapper. The problem is that when a function with particularly large number of memory allocation/release ends in the C++ code, an error is definitely issued as the local variables are released. Error: Corrupt value: 0x3fc93ba18499360a GBCare(20641,0x16bcfb000) malloc: *** set a breakpoint in malloc_error_break to debug GBCare(20641,0x16bcfb000) malloc: Incorrect checksum for freed object 0x11556d1e0: probably modified after being freed. Corrupt value: 0x3fc93ba18499360a Additionally, the same error occurs sometimes at the location where the type of memory is allocated (e.g., cv::Mat.clone, cv:Mat::zeros) and we checked that the correct parameter was included. I don't know what it means, but if you do it as shown in the picture below in Product-Scheme-Edit Scheme, it works normally without errors. I think it's not a code problem, but a problem that occurs in the environment setting, so please help me. Development environment: Xcode 13.2.1 / Swift5 / OpenCV 4.3
2
0
2.5k
Feb ’22
objc_copyClassList() not enumerable?
This is a derivative of this and this. On iOS 15(.3.1), if I just try to fetch and enumerate the classes of the objc runtime, waiting until viewDidAppear() to make sure there wasn't some initialization issue: var count = UInt32(0) var classList = objc_copyClassList(&count)! print("COUNT \(count)") print("CLASS LIST \(classList)") for i in 0..<Int(count) { print("\(i)") classList[i] } produces the following before a Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1820e0cdc) COUNT 28353 CLASS LIST 0x000000010bf24000 0 1 2 2022-02-17 16:24:02.977904-0800 TWiG V[2504:705046] *** NSForwarding: warning: object 0x1dbd32148 of class '__NSGenericDeallocHandler' does not implement methodSignatureForSelector: -- trouble ahead 2022-02-17 16:24:02.978001-0800 TWiG V[2504:705046] *** NSForwarding: warning: object 0x1dbd32148 of class '__NSGenericDeallocHandler' does not implement doesNotRecognizeSelector: -- abort I don't know how to do any less with it than just fetching the value. I'm not trying to print it or anything, and yet it still fails. Is there some magic I'm missing? Why have the API if the results crash your program? If the issue is legit, it would be nice of the docs pointed out a workaround, or at least the proper way to cope with the result. (I do not have hardened runtime turned on, XCode 13.2.1)
3
0
1.5k
Feb ’22
Use of undeclared identifier
I'm working on an objective c based macos project for years, containing numerous Objective C classes. For some reason, in a particular class I can bind new IBOutlets in Interface builder, but in my .m file I get always the error: Use of undeclared identifier ' my buttoname ' Someone any idea? I'm working with: XCode 13.2.1
1
0
3.5k
Feb ’22
how to retrieve a writing direction?
I'd like to be able to retrieve a writing direction from an arbitrary string... but how? I have tried getGlyphsInRange:glyphs:properties:characterIndexes:bidiLevels:    NSLayoutManager* layoutManager = [[NSLayoutManager alloc] init];   NSTextStorage* textStorage = [[NSTextStorage alloc] initWithString:@"abc"];   [textStorage addLayoutManager:layoutManager];   NSRange stringRange=NSMakeRange(0,[@"abc" length]);   NSMutableData* glyphData=[NSMutableData dataWithLength:sizeof(CGGlyph)*stringRange.length+1];   CGGlyph* glyphs=(CGGlyph*)[glyphData mutableBytes];       unsigned char *bidiLevelBuffer = calloc([@"abc" length], sizeof(unsigned char));   int glyphCount = (int)[layoutManager getGlyphsInRange:stringRange                           glyphs:glyphs properties:NULL                      characterIndexes:NULL                         bidiLevels:bidiLevelBuffer];       NSLog(@"--- %i, \"%s\"", glyphCount, bidiLevelBuffer); with the result: 2021-12-29 10:39:54.694104+0300 aTypeTrainer4Mac[61412:3479843] --- 3, "" ... any ideas?
2
0
1.1k
Jan ’22
Using UNNotificationCenterCalendarTrigger did not receive a local notification(s) repeat on each day for every hour
We did not get the local notification on next day for every hour using UNNotificationCenterCalendarTrigger. What we have currently, the current day receiving local notification(s) on repeated hour interval, but from next day on-words does not received notification using UserNotifications framework, but with deprecated UILocalNotification framework notification delivered with the help of fireDate, repeatCalendar and repeatInterval property.  So is there any exact replacement for fireDate, repeatCalendar and repeatInterval property of UILocalNotification framework with UserNotifications framework.
0
0
585
Dec ’21
Objective-C Syntax for a Block that has a Block as a Parameter?
I'm not sure this is even possible (and I'm sure there will be questions as to why) but I'm curious how one could define a block that takes a block as a parameter? For instance... MyFunctionWithSuccess:(void(^)((void(^)(NSString* value))blockAsParameter)success This of course doesn't work. The only thing I could find is on StackOverflow but I think in this case it returns a block. Regardless the syntax throws a compiler error.. StackOverflow - Syntax to define a Block that takes a Block and returns a Block in Objective-C There it says to define it as : void (^(^complexBlock)(void (^)(void)))(void) However this throws a "Type-id cannot have a name" which it complains about the ^complexBlock part. Again it just may be that this is not possible and bad to do. However I'd like to confirm that it is or isn't.
1
0
547
Dec ’21
Swift class in ObjC Project : "Receiver 'MySwift' for class message is a forward declaration" error even after adding @obj and open prefixes
After spending a few hours to integrate swift files successfully to my Objective-C based iOS project, I face the next challenge now :In one of my Objective-C class header (Say, MyObjCClass.h), I do the forward declaration for MySwiftClass.In the respective .m file, I define an instance of MySwiftClass _swiftClassInstance.In the init method of MyObjCClass, I try to instantiate it as follows : _swiftClassInstance = [[MySwiftClass alloc] init]; When I compile the code, I get 2 errors :Receiver 'SocketIOClient' for class message is a forward declarationReceiver type 'SocketIOClient' for instance message is a forward declarationI have already done following :Imported MyProject-Swift.h in the MyObjCClass.m file.Marked the swift class with @objc and openSo, what can be the reason for the issue?
Replies
3
Boosts
0
Views
7.9k
Activity
May ’22
How to delete WKWebview's Cache in iOS8?
Dear Apple,The requirement of my application is that can delete cache/cookies in WKWebview. I tried somthing and it working as well in iOS 9 upwards. But there are no way to do it in iOS 8. Please let me know if there is a way to remove cache/cookies in iOS 8 or it can not remove?#Note: I want to remove cookies immediately, ie stay at WKWebview but click url to another site it will delete.Thanks,Phong Tran.
Replies
2
Boosts
0
Views
4.5k
Activity
May ’22
Get SSID of current network for iOS 15.5
Below snippet is used to fetch SSID of current network. __block NSString *ssid = nil; dispatch_semaphore_t sem = dispatch_semaphore_create(0); [NEHotspotNetwork fetchCurrentWithCompletionHandler:^(NEHotspotNetwork * _Nullable currentNetwork) {       if( currentNetwork != nil) {         ssid = [currentNetwork SSID];       }       dispatch_semaphore_signal(sem); }]; We are getting proper currentNetwork information in the block. But when ssid is fetched from outside the block, it is getting invalid after the block exits. We are getting bad NSString object. This issue occurs only on iOS 15.5 beta version or later. Same code snippet worked perfectly for earlier versions of iOS. Can you help why it occurs only on iOS 15.5 or later versions? Note: Requirement according to https://developer.apple.com/forums/thread/679038 is fulfilled
Replies
3
Boosts
0
Views
820
Activity
Apr ’22
How to logout apple account on ios devices
Hello everyone, I need an automation to logout appleid from iphone/ipads. In my scenario, an iphone/ipad device can be used by more than one people. So I want to logout the apple account in device which belongs to previous user So new user can not see the previous user's account. How can i achieve that in programmatically or other solutions?
Replies
1
Boosts
0
Views
1.5k
Activity
Apr ’22
Programmatic way to find the language of an application
Hello, I would like to know if there is any way to programmatically find out the current language of an application(either budle info, plist,any function from CoreFoundation, etc ). Only information I found relating to this is in CFBundleDevelopmentRegion from plist of the app but its not reliable in all cases. We are coding in C++ but we can also run Objective-C code. Thank you in advance!
Replies
9
Boosts
0
Views
3.4k
Activity
Apr ’22
OpenVPNProvider
am using to NETunnelProvider in a openvpn client that is bridged in react-native but no luck there .. the connection to server keep disconnect every time. the Network Extension is configurated. &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; &lt;plist version="1.0"&gt; &lt;dict&gt; &lt;key&gt;NSExtension&lt;/key&gt; &lt;dict&gt; &lt;key&gt;NSExtensionPointIdentifier&lt;/key&gt; &lt;string&gt;com.apple.networkextension.packet-tunnel&lt;/string&gt; &lt;key&gt;NSExtensionPrincipalClass&lt;/key&gt; &lt;string&gt;$(PRODUCT_MODULE_NAME).PacketTunnelProvider&lt;/string&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;/plist&gt; typescript side is getting events from vpnStateObserver connecting ... Object { "message": "The VPN is in the process of connecting", "state": 1, } Object { "message": "The VPN is in the process of disconnecting", "state": 3, } Object { "message": "The VPN is disconnected", "state": 0, } tunel: type = plugin identifier = xxxxxxxxx-6E77-47BA-B41C-52251D2D2C47 serverAddress = x.x.x.x:1194 identityDataImported = NO disconnectOnSleep = NO disconnectOnIdle = NO disconnectOnIdleTimeout = 0 disconnectOnWake = NO disconnectOnWakeTimeout = 0 includeAllNetworks = YES excludeLocalNetworks = NO enforceRoutes = NO authenticationMethod = 0 reassertTimeout = 0 providerConfiguration = { ovpn = {length = 8437, bytes = 0x636c6965 6e740a64 65762074 756e0a70 ... 732d6175 74683e0a } } providerBundleIdentifier = dev.***.xxxxxxx.vpn
Replies
1
Boosts
0
Views
634
Activity
Mar ’22
Cannot sign app
I am trying to sign an ios app using company cert. I get the below error.  /usr/bin/codesign --force --sign 6A29F3EED12E0F0152A7C7510E35EC72623C2F85 --entitlements /Users/afonsomiu/Library/Developer/Xcode/DerivedData/Firma-btcqegchqjjqvuevtxbkjydqgqkp/Build/Intermediates.noindex/ArchiveIntermediates/Firma/IntermediateBuildFilesPath/Firma.build/Release-iphoneos/Firma.build/Firma.app.xcent /Users/afonsomiu/Library/Developer/Xcode/DerivedData/Firma-btcqegchqjjqvuevtxbkjydqgqkp/Build/Intermediates.noindex/ArchiveIntermediates/Firma/InstallationBuildProductsLocation/Applications/Firma.app Please help.
Replies
1
Boosts
0
Views
718
Activity
Mar ’22
Memory allocation and deallocation issues in c++ code
I am porting an image processing app using a camera developed by Android to IOS, and try to use C++ code used by Android in IOS. Install the necessary library and link the target c++ code using objective-c wrapper. The problem is that when a function with particularly large number of memory allocation/release ends in the C++ code, an error is definitely issued as the local variables are released. Error: Corrupt value: 0x3fc93ba18499360a GBCare(20641,0x16bcfb000) malloc: *** set a breakpoint in malloc_error_break to debug GBCare(20641,0x16bcfb000) malloc: Incorrect checksum for freed object 0x11556d1e0: probably modified after being freed. Corrupt value: 0x3fc93ba18499360a Additionally, the same error occurs sometimes at the location where the type of memory is allocated (e.g., cv::Mat.clone, cv:Mat::zeros) and we checked that the correct parameter was included. I don't know what it means, but if you do it as shown in the picture below in Product-Scheme-Edit Scheme, it works normally without errors. I think it's not a code problem, but a problem that occurs in the environment setting, so please help me. Development environment: Xcode 13.2.1 / Swift5 / OpenCV 4.3
Replies
2
Boosts
0
Views
2.5k
Activity
Feb ’22
objc_copyClassList() not enumerable?
This is a derivative of this and this. On iOS 15(.3.1), if I just try to fetch and enumerate the classes of the objc runtime, waiting until viewDidAppear() to make sure there wasn't some initialization issue: var count = UInt32(0) var classList = objc_copyClassList(&count)! print("COUNT \(count)") print("CLASS LIST \(classList)") for i in 0..<Int(count) { print("\(i)") classList[i] } produces the following before a Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1820e0cdc) COUNT 28353 CLASS LIST 0x000000010bf24000 0 1 2 2022-02-17 16:24:02.977904-0800 TWiG V[2504:705046] *** NSForwarding: warning: object 0x1dbd32148 of class '__NSGenericDeallocHandler' does not implement methodSignatureForSelector: -- trouble ahead 2022-02-17 16:24:02.978001-0800 TWiG V[2504:705046] *** NSForwarding: warning: object 0x1dbd32148 of class '__NSGenericDeallocHandler' does not implement doesNotRecognizeSelector: -- abort I don't know how to do any less with it than just fetching the value. I'm not trying to print it or anything, and yet it still fails. Is there some magic I'm missing? Why have the API if the results crash your program? If the issue is legit, it would be nice of the docs pointed out a workaround, or at least the proper way to cope with the result. (I do not have hardened runtime turned on, XCode 13.2.1)
Replies
3
Boosts
0
Views
1.5k
Activity
Feb ’22
Use of undeclared identifier
I'm working on an objective c based macos project for years, containing numerous Objective C classes. For some reason, in a particular class I can bind new IBOutlets in Interface builder, but in my .m file I get always the error: Use of undeclared identifier ' my buttoname ' Someone any idea? I'm working with: XCode 13.2.1
Replies
1
Boosts
0
Views
3.5k
Activity
Feb ’22
how to retrieve a writing direction?
I'd like to be able to retrieve a writing direction from an arbitrary string... but how? I have tried getGlyphsInRange:glyphs:properties:characterIndexes:bidiLevels:    NSLayoutManager* layoutManager = [[NSLayoutManager alloc] init];   NSTextStorage* textStorage = [[NSTextStorage alloc] initWithString:@"abc"];   [textStorage addLayoutManager:layoutManager];   NSRange stringRange=NSMakeRange(0,[@"abc" length]);   NSMutableData* glyphData=[NSMutableData dataWithLength:sizeof(CGGlyph)*stringRange.length+1];   CGGlyph* glyphs=(CGGlyph*)[glyphData mutableBytes];       unsigned char *bidiLevelBuffer = calloc([@"abc" length], sizeof(unsigned char));   int glyphCount = (int)[layoutManager getGlyphsInRange:stringRange                           glyphs:glyphs properties:NULL                      characterIndexes:NULL                         bidiLevels:bidiLevelBuffer];       NSLog(@"--- %i, \"%s\"", glyphCount, bidiLevelBuffer); with the result: 2021-12-29 10:39:54.694104+0300 aTypeTrainer4Mac[61412:3479843] --- 3, "" ... any ideas?
Replies
2
Boosts
0
Views
1.1k
Activity
Jan ’22
Using UNNotificationCenterCalendarTrigger did not receive a local notification(s) repeat on each day for every hour
We did not get the local notification on next day for every hour using UNNotificationCenterCalendarTrigger. What we have currently, the current day receiving local notification(s) on repeated hour interval, but from next day on-words does not received notification using UserNotifications framework, but with deprecated UILocalNotification framework notification delivered with the help of fireDate, repeatCalendar and repeatInterval property.  So is there any exact replacement for fireDate, repeatCalendar and repeatInterval property of UILocalNotification framework with UserNotifications framework.
Replies
0
Boosts
0
Views
585
Activity
Dec ’21
Objective-C Syntax for a Block that has a Block as a Parameter?
I'm not sure this is even possible (and I'm sure there will be questions as to why) but I'm curious how one could define a block that takes a block as a parameter? For instance... MyFunctionWithSuccess:(void(^)((void(^)(NSString* value))blockAsParameter)success This of course doesn't work. The only thing I could find is on StackOverflow but I think in this case it returns a block. Regardless the syntax throws a compiler error.. StackOverflow - Syntax to define a Block that takes a Block and returns a Block in Objective-C There it says to define it as : void (^(^complexBlock)(void (^)(void)))(void) However this throws a "Type-id cannot have a name" which it complains about the ^complexBlock part. Again it just may be that this is not possible and bad to do. However I'd like to confirm that it is or isn't.
Replies
1
Boosts
0
Views
547
Activity
Dec ’21