Post not yet marked as solved
Rosetta 2 is not installed by default, you are prompted to install it for the first run of an x64 app - but only in the gui.
If you run an x64 app from the command line, directly or prefixed with arch -arch x86_64, it will simply fail. You have to double-click an x64 .app bundle in the Finder to trigger the "Would you like to install Rosetta?" popup.
Is there any way/API available to launch intel app/binary via terminal/NStask so that OS can show popup instead of launch failing. If not, any cmd available to show rosetta pop?
Post not yet marked as solved
I'm having trouble with memory leaks.
I want to get shader's reflection data from MTLFunction which is generated from precompiled shader files.
These files are compiled with Metal Developer Tools for Windows 2.3 and I use the following command options.
-x metal hoge.metal -std=ios-metal2.0 -o hoges.msl
To get these reflection data, I use the function newArgumentEncoderWithBufferIndex:reflection:.
I can get the reflection data, but some memory leaks occur for each call this function, and I don't know how to release the memory of the reflection data.
This is a example code.
void Func(id<MTLFunction> _pShaderFunc)
{
MTLAutoreleasedArgument reflection = nil;
id<MTLArgumentEncoder> argEnc = [_pShaderFunc newArgumentEncoderWithBufferIndex:0
reflection:&reflection];
// some process...
// [reflection release]; // run-time error.
[argEnc release];
}
I tested this on iPhone 11 Pro Max with iOS 13.3.1, Xcode 13.1, and Mac mini(2018) with macOS Monterey 12.4.
I compiled source files specifying the option -fno-objc-arc.
I used the instrument Leaks, and I confirmed when this function isn't called, there were no memory leaks.
Could you give me some advice on how to resolve those leaks?
Post not yet marked as solved
Hi all,
I have an application which is getting a segmentation fault when releasing an autorelease pool, but weirdly, it seems to be happening only on earlier OS versions. I and another person have tested it on Monterey and it works, but a tester has High Sierra and it's crashing.
I have tested it on my system for zombies, with address sanitizer turned on, everything I can think of, and no issues.
This is part of the the stack trace:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x000070ff5dfdbec0
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
objc_msgSend() selector name: release
0 Crashed:: Dispatch queue: com.apple.main-thread libobjc.A.dylib 0x00007fff5ef99e9d objc_msgSend + 29
1 com.apple.Foundation 0x00007fff3a2f0c01 NSKVODeallocate +192
2 libobjc.A.dylib 0x00007fff5ef9d042 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 812
3 com.apple.AppKit 0x00007fff35f25f24 -[NSApplication(NSEvent)
_nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 4028
4 com.apple.AppKit 0x00007fff35784d6d -[NSApplication run] + 764
5 com.apple.AppKit 0x00007fff35753f1a NSApplicationMain + 804
6 libdyld.dylib 0x00007fff5fb94115 start + 1
I am at a bit of a loss as to how to debug this, since nothing is turning up on my system, and it seems to be occurring only on an older version of the OS where I can't debug it.
Any clues or ideas for how to track it down would be most welcome.
Post not yet marked as solved
Our
team has implemented PHPickerViewController to allow multiple photos to be
selected. It works fine in the simulator but when tested on actual iPad we have
this strange behaviour. The first time the gallery is displayed it works fine.
If we try and display the gallery again it displays a window with this message
“Unable to Load Items - [Try Again]”. If I tap [Try Again] or if I
use our Gallery button it does display the gallery. And it keeps cycling
through this behaviour. ie. every second attempt to display the gallery leads
to the “Unable to Load Items” window.
Every time we display the gallery we dismiss the old instance and create/initialize a
new instance of the controller. Our code is written in objective-c…
-(void)initPHPickerController
{
[self dismiss];
mPHPickerController = nullref;
PHPickerConfiguration *config = [[PHPickerConfiguration alloc] init];
config.selectionLimit = 0; // 0 represents no selection limit.
config.filter = [PHPickerFilter imagesFilter];
config.preferredAssetRepresentationMode = PHPickerConfigurationAssetRepresentationModeCurrent;
PHPickerViewController *pickerViewController = [[PHPickerViewController alloc] initWithConfiguration:config];
pickerViewController.delegate = self;
mPHPickerController = pickerViewController;
}
- (void)dismiss
{
if (mPHPickerController)
{
[+mPHPickerController dismissViewControllerAnimated:YES completion:nil];
}
...
}
Any suggestions on how to fix this ?
I have seen a post on stackoverflow that this may be a bug in iOS.
Post not yet marked as solved
Hello,
I am facing a problem in including a C++ header file like vector, set etc. in a objective-c++ header.
Lets suppose, I am having 2 files:
abc.h
abc.mm
Now, when I try to include the C++ header in abc.mm file, no build error is coming.
But when I try to include the C++ header in abc.h file, it is throwing build error.
Build error is: Header not found.
How to resolve this error? Any suggestion will be helpful.
Thanks
Asheesh
Post not yet marked as solved
I have an Objective-C macOS app which provides a service that provides unique services on selected text.
This app has been for sale in the Mac App Store for several years.
The app registers as service provider during 'appDidFinishLaunching' with: [[NSApplication sharedApplication] setServicesProvider:self];
When my service is invoked it uses the standard service method:
(void)serviceName:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error
In the body of this standard service method the contents of the NSPasteboard (pboard) are examined and consumed by my app.
- (void) kudosService:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error; {
if ([pboard pasteboardItems].count==0) { return; }
NSPasteboardItem *pI = [pboard pasteboardItems][0];
NSLog(@"pI:%@",pI.types );
for (NSString *uti in pI.types) {
NSLog(@"uti:%@ string:%@",uti, [pI stringForType:uti] );
}
...
}
Something has changed with Preview app; at this point I'm inclined to think the change occurred with version 11.
Console output for Preview
pI:(
"public.utf8-plain-text",
"public.rtf",
"public.utf16-external-plain-text"
)
uti:public.utf8-plain-text string:(null)
uti:public.rtf string:(null)
uti:public.utf16-external-plain-text string:(null)
This is the output regardless of whether or not the user has a mere text selection OR has formally 'Cop(ied)' [Cmd-C] the text in the Preview window!
Please NOTE if I open the exact same .pdf document in Safari and invoke the service from Safari I see the expected Console output:
pI:(
"public.utf8-plain-text"
)
uti:public.utf8-plain-text string:The Best Gluten-Free Chocolate Cake
When did this change in Preview behavior occur?
Can anyone point me to some documentation, which I have obviously overlooked, that would shed some light on this matter!
Post not yet marked as solved
error desc: Reached end of file while looking for: Mach-O slice.
Xcode version :13.2.1
please, how to do it ?
Post not yet marked as solved
Hey everyone I've been tasked to do some back end work for my app and just looking for a little guidance or advice.
I have an app that will need to be connected to a local network only DB. No cloud services can be used. I found some useful information from Code with Chris, https://*******.com/2kfmv8vw ,but seems from the comments it might be a little outdated. I know for sure I'll be using PHP to connect the two but just wanted to see if anyone had any suggestions before I started this journey. Any help is welcome
Post not yet marked as solved
Hi,
I was working on a feature based on dns packet parsing in the VPN solution of my app on iOS.
I was using the dns_parse_packet api from dnsutils.h class, which was able to parse dns requests and reply packets from raw bytes quite efficiently.
I had tested this flow on iOS 15.2 but after updating to iOS 15.5 this api does not seem to work anymore.
Has this API been deprecated or is this a bug in iOS 15.5?
Post not yet marked as solved
I have an older MacOS app where in IB (no storyboards) I created a main window/view and a progress window/view in one xib in response to a menu item. In a new MacOS app (using much of the code from the older menu item code), in IB storyboard I have a window controller/window/view/subviews in the storyboard, but I cannot seem to find a way to also include in the storyboard a progress panel (to hook up to an outlet in the view controller).
I can create the same window/panel/progress bar that I had in the older app in a separate xib. So I suppose (in objective c) I can just load the xib???
So, is there a better way to implement a separate progress window(s) in a storyboard and hook them up to outlets? I think I'm missing something
And what happened to NSPanels?
Post not yet marked as solved
The following is my code to show text in textview. But the error, EXC_BAD_INSTRUCTION, happens while executing it.
How does this error happen and how could I fix it?
dispatch_sync(dispatch_get_main_queue(), ^{
[[[Memo1 textStorage] mutableString]appendString:[NSString stringWithFormat:@"%@", str]];
[Memo1 scrollRangeToVisible:NSMakeRange(Memo1.string.length, 0)];//auto scroll down
});
Post not yet marked as solved
What is the word in programming that means that checks a condition for true or false, and if the condition is false, code is run to make that condition true, so that if the condition is checked again, it would be true?
I believe I have seen something in Swift or Foundations that does this as applied to different things.
Post not yet marked as solved
#define KdownloadsPath NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, YES).firstObject
_downloadedPath = [KdownloadsPath stringByAppendingPathComponent:fileName];
_downloadingPath = [_downloadedPath stringByAppendingString:@".download"];
NSDictionary* info = [NSDictionary dictionaryWithObjectsAndKeys:
@"NSProgressFileOperationKindDownloading", @"NSProgressFileOperationKindKey",
[NSURL fileURLWithPath:_downloadingPath], @"NSProgressFileURLKey",
nil];
self.progress = [[NSProgress alloc] initWithParent:nil userInfo:info];
[self.progress setKind:@"NSProgressKindFile"];
[self.progress setPausable:NO];
[self.progress setCancellable:YES];
[self.progress setTotalUnitCount:_totalBytes];
[self.progress publish];
(updating the progress indicator happens elsewhere)
I'm creating an NSProgress object to show a progress indicator underneat a file in my Downloads directory. The entitlements includes com.apple.security.files.downloads.read-write.
The indicator does not show when NSProgressFileURLKey points to the sandboxed file path, e.g. /Users/mdbraber/Library/Containers/com.mdbraber.TestApp/Data/Downloads/Test.pptx.download. It does work when NSProgressFileURLKey points to the direct download location which the sandbox links to e.g. /Users/mdbraber/Downloads/Test.pptx.download
Is this a bug or should I use something else for NSProgressFileURLKey to make this work?
Hi,
I have a log to file function that as part of the logline inserts the current datetime as below:
class func logToFile(message: String, logInfo: LogInfo = appLogInfo, type: OSLogType = .default) {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"
formatter.timeZone = TimeZone(secondsFromGMT: TimeZone.current.secondsFromGMT())
formatter.locale = Locale(identifier: "en_US_POSIX")
let localDate = formatter.string(from: Date())
let logMessage = "\(localDate) [\(logInfo.category)] \(message)\n"
let documentDirPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
let filePath = "\(documentDirPath)/\(logFileName)"
if let fileHandle = FileHandle.init(forWritingAtPath: filePath), let data = logMessage.data(using: .utf8) {
fileHandle.seekToEndOfFile()
fileHandle.write(data)
}
}
and it is always called from a serial queue:
Log.serialQueue.async {
logToFile(message: message, logInfo: logInfo, type: type)
}
Lately however, I am getting some crashes and I managed to catch one in the debugger. It happens when deallocating the local DateFormatter when exiting the logToFile function.
Xcode stops at the end of the function:
And the thread indicates that it is inside NSDateFormatter dealloc
and clicking on the ici::Dataformat destructor, the assembly code shows this:
And in the inspector, we can see that localDate is half-baked, it only contains the year and day:
I have found some posts on DateFormatter not being thread safe but that was way in the past. In my case I only want to convert a Date() to String.
Something is not working as expected and suggestions on how to improve it would be very welcome.
Thanks in advance
Post not yet marked as solved
Hi,
I have no idea what happened, I got no warnings, no error.
When I used the Sandbox I got a GL_INVALID_VALUE error.
Please have I look at the attachments for illustration.
Post not yet marked as solved
Xcode show this error. and cannot jump to project navigator..I cannot find the real issue... BTW:I use objective-C.
error build: 5457 duplicate symbols for architecture arm64
In the OC project, iOS14 WidgetKit target was added, but consistent error
Cannot find type "ConfigurationIntent" in scope,
type 'Provider' does not conform to protocol 'IntentTimelineProvider'
What is strange is that after adding a new OC project, the compilation is successful,
Tool: Xcode12-beta & Simulator
How to get access to old projects?
Post not yet marked as solved
I have a button that starts tests. The items, test no, min and max are added to the table_array and refresh table to show them.
Following code runs without error.
index++;
//if([[Elect objectAtIndex:index]isEqualToString:@"1"])
item++;
temp = [self GetDCVoltage_34970:1];
if(temp >= [[Min objectAtIndex:index]floatValue] && temp <= [[Max objectAtIndex:index]floatValue])
[table_status addObject:@"Pass"];
else
{
PF=false; [table_status addObject:@"Fail"];
err=101+item; [errcode setIntValue:err];
}
[table_no addObject:[NSString stringWithFormat:@"%d",item]];
[self Show_Datagrid:index];
[table_value addObject:[NSString stringWithFormat:@"%.3f",temp]];
[Test_value replaceObjectAtIndex:index withObject:[NSString stringWithFormat:@"%.3f",temp]];
[self refreshTable];
//if (continue_test.state==0 && PF==false)
//return;
return;
After I removed some lines, I only remain the lines that add objects to table_array. Then it shows up error: Thread1: EXE_BAD_INSTRUTION after I pressed button.
[table_no addObject:[NSString stringWithFormat:@"%d",item]];
[self Show_Datagrid:index];
[table_value addObject:[NSString stringWithFormat:@"%.3f",temp]];
[Test_value replaceObjectAtIndex:index withObject:[NSString stringWithFormat:@"%.3f",temp]];
[self refreshTable];
Post not yet marked as solved
Am new to objective c I need to set a characteristic data which I get from a Bluetooth using CB read to Byte array then return a byte buffer.
the same is written in java how can I do the same in objective c
dataArray = characteristic.getValue();
tsLong = System.currentTimeMillis() - tsStart;
float timeSeconds = (float) ((float) tsLong / 1000.0);
String timerstring = String.format("%.2f", timeSeconds);
message = convertByteToChannelData(ByteBuffer.wrap(dataArray), timerstring, 0);
this is the convertByteToChannelData method
public String convertByteToChannelData(ByteBuffer wrap,String timerString, int stimulus){
wrap.order(ByteOrder.LITTLE_ENDIAN);
// Set 1 Channels
// Channels 1, 5, 6, 11, 16, 17
ch1R = (float) ((wrap.getShort(0) / 4095.) * 3.3);
ch1Rs = (float) ((wrap.getShort(4) / 4095.) * 3.3);
ch5R = (float) ((wrap.getShort(12) / 4095.) * 3.3);
ch5Rs = (float) ((wrap.getShort(4) / 4095.) * 3.3);
ch6R = (float) ((wrap.getShort(6) / 4095.) * 3.3);
}
Post not yet marked as solved
Will Apple continue to support it, or will we wake up one day to find that Swift is the only viable language?It's a serious question. Careers depend on it. I don't accept the "No comment" approach that Apple usually takes. It's cruel.I'm willing to put the time into learning Swift if I have to. I'm not going to do it if I don't. I want to know.Frank