Objective-C

RSS for tag

Objective-C is a programming language for writing iOS, iPad OS, and macOS apps.

Posts under Objective-C tag

213 Posts
Sort by:
Post not yet marked as solved
1 Replies
814 Views
Getting this error in Xcode 12.4 error: /Applications/Xcode12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lPods-PSSCore error: /Applications/Xcode12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lPods-PSSCore is not an object file (not allowed in a library) Currently using Xcode 10 but when I try to run code in Xcode 12.4 it gives this error and not able to build the project
Posted
by
Post not yet marked as solved
12 Replies
857 Views
Currently, we have a Flutter app that uses the network_info_plus plugin to connect to the Wifi network of the current iOS device our app is running on. Unfortunately, we are unable to use Bonjour on the target device that we are attempting to connect to, which acts as an AP, due to legacy device issues. Hence the reason why we use the device's Wifi IP address to interact with this device when it's connected to this device's Access Point. This plugin's iOS implementation is using a non-guaranteed way of fetching the device's Wifi IP address according to a recent DevForum post, presuming that it's en0 as seen here: - (void)enumerateWifiAddresses:(NSInteger)family usingBlock:(void (^)(struct ifaddrs *))block { struct ifaddrs *interfaces = NULL; struct ifaddrs *temp_addr = NULL; int success = 0; // retrieve the current interfaces - returns 0 on success success = getifaddrs(&interfaces); if (success == 0) { // Loop through linked list of interfaces temp_addr = interfaces; while (temp_addr != NULL) { if (temp_addr->ifa_addr->sa_family == family) { // en0 is the wifi connection on iOS if ([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"]) { block(temp_addr); } } temp_addr = temp_addr->ifa_next; } } // Free memory freeifaddrs(interfaces); } I was just wondering what an alternative Objective-C implementation would look like for fetching the actual IP address using a subnet broadcast, since the aforementioned DevForum post suggested that we get all Ethernet-like interfaces (I'm assuming those devices that are prefixed with en) and create a Socket for them bound to IP_BOUND_IF. Thank you in advance.
Posted
by
Post not yet marked as solved
2 Replies
962 Views
I am trying to replace the deprecated unarchiveObjectWithData API with unarchivedObjectOfClass. My class looks something like this Class B:< { (BOOL)supportsSecureCoding { return YES; } } Class C < { property of class B; (BOOL)supportsSecureCoding { return YES; } } Class A< { property of class B property of class c (BOOL)supportsSecureCoding { return YES; } } Tried solutions: Archive code NSData *archiveData = [NSKeyedArchiver archivedDataWithRootObject:(array of objects of type A) requiringSecureCoding:YES error:&error]; // Encrypting archiveData and writing to file Unarchive code // fetching data from file // decrypting it NSSet *classesSet = [NSSet setWithObjects: [NSMutableArray classForCoder], [A classForCoder], [NSString classForCoder], [NSNumber classForCoder], [B classForCoder], [C classForCoder] , nil]; NSKeyedUnarchiver *unArchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:decryptedData error:&error]; [unArchiver setRequiresSecureCoding:YES]; array of objects of Type A = [unArchiver decodeObjectOfClasses:classesSet forKey:NSKeyedArchiveRootObjectKey]; Issue: Unable to unarchive all the properties. Properties have nil values including properties of type NSString, BOOL, custom class Use +unarchivedObjectOfClass:fromData:error Unarchive code: NSSet *classesSet = [NSSet setWithObjects: [NSMutableArray classForCoder], [A classForCoder], [NSString classForCoder], [NSNumber classForCoder], [B classForCoder], [C classForCoder] , nil]; array of objects of Type A = [NSKeyedUnarchiver unarchivedObjectOfClasses:classesSet fromData:storeData error:&error] Issue: "UserInfo={NSDebugDescription=value for key 'root' was of unexpected class 'Class B'. Allowed classes are '{NSMutable Array}" Can someone please assist with this issue. I have tried all the available solutions online. I couldn't find a documentation from Apple on how to consume the new API in a correct way.
Posted
by
Post not yet marked as solved
2 Replies
785 Views
I am trying to replace the deprecated unarchiveObjectWithData API with unarchivedObjectOfClass. My class looks something like this Class B:<<NSSecureCoding> { +(BOOL)supportsSecureCoding { return YES; } } Class C <<NSSecureCoding> { property of class B; + (BOOL)supportsSecureCoding { return YES; } } Class A<<NSSecureCoding> { property of class B property of class c (BOOL)supportsSecureCoding { return YES; } } Tried solutions: Option 1: Archive code NSData *archiveData = [NSKeyedArchiver archivedDataWithRootObject:(array of objects of type A) requiringSecureCoding:YES error:&error]; // Encrypting archiveData and writing to file Unarchive code // fetching data from file // decrypting it NSSet *classesSet = [NSSet setWithObjects: [NSMutableArray classForCoder], [A classForCoder], [NSString classForCoder], [NSNumber classForCoder], [B classForCoder], [C classForCoder] , nil]; NSKeyedUnarchiver *unArchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:decryptedData error:&error]; [unArchiver setRequiresSecureCoding:YES]; array of objects of Type A = [unArchiver decodeObjectOfClasses:classesSet forKey:NSKeyedArchiveRootObjectKey]; Issue: Unable to unarchive all the properties. Properties have nil values including properties of type NSString, BOOL, custom class Option: 2 Use +unarchivedObjectOfClass:fromData:error Unarchive code: NSSet *classesSet = [NSSet setWithObjects: [NSMutableArray classForCoder], [A classForCoder], [NSString classForCoder], [NSNumber classForCoder], [B classForCoder], [C classForCoder] , nil]; array of objects of Type A = [NSKeyedUnarchiver unarchivedObjectOfClasses:classesSet fromData:storeData error:&error] Issue: "UserInfo={NSDebugDescription=value for key 'root' was of unexpected class 'Class B'. Allowed classes are '{NSMutable Array}" Can someone please assist with this issue. I have tried all the available solutions online. I couldn't find a documentation from Apple on how to consume the new API in a correct way.
Posted
by
Post not yet marked as solved
0 Replies
338 Views
I am having an issue with build my existing code with Xcode 15 which can able build using Xcode 14(14.3.1). Its been 9.1since I started the project. I was getting an error saying Dependency Order got Deprecated unable execute. I got changed dependency order to Auto still persists my problem.
Posted
by
Post not yet marked as solved
1 Replies
674 Views
hi, community, I am using qt framework and faced with internal issue on macOS 14.0, haven't found any similar reports, maybe already known issue ------------------------------------- Translated Report (Full Report Below) ------------------------------------- Process: Test [99529] Path: /Applications/Test.app/Contents/MacOS/Test Identifier: com.test.osx Version: 0.0.1 (00000) Code Type: ARM-64 (Translated) Parent Process: launchd [1] User ID: 507 Date/Time: 2023-07-21 10:37:25.1947 +0200 OS Version: macOS 14.0 (23A5286i) Report Version: 12 Anonymous UUID: 191461AA-EC46-D583-CB70-47FA103D8F89 Sleep/Wake UUID: 35433ED4-693B-46C2-9622-99C4FAD6B28F Time Awake Since Boot: 300000 seconds Time Since Wake: 3295 seconds System Integrity Protection: enabled Crashed Thread: 0 CrBrowserMain Dispatch queue: com.apple.main-thread Exception Type: EXC_ARITHMETIC (SIGFPE) Exception Codes: 0x0000000000000001, 0x0000000000000000 Termination Reason: Namespace SIGNAL, Code 8 Floating point exception: 8 Terminating Process: exc handler [99529] Thread 0 Crashed:: CrBrowserMain Dispatch queue: com.apple.main-thread 0 libRosettaRuntime 0x11eb5220c 0x11eb12000 + 262668 1 libsystem_platform.dylib 0x7ff80c666393 _sigtramp + 51 2 TextInputUIMacHelper 0x7ffc0c34f3d2 -[TUINSCursorUIController moveTextInputMenuHUD:] + 258 3 HIToolbox 0x7ff8176055fc TSMMessagePortCallBack + 2779 4 CoreFoundation 0x7ff80c7ad385 __CFMessagePortPerform + 690 5 CoreFoundation 0x7ff80c714c24 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41 6 CoreFoundation 0x7ff80c714b5e __CFRunLoopDoSource1 + 530 7 CoreFoundation 0x7ff80c7137e1 __CFRunLoopRun + 2704 8 CoreFoundation 0x7ff80c712749 CFRunLoopRunSpecific + 557 9 HIToolbox 0x7ff817472aa9 RunCurrentEventLoopInMode + 292 10 HIToolbox 0x7ff8174728b6 ReceiveNextEventCommon + 665 11 HIToolbox 0x7ff817472601 _BlockUntilNextEventMatchingListInModeWithFilter + 66 12 AppKit 0x7ff80fc151b5 _DPSNextEvent + 880 13 AppKit 0x7ff8104edf0f -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1304 14 AppKit 0x7ff80fc06a56 -[NSApplication run] + 603 15 libqcocoa.dylib 0x124849547 QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 2631 16 QtCore 0x127b76826 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 486 17 QtCore 0x127b6d617 QCoreApplication::exec() + 119
Posted
by
Post not yet marked as solved
0 Replies
860 Views
After updating to xcode 14.3 with RN 0.69.9, my project can't build anymore. It's throwing the error for all of my custom view managers. The error i'm getting is: A function declaration without a prototype is deprecated in all versions of C when I'm using RCT_EXTERN_MODULE Output of npx react-native info: System: OS: macOS 13.4.1 CPU: (8) arm64 Apple M1 Pro Memory: 77.59 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v16.13.1/bin/yarn npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm Watchman: 2023.07.10.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.12.1 - /Users/avarisco/.rvm/gems/ruby-2.7.4/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4 Android SDK: Not Found IDEs: Android Studio: Not Found Xcode: 14.3/14E222b - /usr/bin/xcodebuild Languages: Java: Not Found npmPackages: @react-native-community/cli: Not Found react: 18.0.0 => 18.0.0 react-native: 0.69.9 => 0.69.9 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Posted
by
Post not yet marked as solved
1 Replies
1.2k Views
As per apple documentation we are setting textContentType with "" in order to disable password auto fill view option on keyboards which is working fine in all iOS versions below 17 beta. Seems like it broke & password auto fill view option appearing on keyboards for iOS 17 beta versions even on setting textContentType with "" & inputAccessoryView as nil self.username.textContentType = @""; self.password.textContentType = @"";
Posted
by
Post marked as solved
2 Replies
464 Views
I have a static library staticLib.a which is witten mostly in C++ with one additional obj-C class MyClass. There are two dynamic libs, dynamicLib_A. dylib and dynamicLib_B.dylib are linked with the static lib. When starting the application which loads the dynamic libs at runtime it comes out the following warning: objc[15078]: Class MyClass is implemented in both /path/to/libdynamicLib_A.dylib (0x104f03f90) and /path/to/libdynamicLib_B.dylib (0x10dbf3f48). One of the two will be used. Which one is undefined. It can be found that the C++ names are mangled. For instance, both libdynamicLib_A.dylib and libdynamicLib_B contains string: __ZN18MyClassBC2Ev It looks like the obj-c class name is not mangled. Both libdynamicLib_A.dylib and libdynamicLib_B contains string: 00000000012b7f48 S OBJC_CLASS$_MyClass Question: How to avoid this warning? Why it complains only about the obj-c class but not the C++ class? Is this issue related to name mangling?
Posted
by
Post not yet marked as solved
4 Replies
1.3k Views
I ran across the following crash while using one of our apps. The app crashes since the recent iOS 17 beta builds. The code crashes when using valueForKey on an NSArray with objects that implement NSCopying. like: [@[[Sample new]] valueForKey:@"copy"]; or: [[Sample new] valueForKey:@"copy"]; header: @interface Sample : NSObject<NSCopying> - (Sample *)copy; - (Sample *)copyWithZone:(nullable NSZone *)zone; @end implementation: @implementation Sample - (Sample *)copy { return [super copy]; } - (Sample *)copyWithZone:(nullable NSZone *)zone { return self; } @end Any idea why this might be happening? I have created a feedback too: FB12819891
Posted
by
Post marked as solved
2 Replies
1k Views
I'm currently writing a code to achieve the RSA encryption via C++, and I stumbled across this error message when I was running it. The first part of my code is to generate random prime numbers based on the digit from the input for the encryption. For example, if you enter 6 then the code will generate two prime numbers, M and m, between 100000 to 999999. The "fin" variable equals (M-1)*(m-1), and based on "fin" I will create an int array the size of [fin+1] in the "Random e" section. However, if I enter a number greater than 3 ( which means "fin" will go beyond 6 digits) the crash will occur and the error message will show. I can't seem to find the problem anywhere, and if my input is no greater than 3 then the code will work exactly as I wanted it to. Is there something I missed? Thank you very much. Xcode [14.3.1] #include <iostream> #include <stdlib.h> #include <time.h> using namespace std; long long int gcd(long long int x, long long int y) { for (long long int t; y!=0; x=t) { t=y; y=x%y; } return x; } long long int mod(long long int x, long long int y, long long int n) { if (x%n==0) { return 0; } long long int result; for (result=1; y>1; x=(x*x)%n) { if (y%2==1) { result = (result * x)%n; y=(y-1)/2; } else if (y%2==0) { y=y/2; } } x=(x*result)%n; return x; } int main() { // Random Prime Numbers------------------------------// cout << "Input digits" << endl; int k; cin >> k; cout << "Input letter for encryption" << endl; char f; cin >> f; long long int M=pow(10, k)-1; long long int m=pow(10, k-1); bool prime[M+1]; memset(prime, true, sizeof(prime)); for(long long int p=2; p*p<=M; p=p+1 ) { if (prime[p] == true) { for (long long int i=p*p; i<=M; i=i+p) prime[i]=false; } } int prime2[M+1]; for (long long int t=0; t<=M; t=t+1) { prime2[t]=1; } for (long long int p=m, t=1; p<=M; p=p+1) { if(prime[p]==true) { prime2[t]=p; t=t+1; } } long long int h = count(prime, prime+M+1, true); long long int l = count(prime, prime+m, true); h=h-l; srand(time(NULL)); M=rand()%h+1; m=rand()%h+1; if (M==m) { m=(M*1000)%h+1; } if (M>h) { cout << "a=" << M << " error!" << endl; } else if (m>h) { cout << "b=" << m << " error!" << endl; } else { M=prime2[M]; m=prime2[m]; } // Generating RSA keys----------------------------// long long int n = M*m; long long int fin = (M-1)*(m-1); // Generating random e for the public key {e, n}--------// long long int number[fin+1]; for (long long int i=0; i<=fin; i=i+1) { number[i]=0; } for (long long int i=2, k=1; i<=fin; i=i+1) { if (gcd(i, fin)==1) { number[k]=i; k=k+1; } } long long int z = fin+1-count(number, number+fin+1, 0); srand(time(NULL)); long long int r = rand()%z +1; long long int e = number[r]; long long int e2 = e; long long int d=0; for (long long int x=1, y=0, k=1, t=1; e2%fin!=0; k=1, d=y) { t=y; y=x-y*(e2/fin); x=t; k=fin; fin=e2%fin; e2=k; } cout << endl << "The public key is {" << e << " , " << n << "}" << endl; cout << "The private key is {" << d << " , " << n << "}" << endl; // e、d、n acquired // Encryption begins----------------------------// long long int f2 = (int)f; f2 = mod(f2, e, n); cout << "The cyphertext is " << f2 << endl; f2 = mod(f2, d, n); f = (char)f2; cout << f << endl; }
Posted
by
Post not yet marked as solved
2 Replies
1.3k Views
the xcode will freze for 3mins when hit a breakpoint. it report "Fetching variables on ***'s iPhone" it happens when hit a new breakpoint, and the xcode will freeze for 3mins, then it will be ok. anysolution? its wasting my time. the xcode continue print the log below: (arm64) /Users/xx/Desktop/patch/Project/Pods/TestSDK/vendor/***.framework/***(FPEncryptMsg.pb-c.o) 0x00000c22: unable to locate module needed for external types: /Users/packagedevice/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/38MC9CUKFC6LS/Darwin-MI6WZSG1PNOM.pcm error: '/Users/packagedevice/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/38MC9CUKFC6LS/Darwin-MI6WZSG1PNOM.pcm' does not exist Debugging will be degraded due to missing types. Rebuilding the project will regenerate the needed module files. Our project has many dependencies which are binary file. And these dependencies are build in the remote serve。Anyone has ideas about this
Posted
by
Post not yet marked as solved
0 Replies
399 Views
I have an app using in app purchase to buy diamonds And to buy diamonds i want to use in app purchase, Paid Apps agreement activated. I already defined product_id from API [self.delegate applePayShowHUD]; NSDictionary *dics = @{ @"uid":[Config getOwnID], @"coin":[dic valueForKey:@"coin_ios"], @"money":[dic valueForKey:@"money"], @"changeid":dic[@"id"] }; [YBToolClass postNetworkWithUrl:@"Charge.getIosOrder" andParameter:dics success:^(int code, id _Nonnull info, NSString * _Nonnull msg) { if (code == 0) { NSString *infos = [[info firstObject] valueForKey:@"orderid"]; self.OrderNo = infos;//订单 //苹果支付ID NSString *setStr = [NSString stringWithFormat:@"%@_testing",[dic valueForKey:@"product_id"]]; NSSet *set = [[NSSet alloc] initWithObjects:setStr, nil]; self.request = [[SKProductsRequest alloc] initWithProductIdentifiers:set]; self.request.delegate = self; [self.request start]; } else{ [self.delegate applePayHUD]; dispatch_async(dispatch_get_main_queue(), ^{ [MBProgressHUD showError:msg]; }); } } fail:^{ }]; } - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response { [self.delegate applePayHUD]; self.products = response.products; self.request = nil; for (SKProduct *product in response.products) { NSLog(@"已获取到产品信息 %@,%@,%@",product.localizedTitle,product.localizedDescription,product.price); self.product = product; } if (!self.product) { dispatch_async(dispatch_get_main_queue(), ^{ [self showAlertView:YZMsg(@"无法获取商品信息")]; }); return; } //3.获取到产品信息,加入支付队列 SKPayment *payment = [SKPayment paymentWithProduct:self.product]; [[SKPaymentQueue defaultQueue] addTransactionObserver:self]; [[SKPaymentQueue defaultQueue] addPayment:payment]; } and i already put the product in app store connect like this i put configuration too in xcode <SKProduct: 0x2833d8890>: Skipping product "coin_3000_testing" because no price was available I always get skipping product, Am i missing something here ? I test this in real device directly from xcode, not testflight
Posted
by
Post not yet marked as solved
2 Replies
557 Views
Is there a way to catch the crashes from both swift and obj-c without using any 3rd party libraries? I want a way to note that my app has crashed, no stack trace needed just want some count of crashes stored to user defaults. I saw NSSetUncaughtExceptionHandler being used but it is only catching obj-c related errors. eg. force unwrapping nil is not caught here. I want a universal way of catching the crashes. also want to know if this can affect the crash reporting by 3rd party libraries
Posted
by
Post not yet marked as solved
1 Replies
357 Views
When I build and run my Objective-C project—consisting of the files main.m, BNRLogger.h, and BNRLogger.m—in Xcode, the function appLaunch: is supposed to be executed whenever a non-background application without the LSUIElement key in its Info.plist file launches on my MacBook. But that doesn't appear to be happening; the message "An app has started up!" doesn't show up in the Xcode console when an app (e.g., Blender) launches. What's going on? Have I failed to ensure that appLaunch: is called when an NSWorkspaceDidLaunchApplicationNotification is posted, or is no such notification being posted when an app launches? This is what main.m looks like: #import &lt;Cocoa/Cocoa.h&gt; #import "BNRLogger.h" int main(int argc, const char * argv[]) { @autoreleasepool { BNRLogger *logger = [[BNRLogger alloc] init]; [[NSNotificationCenter defaultCenter] addObserver:logger selector:@selector(appLaunch:) name:NSWorkspaceDidLaunchApplicationNotification object:nil]; [[NSRunLoop currentRunLoop] run]; } return 0; } BNRLogger.h looks like this: #import &lt;Foundation/Foundation.h&gt; #ifndef BNRLogger_h #define BNRLogger_h @interface BNRLogger : NSObject @end #endif And here are the contents of BNRLogger.m: #import "BNRLogger.h" @interface BNRLogger () - (void)appLaunch:(NSNotification *)note; @end @implementation BNRLogger - (void)appLaunch:(NSNotification *)note { NSLog(@"An app has started up!"); } @end
Posted
by
Post not yet marked as solved
1 Replies
529 Views
I have an Objective C++ wrapper class called ImageDividerWrapper in which there is a function I want to use in a Swift class called FrameProcessor. Inside the ImageDividerWrapper.h file I made sure to import the bridging header. I also double-checked that the bridging header was referenced and spelled correctly in Project/Build Settings/Swift Compiler. I also deleted derived data, cleaned build folder, etc.. Also imported ImageDividerWrapper.h into my bridging header file: #import "ImageDividerWrapper.h" And in my ImageDividerWrapper header file I include: #import "Vsn3-Bridging-Header.h" Unfortunately, I still continue to get the error: "No such module 'ImageDividerWrapper'" when trying to directly import the Objective C++ class into my Swift file with: import ImageDividerWrapper If anyone who has solved this problem before can point me in the right direction, I would appreciate it so much! Thank you!
Posted
by
Post not yet marked as solved
4 Replies
1.7k Views
I was migrating from Xcode 14 -> 15, and noticed that my code was failing with dyld[46534]: Symbol not found: _OBJC_CLASS_$_NSError I was able to debug the problem to some old objective c code, as documented in this thread: https://github.com/RonRadtke/react-native-blob-util/issues/273 The error seems to stem from this particular try catch block @try { // Some code } @catch(NSError *er) { // handle error } When I convert the code to catch an NSException instead, the runtime error goes away. Understandably, according to the apple docs, it should be throwing an NSException in the first place, but the documents do say Important: Although you can throw and catch objects other than NSException objects, the Cocoa frameworks themselves might only catch NSException objects for some conditions. So if you throw other types of objects, the Cocoa handlers for that exception might not run, with undefined results. (Conversely, non-NSException objects that you throw could be caught by some Cocoa handlers.) For these reasons, it is recommended that you throw NSException objects only, while being prepared to catch exception objects of all types. So it seems like this should not have produced a runtime error. I wanted to flag this in case the underlying code behind the @try @catch changed unintentionally.
Posted
by
Post not yet marked as solved
3 Replies
663 Views
I have an application which will launches another application as a child process. The child application does not need the dock icon, we use [NSApp setActivationPolicy: NSApplicationActivationPolicyAccessory]; to achieve it. However, I have discovered that the dock icon cannot be perfectly hidden. The number of recently used apps that aren’t already in dock(not choose keep in dock) less than three: The icon of the child application remains in the dock without being hidden. The number of recently used apps that aren’t already in dock(not choose keep in dock) more than three: The icon of the child application appears a few milliseconds. Even though add LSUIElement key in the Info.plist can work, we are seeking a programmatic modification.
Posted
by