Cocos desktop app can not access to files on MacOS - xcode

I have an application with the following structure:
./Data/test.txt
./TestMacOSApp
So my TestMacOSApp opens ./Data/test.txt and uses the content of test.txt. This app was working for a long time either on my MacBook or others MacBook. Recently I noticed that the app works on my MacBook fine,
but on others it crashes throwing "File is not found exception".
I create TestMacOSApp using XCode v9.1.
MacOS version is 10.12.6.
The App creation steps are Archive->Export->ExportApp (Without re-signing).
Does someone else have such an issue?
How can I solve this issue?

I don't know how you open the file because you didn't provide the code which does this.
But I know that, when you export your app on other computers, it is important to calculate the real path with fullPathForFilename, instead of giving directly the path that you know. Like this:
auto fileUtils = FileUtils::getInstance();
string content = fileUtils->getStringFromFile(fileUtils->fullPathForFilename(filename));
Have you done this? If you have, and it doesn't work, your file is probably just not where you expect it to be, so please check again.

Related

Prevent or clear app state persistence for MacOS SwiftUI Document Based App

I am developing a MacOS Document based app using SwitfUI on MacOS 12.0.1 using Xcode 13.1 on a MacbookPro M1 Pro. I am encountering an issue that the app is always re-opening the document browser at the last used directory. Which is OK when it is on the Machine but a pain if the last used was on a network drive. I am trying to find a way of suppressing this "always restore using the last directory" mode of operation.
I have tried using the #NSApplicationDelegateAdaptor approach and implementing;
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
print(#function + " returning false")
return false
}
within my NSApplicationDelegate class, which does get called (although it seems sometimes after the dialog is presented), however this does not stop the app secretly remembering the last directory.
Does any know where this information might be being hidden or if it can be suppressed ?
I have looked for, but cannot find, a way of injecting a starting directory into a DocumentGroup as a possible solution.
TIA Alan.
Ok, for anyone who ends up here looking for a similar issue.
After a chunk of digging I found the answer, for me, was to add
UserDefaults.standard.removeObject(forKey: "NSNavLastRootDirectory")
into the app startup. It was also suggested to do
UserDefaults.standard.removeObject(forKey: "NSNavLastCurrentDirectory")
However, just doing the first appears to suppress the file open dialog, doing both causes the file open dialog to open with the user Documents directory.

Running AntlrWorks2 stand-alone on Windows 7

I must be missing something. After downloading AntlrWorks2 I found the executable bin/antlrworks2.exe and bin/antlrworks264.exe. Aren't these supposed to be the standalone version of the tool? Neither works for me; after a NetBeans splash screen, the first times around I got an error message on missing packages; after a couple of times I chose to go on regardless, but now (still after the initial spash screen) there is simply nothing happening at all.
I can't find any tutorial or manual detailing how to run AntlrWorks stand-alone, so any help is much appreciated.
This is due to a bug in the NetBeans platform. I filed a report but it hasn't received a reply yet:
Cannot launch platform application after moving installation folder
Here is a workaround that does not delete any preferences you have customized:
I found that deleting just the var folder under the user's generated
.antlrworks2 settings folder resolves the issue...
Still an issue as of date of this post. Deleting the .antlrworks2 folder from \users\username\AppData\Roaming does work - you can find this folder by putting %APPDATA% into your file explorer address bar (exactly as shown) - that will go to the app data folder for your current user login session. Delete the .antlrworks2 folder and then re-run the app.

Using Qt to open external game application

I have a windows qt application and I'm trying to open an external game, but I'm not having success.
Application is in C:\games\Oni\Edition\ and is called Oni.exe, the code I'm using right now is the follow:
void MainWindow::on_toolButton_clicked()
{
qint64 test=1;
if(!QProcess::startDetached("Oni.exe",QStringList(),"C:\\games\\Oni\\Edition\\",&test)){
QMessageBox msgBox;
msgBox.setText("Oni couln't be started!");
msgBox.exec();
}
}
I don't know if I'm forgetting something? The game runs fine if I double click it. Thanks.
Alright, figured it out.
Just replaced the code:
QProcess::startDetached("Oni.exe",QStringList(),"C:\\games\\Oni\\Edition\\",&test)
by
QProcess::startDetached("C:\\games\\Oni\\Edition\\Oni.exe",QStringList(),"C:\\games\\Oni\\Edition\\",&test)
And it's working like a charm.
I had also tried QProcess::startDetached("C:\\games\\Oni\\Edition\\Oni.exe"); before but didn't worked, seems we need to put always the full directory of the executable and also the full directory as working directory. This because seems only executing the file directly, the file itself may be looking for another folders/files in the QT Debug folder, when they are in the game folder. This cause the game quits prematurely. :)
Another solution would be use windows native api like user827992 pointed out in the follow link: QProcess::startDetached blocked by UAC (running an updater)
This latter solution also should work fine with UAC problems.

Issue in integrating ZXing to iphone App

I am trying to develop QRCode reader application in iPhone.
I am trying to use ZXing SDK. i have successfully run the sample application given by ZXing. But i ma trying to develope new application as per instructions in Readme given by Zxing. but when i am trying to add ZxingWidget in build phases. it going add but it shows like below
I think it will getting problem to me. When i am trying to run application it will give erros like Lexical or Prepocessor issue File not found.
Is am doing any thing wrong when am added to files to application.
Actaully first of all i added ZxingWidget.xcodeproj to my application by drag and drop. But it wont give any alert window would you like copy like similar when we adding images or files to xcode. and next i added cpp and iphone folders to xcode application. and later i added the frameworks as per read me.
Please any one help me in this issue.
Thanks in advance
Pretty hard to help without the real error message. In the Issue Navigator, you can Right Click > Reveal in Log to see the complete error that you can copy and paste.
That said, it sounds a bit like it can't find the headers (though I'm just guessing without the real error message.) If so, double check steps 4 and 5 of the readme.
if you run on real device, the problem will be solved.
I don't know the reason.
But I guess It's related to Build Products Path.

Firemonkey deployment folders on a Mac

I am new to Mac development and are trying to understand the location that XE2 firemonkey apps are deployed. I understand that the application is deployed into a "package" however I am not sure how this work when getting path information from within my app.
My application loads a dylib that I moved over from Visual Studio to XCode and initializes it by passing in a driver path (intended to be off the application path). i.e.
UDMXLibInit(PAnsiChar(AnsiString(driver_path))
If I put a breakpoint on this line in Delphi I find that driver_path is:
.../PAServer/scratch-dir/MacMini/LightFactory3.app/Content/MacOS/drivers
In my dylib I put a breakpoint in XCode on the "Init" function I find that the path is now:
.../PAServer/scratch-dir/MacMini/LightFactory3.app/Content
There appears to be some vodo that is truncating the path. Is this because "LightFactory3.app" is a package and there is something I dont understand or is there something else I am missing about passing this string between app and library under OSX?
Thanks in advance.
This appears to be a bug in the Expressions view for XCode 3.2. For some reason it truncates strings.
The actual string was correct - figure this out by passing it back to to my app.

Resources