When building for iOS Simulator, the expected library /Users/////AdMob/FBLPromises.xcframework/ios-arm64_x86_64-simulator/FBLPromises.framework was not found in /Users/////AdMob/FBLPromises.xcframework
Objective-C
RSS for tagObjective-C is a programming language for writing iOS, iPad OS, and macOS apps.
Posts under Objective-C tag
200 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Hi there,
I am currently facing an issue with PDFKit page rendering. In one of my application, I have to open annoted PDF for reading and when user tap on particular annotation, I have to jump certain number of pages in same PDF to open the new desired page.
Example: User is on page 2 and when user tap on menu button, I need to navigate directly on page number 8.
With above scenario, my application takes a while to load page number 8 and User can see white screen before loading PDF page. When I checked console log, I can see following as an error.
F.I: App requires to use usePageViewController for pagination.
I am using as per following:
_pdfView = [[PDFView alloc] initWithFrame:[UIScreen mainScreen].bounds];
[view addSubview:self.pdfView];
self.pdfView.delegate = self;
[self.pdfView setAutoScales:true];
[self.pdfView setDisplayDirection:kPDFDisplayDirectionHorizontal];
[self.pdfView usePageViewController:true withViewOptions:nil];
[self.pdfView setBackgroundColor:UIColor.whiteColor];
Warning: Unable to complete drawing page index 24 on time as a request to forceUpdateActivePageIndex:withMaxDuration: 0.02
I hope if someone can help me on that
Thanks.
iOS app targeting iOS 15.5 has been working fine up to iOS 17 Beta (21A5326a).
With iOS 17 RC (21A329) it is now crashing on launch.
Anybody experiencing similar issue?
Why kVK_F2 is not equivalent to constant NSF2FunctionKey for F2 key press event, What is equivalent constant of kVK_F2, since carbon framework is deprecated.
When I printed the keyCode, The [Event keyCode] against NSF2FunctionKey is 63237(0xF705) whereas for kVK_F2, it prints is 120 which is 0x78. 0x78 seems to be the standard keyboard value for F2 key.
Sample code :
//@property (nonatomic, strong) id eventMonitor;
NSEvent* (^handler)(NSEvent*) = ^(NSEvent *theEvent) {
NSEvent *result = theEvent;
NSUInteger flags = [theEvent modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
if ((flags & NSEventModifierFlagFunction) && (flags & NSEventModifierFlagCommand) && ([theEvent keyCode] == NSF2FunctionKey)) {
NSLog(@"Command + F2 key pressed.");
}
return result;
};
_eventMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:(NSEventModifierFlagFunction | NSEventMaskKeyDown) handler:handler];
Hello all,
I have an application which retrieves URL from browser using accessibility.
From time to time I am having this crash and I don't know the reason for it.
Could you please help me?
This is the stacktrace:
It is happening on MacOS 13.5 and it happens on an application built for x86_64 and arm64
Hi!
I have a xcode workspace with first objectiveC framework (let’s call it framework#1). This framework has some singletons (+(instancetype)shared using the dispatch_once idiom.
This code is pretty straight forward and used everywhere :
+ (instancetype)shared {
static dispatch_once_t onceToken;
static OGAKeyManager *instance = nil;
dispatch_once(&onceToken, ^{
instance = [[self alloc] init];
});
return instance;
}
I have a second framework (framework#2) in Swift that uses theses singletons (the framework#1 is added as do not embeed in the framework settings).
And I have an application that uses both frameworks.
If I make a breakpoint inside the dispatch_once alloc/init, I see that I enter 2 times : once when the shared method is called from framework#1 and another one when it’s called from framework#2.
How is that even possible ? Isn't dispatch_once supposed to handle this ?
I asked chatGPT, it points out to some objC/Swift interoperability, but honestly, I don't see what I can do to make it work correctly.
There is no circular dependency (framwork#2 uses framwork#1, but framwork#1 has no clue of framwork#2 existence)
Maybe it has something to do with sandbox, but I don't see how can it be.
Does anyone experienced some weird behavior like this ?
Thanks
I have a history objective-c project, and now i want to use Live Acitivity feature in that objc project.
first i implement a live activity in swift project, and it works well on iphone devices.
then i copy same codes from swift project to objective-c project, build and run on same iphone device, no error or warning generates, but Live Activity UI can't seen.
can someone tell me how to fix it ? and only swift project can support Live Activity ?
Calling loadFileRepresentationForTypeIdentifier sometimes returns an empty file, the URL params is filled with a path where a file exists, however it contains empty content.
My app is released on the store and this error happens 1.5% of the time my users pick an image / video from their gallery using the UIImagePickerControllerDelegate.
I was able to reproduce this bug and here is a screenshot of XCode in debug mode so you can see that the file is empty right after calling loadFileRepresentationForTypeIdentifier
I'm using XCode 14.3.1, a real iPhone 12 with iOS 16.3.1 and coding in Objective-C.
Step to repro :
1- Capture a live photo with your device
2- Pick this photo from your gallery using UIImagePickerControllerDelegate -> didFinishPicking
3- Grab the item provider and call provider loadFileRepresentationForTypeIdentifier:@"public.jpeg"
4- Inside the completion handler check the file size of the URL provided in the parameters
It is 1.5% repro, so to repro in local I had to take hundreds of live photos. But with patience, it happens and you can debug.
Note: Calling a second time loadFileRepresentationForTypeIdentifier:@"public.jpeg" inside the completionHandler returns a URL pointing to a real file with existing content, thus there might be some race conditions somewhere.
Do you have any workarounds?
Hi,
I am trying to extend the pytorch library. I would like to add MPS native Cholesky Decomposition. I finally got it working (mostly).
But I am struggling to implement the status codes.
What I did:
// init status
id<MTLBuffer> status = [device newBufferWithLength:sizeof(int) options:MTLResourceStorageModeShared];
if (status) {
int* statusPtr = (int*)[status contents];
*statusPtr = 42; // Set the initial content to 42
NSLog(@"Status Value: %d", *statusPtr);
}
else {
NSLog(@"Failed to allocate status buffer");
}
...
[commandBuffer addCompletedHandler:^(id<MTLCommandBuffer> commandBuffer) {
// Your completion code here
int* statusPtr = (int*)[status contents];
int statusVal = *statusPtr;
NSLog(@"Status Value: %d", statusVal);
// Update the 'info' tensor here based on statusVal
// ...
}];
for (const auto i : c10::irange(batchSize)) {
...
[filter encodeToCommandBuffer:commandBuffer
sourceMatrix:sourceMatrix
resultMatrix:solutionMatrix
status:status];
}
(full code here: https://github.com/pytorch/pytorch/blob/ab6a550f35be0fdbb58b06ff8bfda1ab0cc236d0/aten/src/ATen/native/mps/operations/LinearAlgebra.mm)
But this code prints the following when input with a non positive definite tensor:
2023-09-02 19:06:24.167 python[11777:2982717] Status Value: 42
2023-09-02 19:06:24.182 python[11777:2982778] Status Value: 0
initial tensor: tensor([[-0.0516, 0.7090, 0.9474],
[ 0.8520, 0.3647, -1.5575],
[ 0.5346, -0.3149, 1.9950]], device='mps:0')
L: tensor([[-0.0516, 0.0000, 0.0000],
[ 0.8520, -0.3612, 0.0000],
[ 0.5346, -0.3149, 1.2689]], device='mps:0')
What am I doing wrong? Why do I get a 0 (success) status even tough the matrix is not positive definite.
Thank you in advance!
My apps were working fine and suddenly started crashing on older devices. I have iPhone 7 Plus to test and after updating it to 15.7.8, the installed apps which were working before started crashing. The specific code where they are crashing is
if([testStats objectForKey:TEST_STATS_ARRAY]) {
statArray = [testStats objectForKey:TEST_STATS_ARRAY];
}
else {
statArray = [[NSMutableArray alloc] init];
[testStats setValue:statArray forKey:TEST_STATS_ARRAY];
}
Hello everyone! Here with another graphics api question but slightly different. I'm currently looking at 2 SDK's for physics called PhysX and Bullet. The game asphalt 9 uses metal and bullet and I would like to do the same with asphalt 9. With metal 3 out and stable it seems, I would like to use one of these engines for my upcoming metal api rendering engine. Bur there's a catch, I wish to use objective-c or c++ for both the rendering engine and the physics engine as I mentioned above, but not me touching swift(its a good language but i wish to use c++ for game development). What do you guys say about this?
Hey all. I took a look at a video that caught my attention(https://developer.apple.com/videos/play/wwdc2021/10081) and wish to use this for my ios and iPad game. However, the language used here is swift, and want to use either objective-c or c++. Did anyone here used this method shown is this video but without swift?
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.
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
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!
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 <Cocoa/Cocoa.h>
#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 <Foundation/Foundation.h>
#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
When my app enter to background, I start a background task, and when Expiration happens, I end my background task. The code likes below:
backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
dispatch_async(dispatch_get_main_queue(), ^{
if (backgroundTask != UIBackgroundTaskInvalid) {
[[UIApplication sharedApplication] endBackgroundTask:backgroundTask];
backgroundTask = UIBackgroundTaskInvalid;
[self cancel];
}
});
}];
When the breakpoint is triggered at the endBackgroundTask line, I also get the following log:
[BackgroundTask] Background task still not ended after expiration handlers were called: <UIBackgroundTaskInfo: 0x282d7ab40>: taskID = 36, taskName = Called by MyApp, from MyMethod, creationTime = 892832 (elapsed = 26). This app will likely be terminated by the system. Call UIApplication.endBackgroundTask(:) to avoid this.
The log don't appear every time, so why is that? Is there something wrong with my code?
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?
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 = @"";
How to Setup "Multi-OS Engine" in Xcode