我有一个iOS,我要为其运行一个构建阶段,该阶段从JSON文件读取一个值,将其导出为环境变量,然后在我的Info.plist中读取它。
我目前有:
# Build Scripts/SetAPIVersion
set -e
if ! which jq > /dev/null; then
echo "error: jq is missing. Be sure to git pull `dev-box` and run apply.sh"
exit 1
fi
export API_VERSION =$(cat ../src/version.json | jq .api)
echo "Set API Version to $(API_VERSION)!"
我的应用程序将生成,但是该值似乎未设置。我在这里做什么错了?
答案 0 :(得分:4)
您可以使用此:
plutil -replace APIVersion -string <VERSION> <PATH TO INFO>.plist
您还可以使用PlistBuddy:
/usr/libexec/PlistBuddy -c "Set :APIVersion string <VERSION>" <PATH TO INFO>.plist
如果版本是静态数字(取决于环境),则可以将项目构建设置user defined variable
用于:
答案 1 :(得分:1)
shell解释器作为子进程运行。当它sed
是一个环境变量时,它只会影响该shell解释器进程及其其子进程,而不会影响父进程(即Xcode)或其兄弟进程(其他构建阶段) )。
您可以使Shell脚本构建阶段采用一个输入文件,例如Info.plist.in,然后从中生成Info.plist。它将根据您的喜好将输入转换为输出。例如,它可以使用#define
将特殊字符串替换为其应具有的值。确保适当地配置运行脚本构建阶段的输入和输出。
或者,您可以让运行脚本构建阶段生成一个定义宏的头文件,例如api_version.h,其中API_VERSION
s #include
,def segmented_stylization(self, img, target_size = 3840):
self.g1 = self.seg_graph.as_graph_def()
self.g2 = self.eval_graph.as_graph_def()
start = time.time()
# Here we need to create a combined graph
with tf.Graph().as_default() as g_combined:
# Get both our stylized frame and segmentation mappings by passing in the original frame input
style_input = self.eval_graph.get_tensor_by_name("img_placeholder:0")
style_output = self.eval_graph.get_tensor_by_name("style_outputs:0")
seg_input = self.seg_graph.get_tensor_by_name("ImageTensor:0")
seg_output = self.seg_graph.get_tensor_by_name("SemanticPredictions:0")
seg_map = seg_output[0]
# Take our segmented mapping and identify the pixels corresponding to any human(s) in the picture
hPixels = tf.where(tf.equal(seg_map, self.humanIdx))
# Replace the pixels corresponding to a human
#mframe = tf.scatter_nd_update(style_output, hPixels, tf.gather_nd(resized_img, hPixels))
# mframe = tf.image.resize_nearest_neighbor(style_output (self.output_width, self.output_height))
#mframe = tf.clip_by_value(mframe, 0, 255)
sess_comb = tf.Session(graph = g_combined)
a = sess_comb.run([hPixels], feed_dict = {"img_placeholder:0" : resized_img, "ImageTensor:0" : resized_img})
output_img = sess_comb.run([mframe], feed_dict = {"img_placeholder:0" : resized_img, "ImageTensor:0" : resized_img})
return output_img
Info.plist,并在构建设置中启用对Info.plist的预处理。再次,确保运行脚本阶段的输入和输出正确。