Building OSX App Bundle

后端 未结 7 487
[愿得一人]
[愿得一人] 2020-11-29 14:40

Suppose I have have made a an osX app without using Xcode. After compiling with GCC I get an executable which is linked to several other libraries. Some of those libraries m

相关标签:
7条回答
  • 2020-11-29 15:39

    I use this in my Makefile... It creates an app bundle. Read it and understand it, because you'll need a png icon file in a macosx/ folder along with the PkgInfo and Info.plist files i include here...

    "it works on my computer"... I use this for multiple apps on Mavericks...

    APPNAME=MyApp
    APPBUNDLE=$(APPNAME).app
    APPBUNDLECONTENTS=$(APPBUNDLE)/Contents
    APPBUNDLEEXE=$(APPBUNDLECONTENTS)/MacOS
    APPBUNDLERESOURCES=$(APPBUNDLECONTENTS)/Resources
    APPBUNDLEICON=$(APPBUNDLECONTENTS)/Resources
    appbundle: macosx/$(APPNAME).icns
        rm -rf $(APPBUNDLE)
        mkdir $(APPBUNDLE)
        mkdir $(APPBUNDLE)/Contents
        mkdir $(APPBUNDLE)/Contents/MacOS
        mkdir $(APPBUNDLE)/Contents/Resources
        cp macosx/Info.plist $(APPBUNDLECONTENTS)/
        cp macosx/PkgInfo $(APPBUNDLECONTENTS)/
        cp macosx/$(APPNAME).icns $(APPBUNDLEICON)/
        cp $(OUTFILE) $(APPBUNDLEEXE)/$(APPNAME)
    
    macosx/$(APPNAME).icns: macosx/$(APPNAME)Icon.png
        rm -rf macosx/$(APPNAME).iconset
        mkdir macosx/$(APPNAME).iconset
        sips -z 16 16     macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_16x16.png
        sips -z 32 32     macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_16x16@2x.png
        sips -z 32 32     macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_32x32.png
        sips -z 64 64     macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_32x32@2x.png
        sips -z 128 128   macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_128x128.png
        sips -z 256 256   macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_128x128@2x.png
        sips -z 256 256   macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_256x256.png
        sips -z 512 512   macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_256x256@2x.png
        sips -z 512 512   macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_512x512.png
        cp macosx/$(APPNAME)Icon.png macosx/$(APPNAME).iconset/icon_512x512@2x.png
        iconutil -c icns -o macosx/$(APPNAME).icns macosx/$(APPNAME).iconset
        rm -r macosx/$(APPNAME).iconset
    

    Info.plist

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>English</string>
        <key>CFBundleExecutable</key>
        <string>MyApp</string>
        <key>CFBundleGetInfoString</key>
        <string>0.48.2, Copyright 2013 my company</string>
        <key>CFBundleIconFile</key>
        <string>MyApp.icns</string>
        <key>CFBundleIdentifier</key>
        <string>com.mycompany.MyApp</string>
        <key>CFBundleDocumentTypes</key>
        <array>
        </array>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
        <string>0.48.2</string>
        <key>CFBundleSignature</key>
        <string>MyAp</string>
        <key>CFBundleVersion</key>
        <string>0.48.2</string>
        <key>NSHumanReadableCopyright</key>
        <string>Copyright 2013 my company.</string>
        <key>LSMinimumSystemVersion</key>
        <string>10.3</string>
    </dict>
    </plist>
    

    PkgInfo

    APPLMyAp
    
    0 讨论(0)
提交回复
热议问题