openFrameworks icon indicating copy to clipboard operation
openFrameworks copied to clipboard

Xcode Template Issue - Build defaults to AppStore

Open ofTheo opened this issue 1 year ago • 5 comments

Was testing the nightly builds and found another small regression @dimitre.

In the past we used Debug by default, but in the Nightly Builds it now defaults to AppStore.

Thinking it might be good to switch to Release as the default as sometimes people complain about speed when they first try OF in Debug. Either way prob shouldn't be AppStore.

Curious what you think @ofZach ?

ofTheo avatar Sep 08 '22 20:09 ofTheo

I'll check this out. from what I've seen in the past this settings are saved outside pbxproj file so it is sorted alphabetically by default. I'll se if it is saved inside xcshareddata folder or xcuserdata folder. AppStore by default is not ideal, I'll try to fix it.

Other proposition is totally phase out AppStore template, because the only change from release is rsync data folder to inside .app folder. This can be achieved by other means like some commented out Project.xcconfig setting

dimitre avatar Sep 09 '22 00:09 dimitre

Actually XCode saves schemes order and default in a specific folder which contains the macOS user. Thats annoying because the first (and selected) scheme is the first in alphabetical order (was Debug, so now it is Appstore) Screen Shot 2022-09-09 at 15 11 57

<?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>SchemeUserState</key>
	<dict>
		<key>emptyExample AppStore.xcscheme_^#shared#^_</key>
		<dict>
			<key>orderHint</key>
			<integer>2</integer>
		</dict>
		<key>emptyExample Debug.xcscheme_^#shared#^_</key>
		<dict>
			<key>orderHint</key>
			<integer>1</integer>
		</dict>
		<key>emptyExample Release.xcscheme_^#shared#^_</key>
		<dict>
			<key>orderHint</key>
			<integer>0</integer>
		</dict>
	</dict>
</dict>
</plist>

dimitre avatar Sep 09 '22 21:09 dimitre

Ahh interesting. That's annoying. 🙂

Could AppStore be Release-AppStore? Sort of a hack but maybe that would work?

Also as you said it could also be a Project.xcconfig setting instead

//Uncomment below to bundle the data folder. Use for AppStore distribution. 
#BUNDLE_DATA_FOLDER=1  

ofTheo avatar Sep 10 '22 00:09 ofTheo

Yeah both would work. even if we remove AppStore config, Debug will be before Release. I'll post a diff between AppStore and Release so we can see the little differences, others than bundle data folder

dimitre avatar Sep 10 '22 01:09 dimitre

diff /Volumes/tool/ofw/scripts/templates/osx/emptyExample.xcodeproj/xcshareddata/xcschemes/emptyExample\ AppStore.xcscheme /Volumes/tool/ofw/scripts/templates/osx/emptyExample.xcodeproj/xcshareddata/xcschemes/emptyExample\ Release.xcscheme
26d25
<       buildConfiguration = "Release"
29c28,29
<       shouldUseLaunchSchemeArgsEnv = "YES">
---
>       shouldUseLaunchSchemeArgsEnv = "YES"
>       buildConfiguration = "Release">
41,42d40
<       <AdditionalOptions>
<       </AdditionalOptions>
45,47c43,44
<       buildConfiguration = "AppStore"
<       selectedDebuggerIdentifier = ""
<       selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
---
>       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
>       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
49a47
>       buildConfiguration = "Release"
52d49
<       debugServiceExtension = "internal"
54,55c51
<       <BuildableProductRunnable
<          runnableDebuggingMode = "0">
---
>       <BuildableProductRunnable>
68d63
<       buildConfiguration = "Release"
71a67
>       buildConfiguration = "Release"
73,74c69
<       <BuildableProductRunnable
<          runnableDebuggingMode = "0">
---
>       <BuildableProductRunnable>

dimitre avatar Sep 10 '22 01:09 dimitre

I'm all about removing AppStore and replacing with a define, I would love to discuss some other defines too, so we can standarize naming

dimitre avatar Sep 28 '22 18:09 dimitre

I've thought in separate both actions (Bundle data folder and Code sign frameworks and libraries) like this: Thoughts? @danoli3 @ofTheo

echo "\033[32;1;4m3 - Code Sign\033[0m"

if [ -z "$OF_BUNDLE_DATA_FOLDER" ] ; then
    echo 'Bundle data folder disabled';
else
    # Copy bin/data into App/Resources
    echo 'Bundle data folder enabled - will copy bin/data to App Package'
    rsync -avz  --delete --exclude='.DS_Store' "${SRCROOT}/bin/data/" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/data/"
fi

if [ -z "$OF_CODESIGN" ] ; then
    echo "Codesign Disabled";
#echo "Note: Not copying bin/data to App Package or doing App Code signing. Use AppStore target for AppStore distribution";
else
    echo "Codesign Enabled";

    # ---- Code Sign App Package ----
    # WARNING: You may have to run Clean in Xcode after changing CODE_SIGN_IDENTITY!

    # Verify that $CODE_SIGN_IDENTITY is set
    if [ -z "${CODE_SIGN_IDENTITY}" ] ; then
        echo "CODE_SIGN_IDENTITY needs to be set for framework code-signing"
        exit 0
    fi

    if [ -z "${CODE_SIGN_ENTITLEMENTS}" ] ; then
        echo "CODE_SIGN_ENTITLEMENTS needs to be set for framework code-signing!"

        if [ "${CONFIGURATION}" = "Release" ] ; then
            exit 1
        else
            # Code-signing is optional for non-release builds.
            exit 0
        fi
    fi

    ITEMS=""

    FRAMEWORKS_DIR="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
    echo "$FRAMEWORKS_DIR"
    if [ -d "$FRAMEWORKS_DIR" ] ; then
        FRAMEWORKS=$(find "${FRAMEWORKS_DIR}" -depth -type d -name "*.framework" -or -name "*.dylib" -or -name "*.bundle" | sed -e "s/\(.*framework\)/\1\/Versions\/A\//")
        RESULT=$?
        if [[ $RESULT != 0 ]] ; then
            exit 1
        fi

        ITEMS="${FRAMEWORKS}"
    fi

    LOGINITEMS_DIR="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/Library/LoginItems/"
    if [ -d "$LOGINITEMS_DIR" ] ; then
        LOGINITEMS=$(find "${LOGINITEMS_DIR}" -depth -type d -name "*.app")
        RESULT=$?
        if [[ $RESULT != 0 ]] ; then
            exit 1
        fi

        ITEMS="${ITEMS}"$'\n'"${LOGINITEMS}"
    fi

    # Prefer the expanded name, if available.
    CODE_SIGN_IDENTITY_FOR_ITEMS="${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
    if [ "${CODE_SIGN_IDENTITY_FOR_ITEMS}" = "" ] ; then
        # Fall back to old behavior.
        CODE_SIGN_IDENTITY_FOR_ITEMS="${CODE_SIGN_IDENTITY}"
    fi

    echo "Identity: ${CODE_SIGN_IDENTITY_FOR_ITEMS}"

    echo "Entitlements: ${CODE_SIGN_ENTITLEMENTS}"

    echo "Found: ${ITEMS}"

    # Change the Internal Field Separator (IFS) so that spaces in paths will not cause problems below.
    SAVED_IFS=$IFS
    IFS=$(echo -en "\n\b")

    # Loop through all items.
    for ITEM in "${ITEMS}";
    do
        if lipo -archs "${ITEM}" | grep -q 'i386'; then
            echo "Stripping invalid archs ${ITEM}"
            lipo -remove i386 "${ITEM}" -o "${ITEM}" 
        else
            echo "No need to strip invalid archs {$ITEM}"
        fi

        echo "Signing '${ITEM}'"
        codesign --force --verbose --sign "${CODE_SIGN_IDENTITY_FOR_ITEMS}" --entitlements "${CODE_SIGN_ENTITLEMENTS}" "${ITEM}"
        RESULT=$?
        if [[ $RESULT != 0 ]] ; then
            echo "Failed to sign '${ITEM}'."
            IFS=$SAVED_IFS
            exit 1
        fi
    done

    # Restore $IFS.
    IFS=$SAVED_IFS

fi

dimitre avatar Oct 07 '22 14:10 dimitre

Yeah awesome!

On Sat, 8 Oct 2022 at 1:23 am, Dimitre @.***> wrote:

I've thought in separate both actions (Bundle data folder and Code sign frameworks and libraries) like this: Thoughts? @danoli3 https://github.com/danoli3 @ofTheo https://github.com/ofTheo

echo "\033[32;1;4m3 - Code Sign\033[0m" if [ -z "$OF_BUNDLE_DATA_FOLDER" ] ; then echo 'Bundle data folder disabled';else # Copy bin/data into App/Resources echo 'Bundle data folder enabled - will copy bin/data to App Package' rsync -avz --delete --exclude='.DS_Store' "${SRCROOT}/bin/data/" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/data/"fi if [ -z "$OF_CODESIGN" ] ; then echo "Codesign Disabled";#echo "Note: Not copying bin/data to App Package or doing App Code signing. Use AppStore target for AppStore distribution";else echo "Codesign Enabled";

# ---- Code Sign App Package ----
# WARNING: You may have to run Clean in Xcode after changing CODE_SIGN_IDENTITY!

# Verify that $CODE_SIGN_IDENTITY is set
if [ -z "${CODE_SIGN_IDENTITY}" ] ; then
    echo "CODE_SIGN_IDENTITY needs to be set for framework code-signing"
    exit 0
fi

if [ -z "${CODE_SIGN_ENTITLEMENTS}" ] ; then
    echo "CODE_SIGN_ENTITLEMENTS needs to be set for framework code-signing!"

    if [ "${CONFIGURATION}" = "Release" ] ; then
        exit 1
    else
        # Code-signing is optional for non-release builds.
        exit 0
    fi
fi

ITEMS=""

FRAMEWORKS_DIR="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
echo "$FRAMEWORKS_DIR"
if [ -d "$FRAMEWORKS_DIR" ] ; then
    FRAMEWORKS=$(find "${FRAMEWORKS_DIR}" -depth -type d -name "*.framework" -or -name "*.dylib" -or -name "*.bundle" | sed -e "s/\(.*framework\)/\1\/Versions\/A\//")
    RESULT=$?
    if [[ $RESULT != 0 ]] ; then
        exit 1
    fi

    ITEMS="${FRAMEWORKS}"
fi

LOGINITEMS_DIR="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/Library/LoginItems/"
if [ -d "$LOGINITEMS_DIR" ] ; then
    LOGINITEMS=$(find "${LOGINITEMS_DIR}" -depth -type d -name "*.app")
    RESULT=$?
    if [[ $RESULT != 0 ]] ; then
        exit 1
    fi

    ITEMS="${ITEMS}"$'\n'"${LOGINITEMS}"
fi

# Prefer the expanded name, if available.
CODE_SIGN_IDENTITY_FOR_ITEMS="${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
if [ "${CODE_SIGN_IDENTITY_FOR_ITEMS}" = "" ] ; then
    # Fall back to old behavior.
    CODE_SIGN_IDENTITY_FOR_ITEMS="${CODE_SIGN_IDENTITY}"
fi

echo "Identity: ${CODE_SIGN_IDENTITY_FOR_ITEMS}"

echo "Entitlements: ${CODE_SIGN_ENTITLEMENTS}"

echo "Found: ${ITEMS}"

# Change the Internal Field Separator (IFS) so that spaces in paths will not cause problems below.
SAVED_IFS=$IFS
IFS=$(echo -en "\n\b")

# Loop through all items.
for ITEM in "${ITEMS}";
do
    if lipo -archs "${ITEM}" | grep -q 'i386'; then
        echo "Stripping invalid archs ${ITEM}"
        lipo -remove i386 "${ITEM}" -o "${ITEM}"
    else
        echo "No need to strip invalid archs {$ITEM}"
    fi

    echo "Signing '${ITEM}'"
    codesign --force --verbose --sign "${CODE_SIGN_IDENTITY_FOR_ITEMS}" --entitlements "${CODE_SIGN_ENTITLEMENTS}" "${ITEM}"
    RESULT=$?
    if [[ $RESULT != 0 ]] ; then
        echo "Failed to sign '${ITEM}'."
        IFS=$SAVED_IFS
        exit 1
    fi
done

# Restore $IFS.
IFS=$SAVED_IFS

fi

— Reply to this email directly, view it on GitHub https://github.com/openframeworks/openFrameworks/issues/7068#issuecomment-1271664619, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGK2HFD3RWYP6XQXXRGGELWCAW5ZANCNFSM6AAAAAAQICQUPQ . You are receiving this because you were mentioned.Message ID: @.***>

danoli3 avatar Oct 07 '22 14:10 danoli3