How does InstallBuilder know Mac OS X 10.5 (32-bit) vs 10.6 (64-bit) We have a single BitRock installer xml file that needs to support both 32-bit and 64-bit Mac OSX. That is, we need to copy 64-bit library if we install our application on a 64-bit Mac OSX, or 32-bit library, if we install on 32-bit Mac OSX. In both cases, we call platform “osx”. We just pull respective libraries from different origins, either 64-bit subfolder, or 32-bit subfolder on our source platform. Destination folder is the same for both platforms.

How will BitRock know if we need to copy a library from 32-bit source, or from 64-bit source during runtime?

The xml code that does this is as follows:

--32-BIT Part ---

<component> <name>macosx105files</name> <description>Mac OS X 10.5 Files</description> <folderlist> <folder> <description>Mac configuration folder for MacOS 10.5</description> <destination>${installdir}/modules/lib</destination>

                <platforms>osx</platforms>
                <distributionFileList>
                    <distributionFile>
                                               <origin>../MacOSX/OSX_10.5/libusb-1.0.0.dylib </origin>
                    </distributionFile>
    </distributionFileList>
          </folder>
        </folderList>
    </component>

--64-BIT Part --

 <component>
        <name>macosx106files</name>
        <description>Mac OS X 10.6 and Later Files</description>
        <folderList>
            <folder>
                <description>Mac configuration folder - for MacOS 10.6 and later</description>
                   <folderList>
            <folder>
      <description>Mac configuration folder for MacOS 10.6+</description>
    <destination>${installdir}/modules/lib</destination>

                <platforms>osx</platforms>
                <distributionFileList>
                    <distributionFile>
                                               <origin>../MacOSX/OSX_10.6/libusb-1.0.0.dylib </origin>
                    </distributionFile>
    </distributionFileList>
          </folder>
        </folderList>
    </component>

asked 16 Apr '12, 19:25

Sasha's gravatar image

Sasha
6222323
accept rate: 0%


For detecting version of OSX, you can use <compareVersions> and ${osx_major_version} variable to check the version. For example:

<compareVersions>
    <logic>greater_or_equal</logic>
    <version1>${osx_major_version}</version1>
    <version2>10.6</version2>
</compareVersions>

It is also possible to use uname -m command to detect if OSX is running in 32-bit or 64-bit mode. You can first check it at initialization:

<initializationActionList>
    <setInstallerVariable>
        <name>osx_64bit</name>
        <value>0</value>
    </setInstallerVariable>
    <actionGroup>
        <actionList>
            <runProgram>
                <program>uname</program>
                <programArguments>-m</programArguments>
            </runProgram>
            <setInstallerVariable>
                <name>osx_64bit</name>
                <value>1</value>
                <ruleList>
                    <compareText>
                        <logic>contains</logic>
                        <text>${program_stdout}</text>
                        <value>x86_64</value>
                    </compareText>
                </ruleList>
            </setInstallerVariable>
        </actionList>
        <ruleList>
            <platformTest>
                <type>osx</type>
            </platformTest>
        </ruleList>
    </actionGroup>
</initializationActionList>

The ${osx_64bit} variable will now be set to 1 if system is running in 64bit mode. You can then use folder's rules to determine which file(s) will get installed:

<folder>
    <description>Library 32bit</description>
    <destination>${installdir}</destination>
    <name>library32</name>
    <platforms>osx</platforms>
    <ruleList>
        <isFalse>
            <value>${osx_64bit}</value>
        </isFalse>
    </ruleList>
</folder>
<folder>
    <description>Library 64bit</description>
    <destination>${installdir}</destination>
    <name>library64</name>
    <platforms>osx</platforms>
    <ruleList>
        <isTrue>
            <value>${osx_64bit}</value>
        </isTrue>
    </ruleList>
</folder>
link

answered 17 Apr '12, 05:31

wojciechka's gravatar image

wojciechka ♦♦
7.8k61122
accept rate: 26%

Thank you so much for your detailed answer to us!

So far, we had not implemented this comparative logic in our installer script, but somehow it works?.. I mean, we tested the installer on both 32-bit and 64-bit OSX, and determined that corresponding libraries get copied, without us checking in detail if it is 64-bit or 32-bit. Do we just get by with it? Or BitRock can detect internally which OSX we have? Is it wrong not to check for OSX 64-bit or 32-bit, and rely on BitRock's to SOMEHOW know that? Thank you in advance for your answer.

(17 Apr '12, 13:42) Sasha

It should not work out of the box. Could that be that you are testing in 10.6 so you get the 10.6 version because it overwrites the 10.5 lib? In addition to the solution proposed by Wojciech, have you consider creating an universal library for 10.5 and 10.6 using lipo?

lipo -create MacOSX/OSX_10.6/libusb-1.0.0.dylib MacOSX/OSX_10.5/libusb-1.0.0.dylib -output libusb-1.0.0-universal.dylib

(17 Apr '12, 15:37) juanjo ♦♦

lipo sounds like a great idea. No, haven't looked into it yet, but certainly will. Thanks!

(17 Apr '12, 16:34) Sasha
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×92
×64
×51
×20

Asked: 16 Apr '12, 19:25

Seen: 2,884 times

Last updated: 17 Apr '12, 16:34