Rakuyo
Rakuyo

Reputation: 631

How do I use prepare_command to modify the info.plist file of the host project

I have a private pod, its role is to manage some "IconFont", it contains a .ttf file.

I hope my other projects will automatically register this font in the info.plist file when they rely on this pod

I wrote a script:

s.prepare_command = <<-CMD
    cd ..

    project_path=$(cd `dirname $0` ; pwd)
    project_Name=${project_path##*/}

    if [[ -f "Other/Info.plist" ]]; then
        infoPlist=$project_path"/"$project_Name"/Other/Info.plist"
    else
        infoPlist=$project_path"/"$project_Name"/"$project_Name"/Other/Info.plist"
    fi

    /usr/libexec/PlistBuddy -c 'Add :UIAppFonts array' $infoPlist
    /usr/libexec/PlistBuddy -c 'Add :UIAppFonts: string iconfont.ttf' $infoPlist
CMD

As far as I know, the prepare_command command will be carried out in the Pods directory (may not be this directory?). When I encapsulate the above code as register.sh and execute sh register.sh in the Pods directory, this code works —— Added UIAppFonts field in info.plist of host project.

Maybe prepare_command does not meet my needs?

How can I solve this problem? thank!

Upvotes: 1

Views: 326

Answers (0)

Related Questions