我在MacOSX构建的独立软件包中添加DMG背景的自定义图标很难。我已经在项目的根目录中添加了一个软件包。自定义图标正在从中加载,但DMG背景图标不是。我正在使用Java FX 2.2.3和JDK1.7.0_09。这是对同一的详细输出。
Detected JavaFX Ant API version 1.2 Launching <fx:jar> task from
/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/lib/ant-javafx.jar
Launching <fx:deploy> task from
/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/lib/ant-javafx.jar
Copying 102 files to
/Users/apple/NetBeansProjects/JavaFXApplication2/dist Using base JDK
at: /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk Using default
package resource [Bundle config file] (add package/macosx/Info.plist
to the class path to customize) Using custom package resource [icon]
(loaded from file
/Users/apple/NetBeansProjects/JavaFXApplication2/package/macosx/javaFXApplication2.icns)
Creating app bundle:
/Users/apple/NetBeansProjects/JavaFXApplication2/dist/bundles/JavaFXApplication2.app
Config files are saved to
/var/folders/vd/nyxf14z53tx56g2_lbqcnfrr0000gn/T/build1722966263281326253.fxbundler/macosx.
Use them to customize package. Building DMG package for
JavaFXApplication2 Using default package resource [Bundle config
file] (add package/macosx/Info.plist to the class path to customize)
Using custom package resource [icon] (loaded from file
/Users/apple/NetBeansProjects/JavaFXApplication2/package/macosx/javaFXApplication2.icns)
Config files are saved to
/var/folders/vd/nyxf14z53tx56g2_lbqcnfrr0000gn/T/build1722966263281326253.fxbundler/macosx.
Use them to customize package. Using default package resource [dmg
background] (add package/macosx/JavaFXApplication2-background.png to
the class path to customize) Using custom package resource [volume
icon] (loaded from file
/Users/apple/NetBeansProjects/JavaFXApplication2/package/macosx/javaFXApplication2.icns)
Using default package resource [script to run after application
image is populated] (add
package/macosx/JavaFXApplication2-post-image.sh to the class path to
customize) Using default package resource [DMG setup script] (add
package/macosx/JavaFXApplication2-dmg-setup.scpt to the class path
to customize) Result DMG installer for JavaFXApplication2:
/Users/apple/NetBeansProjects/JavaFXApplication2/dist/bundles/JavaFXApplication2.dmg
Config files are saved to
/var/folders/vd/nyxf14z53tx56g2_lbqcnfrr0000gn/T/build1722966263281326253.fxbundler/macosx.
Use them to customize package.
这是列出我所有图标文件的目录: -
Apples-MacBook-Pro-2:~ apple$ ls -l /Users/apple/NetBeansProjects/JavaFXApplication2/package/macosx/
total 136
-rw-r--r--@ 1 apple staff 1251 Nov 1 19:02 Info.plist
-rw-r--r-- 1 apple staff 18017 Nov 1 18:22 JavaFXApplication2-background.png
-rw-r--r--@ 1 apple staff 902 Nov 2 13:55 JavaFXApplication2-dmg-setup.scpt
-rw-r--r-- 1 apple staff 38115 Jan 19 2006 JavaFXApplication2.icns
您可以看到,即使我在同一目录中添加了该文件,图标也不会从软件包中加载,但DMG背景文件也不是。
OS X中的文件夹背景由Finder设置在.ds_store文件中。如果您小心不要更改后台文件的文件夹路径和名称,则可以使用Finder设置背景图像,然后复制.ds_store文件并在构建过程中复制。如果您想要更好的东西,我们使用此PERL脚本在文件夹上设置背景(它依赖于其他一些Perl库,您应该能够找到它们)。
#!/usr/bin/perl
use Mac::Finder::DSStore::BuddyAllocator;
use Mac::Finder::DSStore;
use IO::File;
use Data::Dumper;
use Config;
use Mac::Files;
use Mac::Memory;
use Mac::Finder::DSStore qw( writeDSDBEntries makeEntries );
use Sys::Filesystem::ID;
use File::Basename;
die "Usage: $0 <Folder path> <bg path relative to folder>n"
unless @ARGV == 2;
$folderPath=$ARGV[0];
while ($folderPath =~ //$/)
{
chop($folderPath);
}
die "$folderPath is not a directory" unless -d $folderPath;
$bgPath=$folderPath."/".$ARGV[1];
die "$bgPath is not a file" unless -f $bgPath;
# When we're setting the background for the root, the info lives
# in the .DS_Store file in the directory, otherwise it lives in
# the parent directory
if (Sys::Filesystem::ID::_arg_to_mount_point($folderPath) eq $folderPath)
{
$dsStoreFile=$folderPath."/.DS_Store";
$ourName=".";
}
else
{
$dsStoreFile=$folderPath."/../.DS_Store";
($ourName, $path, $suffix) = fileparse($folderPath);
}
#print "Setting bg for $folderPath to $bgPath, .DS_Store file = $dsStoreFile ourName=$ourNamen";
#We use byFilename to keep track of the records for everybody
# we will pull out the records for . and remove any BKGD records
@otherRecs=();
@ourRecs=();
if (-f $dsStoreFile)
{
$store = Mac::Finder::DSStore::BuddyAllocator->open(new IO::File $dsStoreFile, '<');
@records=&Mac::Finder::DSStore::getDSDBEntries($store);
foreach my $curRec (@records)
{
if ($curRec->filename ne $ourName)
{
push(@otherRecs, $curRec);
}
else
{
push(@oldRecs, $curRec);
}
}
if ( @oldRecs != 0)
{
foreach $curRec(@oldRecs)
{
if ($curRec->strucId ne "BKGD" && $curRec->strucId ne "pict" && $curRec->strucId ne "bwsp" && $curRec->strucId ne "icvp")
{
push(@ourRecs, $curRec);
}
}
}
}
undef $store;
if ($ourRec == 0)
{
push(@ourRecs, &makeEntries($ourName, ICVO => 1,
icvo => pack('A4 n A4 A4 n*', "icv4", 48, "none", "botm", 0, 0, 0, 0, 0, 1, 0, 100, 1)));
}
@bgRecs=&makeEntries($ourName, BKGD_alias => NewAliasMinimal($bgPath));
@ourRecs=(@ourRecs,@bgRecs);
&writeDSDBEntries($dsStoreFile, @ourRecs, @otherRecs);
您是否尝试过将其chmoding?我发现这是具有类似经验的问题。
chmod 777 backgroundpathhere
在终端中。(只是您不知道)