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
It is that you are using an old version of macOS?
The command works ok on my 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
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
andrealpath
. In this case, you need to replacereadlink -f
with the equivalent command in macOS which would be a combination ofreadlink
andrealpath
.Try to change your script in the following way:
Replace:
With:
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 runningbrew install coreutils
. After installing coreutils, you can usegrealpath
as a replacement forrealpath
.So the updated line will be:
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.