function hasSharedCode = protectedModelHasSharedUtilityCode(protectedModel)
    % PROTECTEDMODELHASSHAREDUTILITYCODE
    %   Returns true if the protected model's "rtwsharedutils" relationship
    %   contains shared utility code.
    
    % Copyright 2019-2020 The MathWorks, Inc.
    [opts, fullName] = Simulink.ModelReference.ProtectedModel.getOptions(protectedModel);
    currentTarget = Simulink.ModelReference.ProtectedModel.getCurrentTarget(opts.modelName);
    if strcmp(currentTarget, 'sim')
        % If the current target for the protected model is "sim", clear the
        % current target cache so that the default code generation target
        % becomes active.
        Simulink.ModelReference.ProtectedModel.CurrentTarget.clear(opts.modelName);
        currentTarget = Simulink.ModelReference.ProtectedModel.getCurrentTarget(opts.modelName);
    end
    
    year = Simulink.ModelReference.common.RelationshipTargetSharedUtils.getRelationshipYear();
    relName = 'rtwsharedutils';
    sharedUtilsRelName = Simulink.ModelReference.common.constructTargetRelationshipName(relName, currentTarget);
    
    % Just getting the list of files from the protected model does not
    % need a decryption password.
    files = deblank(string(slInternal('getListOfPartsInRelationship', fullName, sharedUtilsRelName, year)));
    
    % shared_file.dmr can be present even when the shared utility code is
    % colocated with the main build folder, so we should ignore it.
    bIgnoreFile = ismember(files, ["shared_file.dmr", "tflSUInfo.mat"]);
    hasSharedCode = ~all(bIgnoreFile);
end