Carte
Carte copied to clipboard
Issue with build script
The build script is added to all targets in the Xcode project, and this leads to build errors when you have a Watch App and Extension, because the script is copied to the build phase of the Watch App and Extension targets as well, and since Carte does not support watchOS, Xcode isn't able to run the script (because it can't find the script file on the Watch App and Extension paths).
When removing the build script code from the Watch App and Extension targets, the script code is erased from other targets as well.
Currently, I have to modify the build script in Xcode and set it to:
if [ "${TARGET_NAME}" = "App Target Name" ]; then
ruby ${PODS_ROOT}/Carte/Sources/Carte/carte.rb pre
fi
if [ "${TARGET_NAME}" = "App Target Name" ]; then
ruby ${PODS_ROOT}/Carte/Sources/Carte/carte.rb post
fi
It would be nice if the library didn't install the build script on non-iOS targets.
PS: I am on Xcode 9.2
I fixed this by writing a small script in the Podfile that removes the unwanted build scripts from other targets.
Replace PROJ-FILE with your own .xcodeproj file and TARGET-NAME with your own target. If it should remove the Carte build scripts from multiple targets, change the select condition.
project = Xcodeproj::Project.open('PROJ-FILE')
target = project.targets
.select { |target| target.name == 'TARGET-NAME' }
.first
# at_exit blocks will be executed in reverse order.
at_exit {
remove_carte_scripts(target)
project.save
}
pods_dir = File.dirname(lib.pods_project.path)
at_exit { `ruby #{pods_dir}/Carte/Sources/Carte/carte.rb configure` }
I fixed this by writing a small script in the Podfile that removes the unwanted build scripts from other targets.
Replace PROJ-FILE with your own .xcodeproj file and TARGET-NAME with your own target. If it should remove the Carte build scripts from multiple targets, change the select condition.
project = Xcodeproj::Project.open('PROJ-FILE') target = project.targets .select { |target| target.name == 'TARGET-NAME' } .first # at_exit blocks will be executed in reverse order. at_exit { remove_carte_scripts(target) project.save } pods_dir = File.dirname(lib.pods_project.path) at_exit { `ruby #{pods_dir}/Carte/Sources/Carte/carte.rb configure` }
"remove_carte_scripts" ??? What is it?
It's here, sorry.
def remove_carte_scripts(target)
target.build_phases
.select { |p|
p.kind_of? Xcodeproj::Project::Object::PBXShellScriptBuildPhase and \
not p.name.nil? and \
p.name.include?("Carte")
}
.each { |p|
index = target.build_phases.index(p)
target.build_phases.delete_at(index)
}
puts("Removed Carte scripts.")
end