How to cd to working directory in Xcode Run Script? - ios

I am attempting to add Parse.com crash reporting to my application, but ran into an issue that I can't seem to find a fix to. Their documentation states you should setup a Run Script with the following script:
export PATH=/usr/local/bin:$PATH
cd (path to working directory i.e. - /Users/Username/Documents/ParseProject/parse)
parse symbols "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
The issue I have with this is that it requires an explicit project directory to cd to. That results in obvious problems when using git and attempting to run the same script on another computer.
I have tried changing the cd to a few different options:
cd ${PROJECT_DIR}
cd "$PROJECT_DIR"
cd ./ParseProject/parse
cd ./parse
How can I get this to work so that it'll function across different computers?

I managed to get it to work and was very close before. I had to call cd "$PROJECT_DIR"/parse, which now makes sense in hindsight.
The final Run Script for ParseCrashReporting that I'm using is now this:
export PATH=/usr/local/bin:$PATH
cd "$PROJECT_DIR"/parse
parse symbols "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"

Related

How to access my app’s derived data folder itself?

I’m in the middle of moving my iOS app’s Firebase dependency from CocoaPods to Swift Package Manager.
Firebase’s Crashlytics requires a script to be executed while the app is building (using the Run Script build phase). Back in the CocoaPods days, I used to call the script the way documented by Google: "${PODS_ROOT}/FirebaseCrashlytics/run".
After I’ve switched to SPM, Firebase files are no longer in ${PODS_ROOT}, and there’s no such variable available at all. I know the file I need is now located in the DerivedData folder, specifically it’s at ~/Library/Developer/Xcode/DerivedData/MyApp-abcde/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run. The problem is, the MyApp-abcde folder is not easily referenced.
A Medium post I found suggested using the ${BUILD_DIR} build variable (in regard to the example above, it would resolve to <…>/MyApp-abcde/Build/Products), and calling the dirname command to move up the directory hierarchy.
This hack worked only for running the app. When I tried to archive it, ${BUILD_DIR} resolved to another path, namely <…>/MyApp-abcde/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath. I tried a few more build variables, such as ${SYMROOT}, in place of ${BUILD_DIR}, but they also produce different paths depending on the operation.
So, here comes the question…
Is there a way to reliably reference my app’s derived data folder’s root (i.e. ~/Library/Developer/Xcode/DerivedData/MyApp-abcde) using Xcode’s build variables?
You were close. This should work:
${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
Crashlytics run script
To build&run from Xcode:
${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
To archive for distribution from Xcode Server at CI/CD:
${XCS_DERIVED_DATA_DIR%/*}/Dependencies/checkouts/firebase-ios-sdk/Crashlytics/run
To work for both at the same time:
if [[ "${XCS_DERIVED_DATA_DIR}" == "" ]]; then
${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
else
${XCS_DERIVED_DATA_DIR%/*}/Dependencies/checkouts/firebase-ios-sdk/Crashlytics/run
fi
I'm reworking my answer as I realized I haven't answered your question..
I have a run script that copies the build targets into a new folder. This works for both Build and Archive. Note that you need the -L on copy to follow the symlink
# Copy the built framework into a sibling to the project folder
if [[ "$CONFIGURATION" == "Debug" ]]; then
mkdir -p "$PROJECT_DIR/../../iwins-ios-sdk/debug"
rm -rf "$PROJECT_DIR/../../iwins-ios-sdk/debug/IWiNS_SDK.framework"
cp -LR "$BUILD_DIR/Debug-iphoneos/IWiNS_SDK.framework" "$PROJECT_DIR/../../iwins-ios-sdk/debug"
else
mkdir -p "$PROJECT_DIR/../../iwins-ios-sdk/release"
rm -rf "$PROJECT_DIR/../../iwins-ios-sdk/release/IWiNS_SDK.framework"
cp -LR "$BUILD_DIR/Release-iphoneos/IWiNS_SDK.framework" "$PROJECT_DIR/../../iwins-ios-sdk/release"
fi
Also, you can find all of the build envvars here:
https://gist.github.com/gdavis/6670468
So, it appears that $BUILD_DIR is different for build/release, but by copying the files to a known location at build time, you'll know where to find them.

"config.h" file not found in iOS project of React native

In X-Code project of react native, getting error
config.h file not found.
Here is version detail :
react-native-cli: 2.0.1
react-native: 0.51.0
How to solve it?
Close Xcode.
Open Terminal, go to your project's root folder and run:
cd node_modules/react-native/third-party/glog-0.3.4/
Run the configure script:
./configure
Open Xcode and try to run your app.
I had the same issue, using this steps solves for me:
Running into the same issue here after upgrading from 0.44. None of the above solutions or clearing caches did the trick for me. Here's what I did to get things working again:
In the Terminal, navigate to the react-native/third-party/glog folder inside node_modules (for me, this was cd node_modules/react-native/third-party/glog-0.3.4)
Once actively in this folder, run sh ../../scripts/ios-configure-glog.sh
Glog is configured and the required config.h header file is created for Xcode to find
Run your iOS BUILD
Regards!
When project files get messed up for me. I typically follow these steps.
rm -rf node_modules
npm install
react-native upgrade (Only changing affected files, so IOS for you)
react-native link
npm start --reset-cache
(In another terminal)
react-native run-ios
These steps worked for me:
rm -rf ~/.rncache
rm -rf node_modules/
npm install
npm start
You need to change to the legacy build system in Xcode 10 and install third party scripts manually.
1:
File -> Project/Workspace settings
Build System: dropdown -> change to Legacy Build system
2: Follow this to manually install third party scripts for RN:
Clean RN cache
$ rm -rf ~/.rncache
Re-install the deps
$ cd your_project_path
$ rm -rf node_modules/ && npm install
Then install the third-party
$ cd node_modules/react-native/scripts
$ ./ios-install-third-party.sh
Run the commands below if glog installation failed.
$ cd ../third-party/glog-0.3.x
$ ./configure
It works for me, I hope it helps for you.
If above all answers don't work,
Please check that there is no space in any directory name of the full path and not only the project directory name.
While in terminal, it accepts throgh My Disk as My\ Disk but xcode do not recognize that.
If its in My Disk directory, try after moving it to Desktop or any other directory which doesn't have space in their name.
configure: error: unsafe absolute working directory name Issue:
-Open Terminal, go to your project's root folder and run:
cd node_modules/react-native/third-party/glog-0.3.5/
Run the configure script:
./configure
got error: configure: error: unsafe absolute working directory name
try to created app in desktop and from there run ./configure command.
Please note with XCOXE 10, and Mojave MAC OS , I had same issue, ./configure was showing some permission issue, I had set permission "777" to project folder enclosing with inner folders
This is the linking issue in xcode. You just need to re-link the files.
Please follow the below steps:
Open you peoject's root directory then open node-module -> react-native -> React.
Open React.xcodeproj file in xcode.
You will see missing (showing red in color) files under the third-party folder
Just run the React.xcodeproj project.
After completion close this project & open you project file.
Delete Drive data & Clean the project & run.
If after running the project you are getting linking issue then please make sure you have added all the (ios) products () come under the Libraries -> React.xcodeproj -> Products in your Build Phases -> Link Binary With Libraries.
If everyone has tried solving the issue by this
Open Terminal, go to your project's root folder and run:
cd node_modules/react-native/third-party/glog-0.3.4/
Run the configure script:
./configure
But still not got the solution then,
Go to your Xcode and check if there any library is missing. Add that library and then perform this above step.
Although the already mentioned answers are correct but still few guys are struggling, as only configuring the glog doesn't sometimes resolve the error.
Here I have written a detailed solution to the problem.
Solution: config.h file not found mutex.h During Archive.
The steps are the following:
Remove node_modules directory
Clear Cache
Install packages again with Yarn
Install third party
Configure Glog
Make & Make install glog
For all these above steps the I have shared commands in the above mentioned article, so not going to write again. I hope it will solve problem for guys who are still struggling.

linphone library compile issue xcode 7.3 MAC OS El Capitan v10.11.4

I have download linphone open source VoIP project from git.
Follow steps that given in link but i have stuck on one steps
Link host strings to simulator SDK
$ sudo ln -s /usr/bin/strings /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/strings
->I have checked below path
"/usr/bin/strings" and found that 'strings' not found and also another path not work '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/strings'
->When command run at that time it fail with below reason
ln: failed to create symbolic link '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/strings': No such file or directory
-> On Build I have received below output.
*******************************************************************************
This makefile is deprecated. Please see README.md for compilation instructions. Here are some equivalents:
Equivalent of make is: cd ../../ && ./prepare.py && make
Equivalent of make enable_gpl_third_parties=no is: cd ../../ && ./prepare.py -DENABLE_GPL_THIRD_PARTIES=NO && make
Equivalent of make enable_debug=yes is: cd ../../ && ./prepare.py -d && make
Equivalent of make enable_i386=yes is: cd ../../ && ./prepare.py all && make
Equivalent of make enable_zrpt=yes enable_opus=yes enable_ffmpeg is: cd ../../ && ./prepare.py -DENABLE_ZRTP=YES -DENABLE_OPUS=YES -DENABLE_FFMPEG=YES && make
*******************************************************************************
Below Link I have referred
1) https://libraries.io/github/mfrager/linphone-iphone
2)
https://github.com/BelledonneCommunications/linphone/blob/master/README.macos.md
3) https://ohthehugemanatee.org/blog/2015/10/01/how-i-got-el-capitain-working-with-my-developer-tools/
->I have checked below path "/usr/bin/strings" and found that 'strings' not found and also another path not work
Firstly you have to generate strings file at this path anyhow.
After that please check that whether your Xcode in Applications have name as Xcode.app or Xcode7.3.app
This makefile is deprecated. Please see README.md for compilation instructions.
For this error, it may occur because you are trying
$ make all
this command
Instead try this:
./prepare.py && make
For more info, regarding home-brews, etc, follow correctly(as you mentioned you'r following it):
building linphone-sdk
Also give all the permissions(rwxrwxrwx) to linphone-sdk directory and all other related files
I've followed this for iOS project.
Hope this will help you!
For HomeBrew make sure run:
brew update then
brew doctor
to double check. Also refer to http://www.successmonkey.co.nz/blog/building-linphone-for-ios
After the dependencies are installed run ./prepare.py and make to compile everything (had a easy fix in submodules/linphone/mediastreamer2/src/basemsfactory.cs) then use Xcode the build the final application.

Access iOS filesystem without jailbreak?

I would like to write/use an open source script that can access iOS filesystem (non-jailbroken). On a Jailbroken device, i use ssh/scp to access, transfer data from the device. Intent is to copy some part of the iOS filesystem (say /var/mobile/Applications/xxx-xxxx/Documents) to a Mac, from a non-Jailbroken device, using some script. I see that tools like iFunBox is able to do it. Would like to know it manages to do so.
I came across mobiledevice.h but could not really understand how to use it.
Also, would prefer getting this done over USB.. for a jailbroken device, i use tcprelay.py for doing the usb tunneling. Is there something i can use for a non jailbroken device?
You can install the ifuse tool, which is hosted here: https://github.com/libimobiledevice/ifuse
In order to compile this tool, you will need the a working set of Gnu-tools (make, libtool, etc).
#Don't worry - clang is still default
sudo port install gcc48
NB: Update your .bash_profile (or similar) to include the following:
#Important - this is where your compiled libs will get installed to, so we need this
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/**
The rest of this process should take a few minutes
Install fuse4x
sudo port install fuse4x
Build the dependencies:
Check out: https://github.com/libimobiledevice/libplist, cd into the checkout, and run:
./autogen.sh
./configure
make
sudo make install
Check out: https://github.com/libimobiledevice/libusbmuxd, cd into the checkout, and run:
./autogen.sh
./configure
make
sudo make install
Check out: https://github.com/libimobiledevice/libimobiledevice, cd into the checkout, and run:
./autogen.sh
./configure
make
sudo make install
(If you're on Linux you'll also need to install usbmuxd, after building libusbmuxd and libimobiledevice. . otherwise, for Windows and OSX . . . )
Now build iFuse:
Check out: https://github.com/libimobiledevice/ifuse
./autogen.sh
./configure
make
sudo make install
To use ifuse to access your app's documents directory:
Make a mount directory:
sudo mkdir -p /Volumes/myapp.app
Now mount the app's dir:
ifuse --container <appid> /Volumes/abced.app
Where app id is the name what's displayed in the bundle identifier . . example:
ifuse --container mycompany.ABCED.com /Volumes/abced.app/
(Refer to the attached pic)
The MobileDeviceManager library brings us simple filesystem operations (it's an easy-to-use Objective-C wrapper around the MobileDevice framework you have come across).
The thing is that it doesn't support copying files from the device to the computer, only the other way around. So, in order to work around this issue, I've created a patch (GitHub gist) that you can merge into the included sample program to have it understand the copyFrom command.

show ANSI color in Xcode4 debug console

Is there any way to do this?
I wan't to distinguish my Logs by different colors.
To enable ANSI colors in Xcode console install clone https://github.com/robbiehanson/XcodeColors and build. The build process will install the Xcode plugin in the proper directory.
To unsign Xcode clone https://github.com/steakknife/unsign, run make, put the unsign command in the path. Then run the following:
cd /Applications/Xcode.app/Contents/MacOS
sudo unsign Xcode
sudo mv Xcode Xcode.signed
sudo ln -sf Xcode.unsigned Xcode
Note that this is reversible. Just change the symbolic link. Now you need to update the plugin UUID to match the current Xcode version:
XCODEUUID=`defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID`
for f in ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/*; do defaults write "$f/Contents/Info" DVTPlugInCompatibilityUUIDs -array-add $XCODEUUID; done
Now you can use ANSI colors in your Xcode console. It looks like this:

Resources