Swift how to implement macOS Finder's file downloading progress on file - swift

it's looks like this
https://ibb.co/JysCH5v
https://ibb.co/H45b9xN
I've reference from here
Can you implement OS X's Finder download progress bars from a shell script?
and here
https://gist.github.com/mminer/3c0fbece956f3a5fa795563fafb139ae
but both of them not work,
Finder's file progress not show up, and nothing happen,
I'v intend to implement like safari file download, or google chrome file download effect,
every individual file will have progress bar on it, until file completed,
I'm not mean update progress on my own app view, it's on finder's file
I'm in macOS 10.14.5, Swift5
am I missing something?
Thank you!

Related

Change command line app icon programmatically

I've created a swift command line app for macOS (WITHOUT XCODE, just a simple .swift file), used to build a macOS installer.
When I run the app with sudo swift install.swift, the app is opened with an icon with a terminal app design like this:
Icon
I want to change that icon from the code, would that possible? I'm using Appkit.
You can change the icon by setting NSApplication's applicationIconImage property. That is, if you can obtain an image. Since your program isn't a bundled app, it won't be easy to provide an image with it.
There will be an unavoidable visual glitch when your program exits, though. Its icon will revert to that "exec" icon as it shrinks in the Dock before vanishing. Also, if the icon ends up in the Dock's recently-used applications section, it will be the "exec" icon, there, too. In other words, the icon set programmatically persists only as long as the program runs.
By the way, it's distinctly unwise to run the high-level frameworks with root privileges. It opens a large attack surface that's not really audited for security. You probably want to separate your program into a user app and a privileged helper.

Get rid of file icon shadow when file is not saved in Xcode

When a file was just edited and not saved in the Xcode editor the icon of the file in the right pane is darkened a little, and because I have OCD this drives me absolutely crazy and I end up having to click Ctrl+S every time I do anything as simple as commenting a line of code or moving a button 1 pixel in storyboard.
I am using Xcode 10.1 Beta 2, but this happens in all versions of Xcode.
How do you make it so the file is never darkened?
I have the same problem in Xcode and I always command s everything as well. I have looked for a way to disable this, but for now I don’t think there is a way... Maybe they’ll add a way to turn this off in another update soon :)

Can't configure background image for DMG installation using CMake

I am working with CMake 2.8.10.2 on Mac OS X 10.7.5.
I've configured CMake to build a simple application with Xcode that creates an empty window. I then tried to configure CMake to build a DMG installation of the program specifying a background image using:
set(CPACK_DMG_BACKGROUND_IMAGE /path/to/image)
and custom .DS_Store to set windows size and icon placement using:
set(CPACK_DMG_DS_STORE /path/to/DS_Store file)
Xcode will successfully build the application and create the disk image. When I mount the image it comes up with the correct size and icon placement, however the background is always set to white instead of specified background image.
What is needed to get the background to display properly in the disk image?
Unfortunately no one has responded this question. This has been a frustrating experience, however, it looks like I finally solved it so I'm posting a description here to save someone else the grief if they ever have to deal with this.
In order for a background to work on an installation image, basically two things must happen; the background file must exist within the installation image, and the .DS_Store at the root of the image must be configured to use that background.
The .DS_Store file can be configured by mounting the install image in a writable state and then selecting Show View Options from the Finder's View menu. From there someone will select the Picture option for the Background and drag the background file to the placeholder in the Show View Options panel.
When working with CPack, the trick is to be able to drag the image. When someone sets the background for the installation, builds, and mounts the image it will not look like there is any background to drag to the Show View Options panel. If someone goes into the Terminal and does
ls -a
on the root of the mounted install, that command will list, among other things, a file called background.png. This file does not display in the Finder.
The reason this file displays in the Terminal and not the Finder is because it has an extended attributes that makes it hidden for the Finder. Since the file is hidden from the Finder it is not possible to drag the file to the Show View Options panel. Doing
ls -l#
will reveal what extended attributes are applied to the file. There should be only one called com.apple.FinderInfo. Removing this attribute should make the file visible in the Finder. The attribute can be removed using this command from the Terminal
xattr -d com.apple.FinderInfo background.png
After removing the attribute the background file still will not show up in the Finder right away. Someone will have to eject and remount the install image. Once this has happened, the background file should appear in the Finder and someone can drag it to the Show View Options panel, which will cause the background image to display in the Finder window for the install image. After that, someone can copy the .DS_Store file from the root of the install image and apply it to the CPACK_DMG_DS_STORE attribute, and the background image should appear whenever an install image is built.
#TronThomas response helped me out dramatically. Not to supplant his answer, here's some additional information about the process that I just worked through. For reference, this is with MacOS Sierra and CMake 3.6.2.
Set a background image with set(CPACK_DMG_BACKGROUND_IMAGE /path/to/image)
Create the DMG file using the CPack generator DragNDrop
Mount the image in read/write mode using a shadow file hdiutil attach mypackage.dmg -shadow junk.dmg
At this point, we don't see a background image, but one exists in the folder .background in the DMG file. Our strategy will be to use Finder to make the window exactly how we want, then copy out the .DS_Store file.
On the Finder menu, click View->Show View Options
Under Background:, click the Picture radio button. Then, click the image above the text Drag Image Here. Note, the current view must be as Icons otherwise this dialog will not be there.
In the file dialog, go back to the mounted DMG image. Then, press cmd-shift-. This should show the hidden folders. From here, go into the .background folder and select the background image.
If everything has worked properly, the background image should now be visible.
Adjust the windows size and view or hide toolbars as desired on the View menu. The exact settings will be replicated by the installer.
Copy off the the hidden .DS_Store file in the root directory of the volume to another location. The cmd-shift-. trick can be used view the file or just use the Terminal at this point to copy everything. Note, we can change the name of this file to DS_Store, so that it's not hidden when we store it.
Eject the DMG file from Finder. Delete junk.dmg or any shadow files remaining.
Back in the CMakeLists.txt, set the variable set(CPACK_DMG_DS_STORE /path/to/DS_Store) This is the file that we just created and moved off of the volume.
Rebuild the DMG file with CPack. Everything should be as viewed before.
As a warning, there's a lot of information that gets stored in the .DS_Store file such as file locations, user names, and the like. At the moment, I don't know how to control this information, so be a little careful when distributing the final DMG file. If you're curious as to what's in there, use a hex editor like xxd.
As a brief comment, this process is very obtuse. That said, I don't think it's Kitware's fault. Though, they could document the process better. From what I can tell, the .DS_Store file format is not well documented or disclosed, so we're basically forced to use Finder to make one for us. This is a MacOS issue that probably should be fixed.

My recent changes in NIB file is not displayed in ios simulator-closed

I've applied changes in interface builder for my app which has labels in it. I just changed the name and position of a label and in addition to that I changed the font of a text view in my app. When I started to run my app, the font remains the same as previous one and none of the labels are displayed in it.
Can anyone help it pls?
in Xcode try this: main menu:product:Clean
if not enough: main menu:Xcode:preferences: -> click over locations icon:
click over the little gray right arrow for derived data:
that will show you the finder folder "DerivedData": delete it.
one other thing to try: in simulator, delete your app.
quite your xcode and then again open your project . Clear your build then run your code.
You should also make sure, that the interfacebuilder file is linked to the target you are starting in simulator.
To do this, select your xib and open the File inspector. There you should see a dropdown named "Target Membership" where you can link the xib to the targets you want.
Also be sure to have the labels defined as IBOutlets in your header file and link them correctly in your xib. Easiest way to do this is using the Assistant Editor and drag the outlet to the header file.
I had the same problem - but only on the iPhone non-retina in the simulator. Cleaning the code did not help. Restarting and rebooting did not help. But removing the app from the simulator worked. Now changes to my UI show up next time I run.
To remove the app from the simulator I did it just like on a real phone. I select the app icon with the mouse and hold it down the mouse button for a few seconds. Then the icon displays a small delete icon that you can select (the app icons shakes too).

How to drag & drop file in xcode?

when i drag and drop any files than its show like below image.
so i want to know that what is "PrizeperdayTests"?
is i have to checked it when adding some files? what if i not cheked it? i ask this question because when i run my app from Xcode it will run but when i try to run my app using api file than its just close instantly.
This is a unit test target created by Xcode, probably as part of the project template you chose.
Unless you are dragging in files required by your unit tests, you can leave "PrizeperdayTests" unchecked.