HomeiOS Developmentios - In Xcode, find out how to replace a configuration `.xcconfig`...

ios – In Xcode, find out how to replace a configuration `.xcconfig` file through the construct section?


I’ve an iOS utility with a Native configuration and related scheme. This configuration is meant to level to a service hosted on the developer’s personal machine (localhost). For the reason that app is sending requests to this service, it must reference the machine’s IP handle. This IP handle can change time beyond regulation resulting from DHCP, and shall be totally different for every developer anyway.

For these causes, I am making an attempt to provide you with an answer the place the IP handle could be set dynamically in keeping with the machine’s IP the place Xcode is working.
Primarily based on solutions on StackOverflow, this is what I got here up with.

First, my Native.xcconfig file defines this variable: URL = http:/$()/$(LOCAL_DEV_IP_ADDRESS):8080/my-endpoint

Then, I’ve added a Run Script because the final step of the construct phases of my goal with the next bash script:

if [[ "$CONFIGURATION" == "Local"* ]]; then
  filename="${TARGET_BUILD_DIR}/${WRAPPER_NAME}/Native.xcconfig"
  search="$(LOCAL_DEV_IP_ADDRESS)"
  exchange=`ipconfig getifaddr en0`

  sed -i '' "s/$search/$exchange/g" $filename
  echo "$(LOCAL_DEV_IP_ADDRESS) has been up to date with the native machine's IP handle (`ipconfig getifaddr en0`) in '$filename'"
fi

After a construct, I can see that the Native.xcconfig file has been efficiently up to date in my construct folder, however after I run it on a take a look at gadget, the configuration is not affected. Once I make a request, I can see that the URL is about to http://localhost:8080/my-endpoint as a result of the URL in my configuration is http://:8080/my-endpoint.

What am I doing improper and why is not my change affecting the app when it is run on a take a look at gadget?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments