Announcement

Collapse
No announcement yet.

How to create the proper .pkg file for deployment to the MacStore

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to create the proper .pkg file for deployment to the MacStore

    Since i have gotten so much from the UE4 community, its time to give a little something back.

    I couldn't find any info on how to create the proper files for deployment a Mac build of a game to the Mac store... After some research, this is a step by step guide on you do it. If I've missed something, or if i've got something wrong, please correct me. At least this solution worked for me...

    I think its useful for Blueprint only projects and/or if you don't want to use Xcode to build your project.

    The .app file created by Unreal Engine when you Package your game for Mac is not suitable for Mac Store deployment (at least up to 4.10.1). I will outline below the steps you need to take in order to create the final pkg file that you will upload to iTunes Connect via Application Loader.

    1. First of all you will need to have the proper Developer Certificates in your Mac. For Mac Store deployment you need to have a. 3rd Party Mac Developer Application and b. 3rd Party Mac Developer Installer You can create these certificates in the Member centre of the Apple Developer Program. You must also have the latest Xcode installed.

    2. The .app file created by Unreal Engine has a generic bundle identifier and you will have to edit that with your own (which again you create in the Member centre of the Apple Developer Program. To edit the bundle identifier first right click on the .app file and select Show Package Contents. Then Open Contents/Info.plist. Find the Bundle Identifier record and edit it with your own identifier. Save the file.

    3. There are more things you need to change/ add in your Info.plist. a. Add the LSApplicationCategoryType key and select the relevant category of you app for the Mac Store. Edit the version number to reflect the one of your app, as it appears in iTunes Connect.

    4. Make sure your ICNS file contains both a 512x512 and a 512x512@2x image. Recreate it if needed and place it in your myapp.app/Contents/Resources

    5. In the myapp.app/Contents/Resources you might have a file named RadioEffectUnit.component. Right click on it, show contents and edit the Info.plist file you will find there to match your bundle identifier.

    6. You will need to sandbox your app. Create an myapp.entitlements file somewhere in your disk.. A basic entitlements looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>com.apple.security.app-sandbox</key> <true/>
    </dict>
    </plist>

    7. After than you will need to code sign your app. I found out that you need code sign all libraries included in your app. These libraries reside in yourapp.app/Contents/MacOS/

    The command you will need is the following, and you must run in the Terminal in the same folder as your .app file:

    Code:
    codesign -f -v -s "Your own 3rd Party Mac Developer Application" --entitlements "path_to_your_entitlements" "Path_to_your_app_content_mac_os_folder/libraryname"
    Run it for each library in your yourapp.app/Contents/MacOS/ folder.

    e.g.

    Code:
    codesign -f -v -s "Your own 3rd Party Mac Developer Application" --entitlements "path_to_your_entitlements" "myapp.app/Contents/MacOS/libogg.dylib"
    Finally code sign your .app file with the same command

    Code:
    codesign -f -v -s "Your own 3rd Party Mac Developer Application" --entitlements "path_to_your_entitlements"  "myapp.app"
    if your code sign was successful you will see a message saying "signed bundle with Mach-O thin (x86_64)"

    8. After successfully signing your app you will need to create the proper .pkg, witch you will upload to iTunes Connect

    To do that run the following command:

    Code:
    productbuild --component "myapp.app" /Applications --sign "Your own 3rd Party Mac Developer Installer" --product "myapp.app/Contents/Info.plist" myapp.pkg
    Notice that for the product build you use the Mac Developer Installer certificate.

    This procedure may take a few minutes.

    The created .pkg can be uploaded via Application Loader to iTunes Connect.

    That's all!!!

    I have also create a wiki page at https://wiki.unrealengine.com/MacStore
    Last edited by romfeo; 01-09-2016, 04:49 PM. Reason: Additional steps.
    Asteroids from Photogrammetry plus a mini game available in the UE4 Marketplace

    #2
    Hey Romfeo,

    This is an awesome write up. I have been trying to get my game approved for the Mac App Store, and I finally got the app packaged correctly and sent it off to Apple last week.

    But, once it went into review, it got rejected for this reason:

    The application accesses the following location(s):

    '/Engine/Config/NoRedist'
    '/GameName/Intermediate/Shaders/tmp'
    '/GameName/Intermediate/Shaders/WorkingDirectory'

    The majority of developers encountering this issue are opening files in Read/Write mode instead of Read-Only mode, in which case it should be changed to Read-Only.


    Do you have any idea why it would be using those directories in Read/Write mode?

    I am trying to figure out what to change to fix this problem.

    Were you able to get your app/game accepted on the Mac App Store?

    I can't find hardly any information about the Mac App Store and Unreal Engine 4. The game works fine on the Mac when I run it. I even ran it with a guest account and it worked fine.

    Thanks for any help,
    Shawn
    Last edited by SKH Apps; 01-10-2016, 12:41 AM.
    Shawn
    I like to make stuff! Current Project: Emily Wants To Play Too http://www.emilywantstoplay.com/

    Comment


      #3
      Well, my app is still in "waiting for review", so I am not sure if i have done all that is required. I just know that it got successfully submitted.

      From what you describe I guess that it just needs some more Sandbox Entitlement Keys. Specifically, check out this article and look for the section "File Access Temporary Exceptions":

      https://developer.apple.com/library/...011195-CH5-SW1

      Let us know if it worked for you...
      Asteroids from Photogrammetry plus a mini game available in the UE4 Marketplace

      Comment


        #4
        Thanks for responding. I will look into the extra entitlements. I will tell you if I ever get it accepted to the store.

        On a side note, after I solved how to manually sign the app, I found a program that has a GUI and it made it so much easier. It's called App Wrapper 3. I went ahead and bought the $10 version of it. You can use it as much as you want for a month. Anyway, you drag your app into it, check off all the options, choose your profile, etc... and it makes the changes to the APP file plus creates a PKG. I tested it, and immediately the Mac Store accepted it. Wish I could have found that earlier.

        Now I wish I had a tool that performed all of the tests that the Apple Reviewer performs! It took me 8 hours one day just to upload my game, because it kept getting rejected after upload. Then I finally get it to them correctly, wait several days, and the reviewer rejects it. Sheesh

        Good luck on your review! Let me know if you make it through. Glad to find someone else working on this.

        Shawn
        Shawn
        I like to make stuff! Current Project: Emily Wants To Play Too http://www.emilywantstoplay.com/

        Comment


          #5
          I figured out another clue.

          I used Instruments from Xcode developer tools and watched my game run.

          I chose File Activity then picked my app and clicked record.

          I found in the Directory I/O section several attempts to delete these directories

          ../../../Engine/Config/NoRedist
          ../../../GameName/Intermediate/Shaders/tmp
          ../../../GameName/Intermediate/Shaders/WorkingDirectory

          It actually makes 50 rmdir calls on the first one.

          Those are the ones Apple mentioned. I need to figure out why and how I can change this.
          Shawn
          I like to make stuff! Current Project: Emily Wants To Play Too http://www.emilywantstoplay.com/

          Comment


            #6
            Got rejected today for the same reason as SKH Apps.

            Plan A

            Try and sandbox the directories in question.

            If my app gets rejected once more then I will go to plan b...

            Plan B

            The call to remove Engine/Config/NoRedist is in UnrealEngine/Engine/Source/Runtime/Core/Private/Misc/ConfigCacheIni.cpp

            The calls to remove Shaders/tmp & Shaders/WorkingDirectory are in UnrealEngine/Engine/Source/Runtime/Core/Private/GenericPlatform/GenericPlatformProcess.cpp

            Instruments only report UnrealEngine/Engine/Source/Runtime/Core/Private/Apple/ApplePlatformFile.cpp as the caller of the rmdir command

            Since there is no official answer from Epic I am gonna compile the engine from source and i'll remove the DeleteDirectory references to the above folders, to see if this will allow us to get accepted in the Mac Store.
            Last edited by romfeo; 01-12-2016, 05:38 PM.
            Asteroids from Photogrammetry plus a mini game available in the UE4 Marketplace

            Comment


              #7
              I opened a support ticket with Apple, they didn't respond for a day so I resubmitted my app with the Sandbox exceptions.

              They finally answered my support ticket and told me that they will not let the app go through with the exceptions, that I need to stop it from trying to remove the directories.

              So, I found the same thing as you: ConfigCacheIni.cpp, but I didn't find the GenericPlatformProcess.cpp yet. So thanks for that.

              I am trying the same thing, recompiling the engine after commenting those deletes out.
              Shawn
              I like to make stuff! Current Project: Emily Wants To Play Too http://www.emilywantstoplay.com/

              Comment


                #8
                I also just got my app rejected for trying to access those locations. I explained to them that if their signature system works correctly, then those folders can never exist. Because if they would exist, it would mean that someone modified my signed app. So I think they are being unnecessary annoying.. I mean if the app tries to delete a file (if it exists) and that file will provably never exist, then it should be quite obvious that this can never be a problem. But let's see what they reply.

                Comment


                  #9
                  Well now we have three people on the job!

                  I am trying to rebuild the engine with Xcode but having problems.

                  I am going to keep checking back here throughout the day. If I get anywhere, I will post what I did.
                  Shawn
                  I like to make stuff! Current Project: Emily Wants To Play Too http://www.emilywantstoplay.com/

                  Comment


                    #10
                    full compile &amp; sign tutorial

                    OK so here's the full procedure I used for getting my blueprint-only app compiled for mac and ready for app store submission:

                    1. Added an empty dummy clase to the project from within the UE editor to turn it into a code project

                    2. Apply attached patch to engine source code, to fix the file access problems. As you can see, I commented out the NoRedist deletion and I moved the Intermediate folder into the Application Support path in the sandbox, so that the temporary shader files will be written to a valid location.

                    3. If your app name includes a space, you'll need to patch FMacPlatformMisc::PlatformPostInit to use the correct name instead of the project filename. Otherwise Apple will reject you with "Ref: 3.4 - App names in iTunes Connect and as displayed on Mac OS X should be the same, so as not to cause confusion" because of a name mismatch in the about menu.

                    4. Run Setup.sh in engine source code folder to setup compilation environment.

                    5. Symlink the original development UE4Game.app into your binaries folder. You'll need it for the cooking to work.

                    Code:
                      ln -s /Users/Shared/UnrealEngine/4.10/Engine/Binaries/Mac/UE4Game.app /path/to/src/UnrealEngine/Engine/Binaries/Mac/UE4Game.app
                    6. run this commandline to compile, cook and package your mac app

                    Code:
                      /path/to/src/UnrealEngine/Engine/Build/BatchFiles/RunUAT.sh BuildCookRun -nocompile -nocompileeditor -installed -nop4 -project=/path/to/game/data/MusicFlyingGameFinalMac.uproject -cook -stage -archive -archivedirectory=/path/to/output/dir -package -clientconfig=Shipping -ue4exe=UE4Game -clean -compressed -pak -distribution -nodebuginfo -targetplatform=Mac -build -utf8output
                    7a. I used the Instruments > File Activity tool to verify that UE will not try to write inside the app folder anymore. Otherwise, "2.30 - Apps that do not comply with the Mac OS X File System documentation will be rejected".

                    7b. I used otool -L to verify that the app has no dependencies on external dylibs. The default UE binary refers to @loader_path/libsteam_api.dylib, which will get you rejected with "2.2 - Apps that exhibit bugs will be rejected" if your game doesn't use steam.

                    8. Replace info.plist and icon file in compiled app

                    9. Either remove or sign the radio effect plugin in /Contents/Resources/RadioEffectUnit.component (in my case, I deleted it)

                    10. sign all binaries with sandbox entitlement (attached):

                    Code:
                      
                      codesign -f -v -s  "3rd Party Mac Developer Application: ..."  --entitlements mac_info.entitlements ./Space\ Dance.app/Contents/MacOS/libogg.dylib
                      codesign -f -v -s  "3rd Party Mac Developer Application: ..."  --entitlements mac_info.entitlements ./Space\ Dance.app/Contents/MacOS/libvorbis.dylib
                      codesign -f -v -s  "3rd Party Mac Developer Application: ..."  --entitlements mac_info.entitlements ./Space\ Dance.app/Contents/MacOS/MusicFlyingGameFinal
                    11. make PKG:

                    Code:
                      
                      productbuild --component "Space Dance.app" /Applications --sign "3rd Party Mac Developer Installer: ..." --product "Space Dance.app/Contents/Info.plist" Space\ Dance\ AppStore.pkg
                    12. I then uploaded the PKG with Application Loader
                    Attached Files

                    Comment


                      #11
                      Thanks for that comprehensive guide. Did your app got accepted in the Mac app store?
                      Asteroids from Photogrammetry plus a mini game available in the UE4 Marketplace

                      Comment


                        #12
                        thank you fxtentacle, I will see if I can get this to work today.
                        Shawn
                        I like to make stuff! Current Project: Emily Wants To Play Too http://www.emilywantstoplay.com/

                        Comment


                          #13
                          I finally was able to get it compiled and my game no longer tries to delete those directories. It has been submitted to the Mac App Store again. I will tell you if it was accepted.
                          Shawn
                          I like to make stuff! Current Project: Emily Wants To Play Too http://www.emilywantstoplay.com/

                          Comment


                            #14
                            Yes, after 5 days of waiting it was accepted: https://itunes.apple.com/us/app/spac...e/id1073524962

                            Comment


                              #15
                              I forgot to come back here and update you guys ... My game Emily Wants To Play was also accepted after building and signing the app correctly for the Mac App Store. But an interesting thing happened to one of my customers. They couldn't get the Mac App Store version of the game to open at all, but the game worked fine on the same computer using Steam. The only difference was the Mac App Store version had the changes to get it accepted. It only happened to one person out of many, so maybe its a strange case.

                              Thanks so much for all of your help and information, romfeo and fxtentacle.

                              Here is Emily Wants To Play on the Mac App Store https://itunes.apple.com/us/app/emil...y/id1068368089
                              Shawn
                              I like to make stuff! Current Project: Emily Wants To Play Too http://www.emilywantstoplay.com/

                              Comment

                              Working...
                              X