Building OSX App Bundle

后端 未结 7 516
[愿得一人]
[愿得一人] 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

    
    
    
    
        CFBundleDevelopmentRegion
        English
        CFBundleExecutable
        MyApp
        CFBundleGetInfoString
        0.48.2, Copyright 2013 my company
        CFBundleIconFile
        MyApp.icns
        CFBundleIdentifier
        com.mycompany.MyApp
        CFBundleDocumentTypes
        
        
        CFBundleInfoDictionaryVersion
        6.0
        CFBundlePackageType
        APPL
        CFBundleShortVersionString
        0.48.2
        CFBundleSignature
        MyAp
        CFBundleVersion
        0.48.2
        NSHumanReadableCopyright
        Copyright 2013 my company.
        LSMinimumSystemVersion
        10.3
    
    
    

    PkgInfo

    APPLMyAp
    

提交回复
热议问题