readlink: xcode 中的非法选项 — f 错误

huangapple go评论67阅读模式
英文:

readlink: illegal option -- f error in xcode

问题

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

我在尝试在Xcode中使用“product -> archive”时遇到了readlink: illegal option -- f错误。

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

我尝试从source="$(readlink -f "${source}")"中删除"-f"标记,但出现了Rsync错误:一些文件无法传输(错误代码23)。

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

我尝试将这段代码添加到Podfile中,但不起作用。

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
}
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
end

注意:我使用的是Mac M1,应用在模拟器上运行良好。

英文:

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

答案1

得分: 1

你是否在使用旧版本的 macOS?

这个命令在我的系统上运行正常:

# sw_vers 
ProductName:		macOS
ProductVersion:		13.4
BuildVersion:		22F66

# which readlink
/usr/bin/readlink

# ln -s /System FakeLink 
# readlink -f FakeLink
/System

你可以尝试修改你的脚本,使用明确的路径 /usr/bin/readlink,以防你意外地执行了某个名为 readlink 的脚本。

或者你可以安装 GNU readlink 并使用它:

brew install coreutils
ln -s /usr/local/bin/greadlink /usr/bin/readlink
英文:

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

huangapple
  • 本文由 发表于 2023年6月15日 03:42:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76477044.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定