Firemonkey deployment folders on a Mac - xcode

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.

Related

Cannot run exported application

I've developed a simple MacOS application (i.e. a product consisting of main application and launch helper application) with Xcode 9.4. Application runs fine in Xcode. I've archived and exported the app (either "Export without re-signing" or "Development" using "Automatic signing"). The export process runs without errors.
However, it is not possible to the application. Upon starting outside of Xcode, nothing happens; no error message etc.
How can this be further diagnosed?
Finally found it thanks to #clemens. Embedded libraries have their place inside the generated package in /Contents/Frameworks. Since I had previously embedded a login item I had set a /Contents/Library/LoginItems target path that was used below Frameworks which is clearly not the expected place. Removing the library, cleaning the path and re-adding fixed it for me.

Cocos desktop app can not access to files on MacOS

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.

User data in xcode executable

I opened an executable built for OSX in a text editor (TextMate).
Within the last line of text there is this string:
/Users/FOOBAR/Documents/macapp/macapp/macapp/
macapp is the name of the executable.
However, FOOBAR, seems to be the username of the person who compiled this.
Is this something that Xcode will put into your executable on build?
If it helps, there are other string indicating the name of the Xcode program to be "/Applications/Xcode 2.app".
That's clearly a mistake on the part of the developer and has possibly been left behind from a previous debugging or testing session.
Getting details of particular directories that can be used by the app must be done using APIs like [NSFileManager URLsForDirectory:inDomains:] or NSSearchPathDirectory.

Unable to find APP_BUNDLE_PATH. Cannot find a built app that is linked with calabash.framework

I am running calabash-cucumber in xcode 5.0.1 on OSX 10.9.1, but getting this error while executing the test script. I have installed calabash framework successfully, but don't know why this error occurs.
Error... Unable to find APP_BUNDLE_PATH.
Cannot find a built app that is linked with calabash.framework
Please build your app from Xcode
You should build your calabash target.
Alternatively, specify APP_BUNDLE_PATH in features/support/01_launch.rb
This should point to the location of your built app linked with calabash.
(RuntimeError)
/Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.9.168/lib/calabash-cucumber/launch/simulator_helper.rb:178:in `app_bundle_or_raise'
/Library/Ruby/Gems/2.0.0/gems/calabash-cucumber-0.9.168/lib/calabash-cucumber/launcher.rb:307:in `relaunch'
/Users/mymac/Desktop/myproject/myproj/features/support/01_launch.rb:29:in `Before'
Does your simulator or device contain the YourApp-cal target installed? Check weather you run the YourApp-cal target once from the xcode to install the app with calabash server on simulator or device.
Then Check you have followed setup Process
You need to have xcode tools installed too.
Check these things too.
Build the yourApp-cal target and run using xcode once.
While App is running open a Terminal(console) and type calabash-ios console. If your ruby environment is correct it will open you a ruby console.
In that console type
server_version['version']
and
Calabash::Cucumber::FRAMEWORK_VERSION
you should get something like "0.9.164"
calabash.framework is installed correctly in your app.
If so You should go to the file /YourProject/features/support/01_launch.rb open it check weather app bundle path is specified or not (if it is commented out calabash automatically detect the default app bundle path) if you are building your app to somewhere else than the default place you need to specify the appbundle path here in this file.
Tell us more details after check this list so we can help you more..
I hit the same issue, the way I got around to it is, on Xcode's top-right corner there is "Identity and Type" window. There you will find the full path of anything that you select on left (Project Explorer window).
Now usually on the ProjectExplorer window you should have "Classes", "Common", "Frameworks", "Other Sources", "Product", "Resources", "Scripts" etc. (It might be slightly different project by project). Inside "Product" is where your .app lives.
Select your app and you'll see the whole path on "Identity and Type" window.
Copy and paste it to "support/launch.rb" where it says APP_BUNDLE_PATH.
Should work now.
Edit 29/07/14: Do you see
HTTPServer: Started HTTP server on port 37265 on 'All output' window of Xcode (my version of Xcode is 5.1) when you build ?
There is a better way to set up calabash so you won't have this problem.
It involves creating a configuration, rather than a -calabash target. Basically you
1. create a configuration
2. add calabash framework to that configuration in build settings
3. add framework search path to find that framework
4. create a scheme to run calabash
The longer version can be found
http://fangmobile.com/2014/05/08/do-you-love-calabash-ios-but-hate-that-cal-second-target/
Deleting the contents of /Library/Developer/Xcode/DerivedData and compiling again solved this problem for me.
My error message was Unable to auto detect APP_BUNDLE_PATH.

Using OSX Security-Scoped Bookmarks in a Firemonkey app

I have been developing an OSX app with Delphi XE3 and running into various problems. The latest one is with the sanboxed version built for the Apple Appstore.
The user has to select an arbitrary folder and the app needs to get access to it. Since there is a problem with the OpenDialog, I had to turn to drag-drop functionality instead.
The user drags a folder to the app, the sandbox gives the app temporary access to it and all works properly.
To preserve the access to this folder when the app is restarted I have to use the so-called "security-scoped bookmarks"
I am having two issues with them:
1) How to add the "com.apple.security.files.bookmarks.app-scope" entitlement to an XE3 firemonkey app? It is not available in the Project Options->Entitlements. If I add it manually in the ".entitlements" file it gets overwritten when the app is built.
So is there a way to add a custom entitlement that is not in the list in the project options?
2) To create the bookmark I should use the NSURL.bookmarkDataWithOptions method. I think it should be used like this, but I am not sure of the exact syntax:
var
URL: NSURL;
Err: NSError;
Data: NSData;
...
URL := TNSURL.Create;
Data := URL.bookmarkDataWithOptions(NSURLBookmarkCreationWithSecurityScope, nil, #Err);
...
Maybe there should be a call to Wrap(...) instead of Create.
I have not yet experimented with it, because it is pointless without the answer to issue 1).
It seems no one has written anything about these problems for Delphi, but I hope someone here has experience with that.
Thanks in advance.
Edit:
For problem 1) I tried to add edit manually the ".entitlements" file in the OSX32 folder and set it to read-only to prevent it from being overwritten. It was too easy to be true of course, because the linker complained that the file can not be modified...
OK, I finally found the way to manually add entitlements that are not available in the Project Options > Entitlements.
Instead of selecting the "App Store" build in the Project Manager you have to select a Normal release build and deploy the application as usual.
The application gets deployed in the PAServer scratch-dir as APP package. Inside this package there is an "Entitlements.plist" file, which is in XML format and can be edited with a text editor. It is quite obvious how to add new entitlements once you open the file.
After it is edited, the app has to be code-signed manually and a package has to be prepared. It is slightly more complicated than using the Delphi IDE, but there are instructions about it on the Embarcadero and Apple websites and it actually went without problems.
Still haven't tried the bookmarkDataWithOptions functions.
An alternative could be to deactivate the checkbox for the entitlements-file in the deployment page.
But attention: Evry time you change between Build/Release or App Store/Normal, delphi activates the checkbox. That means you have to deactivate it again in the deplayment-page, to avoid the transfer of this file to the mac PC.
By the way: Do you have tryed meanwhile the StartAccessingSecurityScopedResource function?
In the MacApi.Foundation unit the function is not declared in the NSURL interface.
Do you have found a way to use this function?

Resources