How to reference current dir from a terminal command - xcode

How do I reference the current dir from a terminal command:
xcrun -sdk iphoneos PackageApplication -v "[current dir]/target/My App.app" -o "[current dir]/target/MyApp.ipa"
[current dir] = how do I get this value?
So basically I don't want to type the whole dir out in the command. I want it to look in the dir where it is currently running

xcrun -sdk iphoneos PackageApplication -v "$PWD/target/My App.app" -o "$PWD/target/MyApp.ipa"

Related

Failed to verify bitcode in BarcodeScannerFramework.framework/BarcodeScannerFramework

I am getting this error when I export adhoc build from XCode 10.2
Failed to verify bitcode in BarcodeScannerFramework.framework/BarcodeScannerFramework:
error: Bundle only contains bitcode-marker /var/folders/fj/0lbn1q2s38943yr8x40lsycc0000gn/T/IDEDistributionOptionThinning.~~~SI1oYn/Payload/eslnativescript.app/Frameworks/BarcodeScannerFramework.framework/BarcodeScannerFramework (armv7)
This error is not related to bitcode. It appeared when the framework contained simulator slices (i386 x86_64)
Adding a run script phase to build phases of the target with following code helped in getting rid of the error.
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[#]}"
rm "${EXTRACTED_ARCHS[#]}"
echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
done
Credits: http://ikennd.ac/blog/2015/02/stripping-unwanted-architectures-from-dynamic-libraries-in-xcode/

Read Xcode Build Settings from terminal

I found you can get a list of all environment variables from my project`s build settings by doing:
xcodebuild -showBuildSettings -project <project>.xcodeproj
It also prints out the PROVISIONING_PROFILE, which I want to use for a build script
PROVISIONING_PROFILE = d0eff791-6b39-4d9b-a164-3e768f63b333
however if I do a
echo $PROVISIONING_PROFILE
or
sudo echo $PROVISIONING_PROFILE
it prints nothing.
How can I access the ${PROVISIONING_PROFILE} variable from outside XCode, like in terminal or a build script?
Probably not the most elegant solution...
export PROVISIONING_PROFILE=$(xcodebuild -showBuildSettings -project <project>.xcodeproj | grep PROVISIONING_PROFILE | cut -d' ' -c3)

How to Run Xcode Project From Terminal in iOS Device?

I want to Install Xcode Project in to iOS Device thru Terminal.I know how to Build Application using xcodebuild clean install this command.I want to launch app in device.Please can any body help me in this task?
I have tried some commands which executes successfully as well but now i am getting the following error when i tried to execute the following command.
xcodebuild -target "GoldenGate" -sdk "iOS 6.1" -configuration Release
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer/
PROJECT="GoldenGate"
SIGNING_IDENTITY="iPhone Developer: Deepak Shukla"
PROVISIONING_PROFILE="${WORKSPACE}/E6FD2816-7827-41AA-AC7E-2DC4833E637C.mobileprovision"
ARCHIVE="$(ls -dt ~/Library/Developer/Xcode/Archives//${PROJECT}.xcarchive|head -1)"
IPA_DIR="${WORKSPACE}"
DSYM="${ARCHIVE}/dSYMs/${PROJECT}.app.dSYM"
APP="${ARCHIVE}/Products/Applications/${PROJECT}.app"
/bin/rm -f "${IPA_DIR}/${PROJECT}.ipa"
/usr/bin/xcrun -sdk iphoneos PackageApplication \
-o "${IPA_DIR}/${PROJECT}.ipa" \
-verbose "${APP}" \
-sign "${SIGNING_IDENTITY}" \
--embed "${PROVISIONING_PROFILE}"
Embedding '/E6FD2816-7827-41AA-AC7E-2DC4833E637C.mobileprovision'
/bin/rm -rf /var/folders/wv/kv98qhfj6v36b2h0fkf_l66w0000gn/T/ouA93u702I/Payload/GoldenGate.app/embedded.mobileprovision
Program /bin/rm returned 0 : []
/bin/cp -rp /E6FD2816-7827-41AA-AC7E-2DC4833E637C.mobileprovision /var/folders/wv/kv98qhfj6v36b2h0fkf_l66w0000gn/T/ouA93u702I/Payload/GoldenGate.app/embedded.mobileprovision
Program /bin/cp returned 1 : [cp: /E6FD2816-7827-41AA-AC7E-2DC4833E637C.mobileprovision: No such file or directory
]
error: Unable to copy '/E6FD2816-7827-41AA-AC7E-2DC4833E637C.mobileprovision' to '/var/folders/wv/kv98qhfj6v36b2h0fkf_l66w0000gn/T/ouA93u702I/Payload/GoldenGate.app/embedded.mobileprovision'
Please help me in this task.
#!/bin/sh
# build.sh
#
# Created by iOSRider on 27/01/2014.
APPLICATION_NAME=MyApp
PROJDIR=/Users/iOSRider/Desktop/MyApp
PROJECT_NAME= MyApp
TARGET_SDK="iphoneos"
PROJECT_BUILDDIR="${PROJDIR}/build/Release-iphoneos"
TARGET_TEST_NAME="MyApp"
BUILD_HISTORY_DIR="/Users/iOSRider/Desktop/MyApp"
DEVELOPPER_NAME="iPhone Distribution: iOSRider India Limited (R8UAKS2M7L)"
PROVISONNING_PROFILE="/Users/iOSRider/Desktop/MyApp/iOS.mobileprovision"
# compile project echo Building Project cd "${PROJDIR}" xcodebuild -target "${PROJECT_NAME}" -sdk "${TARGET_SDK}" -configuration Release
#Check if build succeeded
if [ $? != 0 ] then exit 1 fi
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${PROJECT_BUILDDIR}/${APPLICATION_NAME}.app" -o "${BUILD_HISTORY_DIR}/${APPLICATION_NAME}.ipa" --sign "${DEVELOPPER_NAME}" --embed "${PROVISONNING_PROFILE}"

How do I get a build variable from xcodebuild?

I am using the following command:
xcodebuild -project eagle.xcodeproj -target eagle_test -showBuildSettings
But I need to extract the OBJROOT as part of an external makefile. How would I get this?
Her you go. Parsed all nicely.
xcodebuild -project eagle.xcodeproj -target eagle_test -showBuildSettings | grep "OBJROOT" | sed 's/[ ]*OBJROOT = //'
High level answer: As part of the makefile run the xcodebuild -project eagle.xcodeproj -target eagle_test -showBuildSettings command and parse the output for the value of OBJROOT.

When I type $ gcc into the mac Terminal I get a "-bash: gcc: command not found"

However, it works when I type:
$ gcc-4.2
Find where gcc-4.2 is installed and go into that directory:
$ cd $(which gcc-4.2)
Check if there is a gcc symlink:
$ ls gcc
If there isn't one, create it:
$ ln -s gcc-4.2 gcc
I got it: all was well after I installed command line tools in Xcode > Preferences > Downloads.

Resources