skip to Main Content

i have readlink: illegal option — f error when i’m trying to use product -> archive in xcode ..

i tried to remove the "-f" tag from source="$(readlink -f "${source}")" … and got Rsync error: some files could not be transferred (code 23)

i tried to add this code to podfile but its not working

post_install do |installer|
  installer.pods_project.targets.each do |target|
    shell_script_path = "Pods/Target Support Files/#{target.name}/#{target.name}-frameworks.sh"
    if File::exists?(shell_script_path)
      shell_script_input_lines = File.readlines(shell_script_path)
      shell_script_output_lines = shell_script_input_lines.map { |line| line.sub("source="$(readlink "${source}")"", "source="$(readlink -f "${source}")"") }
      File.open(shell_script_path, 'w') do |f|
        shell_script_output_lines.each do |line|
          f.write line
        end
      end
    end
  end

Note: i’m using mac m1 and the application works well on simulator

2

Answers


  1. It is that you are using an old version of macOS?

    The command works ok on my system:

    # sw_vers 
    ProductName:        macOS
    ProductVersion:     13.4
    BuildVersion:       22F66
    
    # which readlink
    /usr/bin/readlink
    
    # ln -s /System FakeLink 
    # readlink -f FakeLink
    /System
    

    You could try changing your script to use the explicit path /usr/bin/readlink in case you are picking up some unexpected script called readlink.

    Alternatively you could install the GNU readlink and use that

    brew install coreutils
    ln -s /usr/local/bin/greadlink /usr/bin/readlink
    
    Login or Signup to reply.
  2. The issue you are experiencing is because the readlink command on macOS doesn’t support the -f option like it does on Linux. The -f option on Linux is used to provide a canonical absolute name by resolving all symbolic links.

    A similar effect can be achieved on macOS by using the combination of readlink and realpath. In this case, you need to replace readlink -f with the equivalent command in macOS which would be a combination of readlink and realpath.

    Try to change your script in the following way:

    Replace:

    source="$(readlink -f "${source}")"
    

    With:

    source="$(realpath "$(readlink "${source}")")"
    

    However, please note that realpath is not available by default on all versions of macOS. If it’s not available on your machine, you can install it using Homebrew by running brew install coreutils. After installing coreutils, you can use grealpath as a replacement for realpath.

    So the updated line will be:

    source="$(grealpath "$(readlink "${source}")")"
    

    Regarding your Podfile code, you will also need to make a similar adjustment. Replace the -f option with the equivalent command. This should hopefully help in resolving your issue.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search