build AppBundler?

Marco Dinacci marco.dinacci at gmail.com
Fri May 11 03:53:57 PDT 2012


Hi Greg,

I noticed that you included LSApplicationCategoryType in the source, thanks.

However I've found one problems after building my app using the latest
code, the icon is not showing.

The reason is that in main.m you changed the current directory to
NSHomeDirectory before launching the application and since the icon
path is relative to the bundlePath the icon can't be found.

A solution would be to revert the code like it was in rev 20 and
change the directory to NSHomeDirectory after the app has been
launched, something like this:

Index: appbundler/native/main.m
===================================================================
--- appbundler/native/main.m	(revision 23)
+++ appbundler/native/main.m	(working copy)
@@ -72,8 +72,11 @@
     // Get the main bundle
     NSBundle *mainBundle = [NSBundle mainBundle];

-    // Set the working directory to the user's home directory
-    chdir([NSHomeDirectory() UTF8String]);
+    // Set the working directory to the main bundle root
+    NSString *mainBundlePath = [mainBundle bundlePath];
+    if (chdir([mainBundlePath UTF8String]) == -1) {
+        [NSException raise:@JAVA_LAUNCH_ERROR format:@"Could not set
initial working directory."];
+    }

     // Get the main bundle's info dictionary
     NSDictionary *infoDictionary = [mainBundle infoDictionary];
@@ -111,7 +114,6 @@
     }

     // Set the class path
-    NSString *mainBundlePath = [mainBundle bundlePath];
     NSString *javaPath = [mainBundlePath
stringByAppendingString:@"/Contents/Java"];
     NSMutableString *classPath = [NSMutableString
stringWithFormat:@"-Djava.class.path=%@/Classes", javaPath];

@@ -162,7 +164,7 @@
     }

     // Invoke JLI_Launch()
-    return jli_LaunchFxnPtr(argc, argv,
+    int result = jli_LaunchFxnPtr(argc, argv,
                             0, NULL,
                             0, NULL,
                             "",
@@ -173,4 +175,9 @@
                             FALSE,
                             FALSE,
                             0);
+
+    // Set the working directory to the user's home directory
+    chdir([NSHomeDirectory() UTF8String]);
+
+    return result;
 }

Best,
Marco


On 9 May 2012 14:03, Greg Brown <greg.x.brown at oracle.com> wrote:
> Thanks!
>
> On May 9, 2012, at 8:57 AM, Marco Dinacci wrote:
>
>> Hi,
>>
>> I also needed the LSApplicationCategoryType to be generated so I added
>> support for it.
>> It's in this very small patch against the latest svn:
>>
>> Index: appbundler/src/com/oracle/appbundler/AppBundlerTask.java
>> ===================================================================
>> --- appbundler/src/com/oracle/appbundler/AppBundlerTask.java  (revision 20)
>> +++ appbundler/src/com/oracle/appbundler/AppBundlerTask.java  (working copy)
>> @@ -65,6 +65,8 @@
>>     private String signature = "????";
>>     private String copyright = "";
>>
>> +    private String applicationCategoryType = "";
>> +
>>     // JVM info properties
>>     private String mainClassName = null;
>>     private FileSet runtime = null;
>> @@ -121,6 +123,10 @@
>>         this.mainClassName = mainClassName;
>>     }
>>
>> +    public void setApplicationCategoryType(String applicationCategoryType) {
>> +        this.applicationCategoryType = applicationCategoryType;
>> +    }
>> +
>>     public void addConfiguredRuntime(FileSet runtime) throws BuildException {
>>         if (this.runtime != null) {
>>             throw new BuildException("Runtime already specified.");
>> @@ -389,6 +395,7 @@
>>             writeProperty(xout, "CFBundleSignature", signature);
>>             writeProperty(xout, "CFBundleVersion", "1");
>>             writeProperty(xout, "NSHumanReadableCopyright", copyright);
>> +            writeProperty(xout, "LSApplicationCategoryType",
>> applicationCategoryType);
>>
>>             // Write runtime
>>             if (runtime != null) {
>>
>>
>>
>> Best,
>> Marco,
>>


More information about the macosx-port-dev mailing list