Shell Script Invocation Error in Xcode 6 - ios

I used to compile universal static library with iOS-Universal-Framework, and works fine until I upgrade Xcdoe to 6.
I got the following error
** BUILD SUCCEEDED **
Create universal static library
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool -static /Users/taofang/Library/Developer/Xcode/DerivedData/xxxxx/Build/Products/Debug-iphoneos/xxx.framework/xxx /Users/taofang/Library/Developer/Xcode/DerivedData/xxxxx/Build/Products/Debug-iphonesimulator/xxx.framework/xxx -o /Users/taofang/Library/Developer/Xcode/DerivedData/xxxxx/Build/Products/Debug-iphoneos/xxx.framework/xxx.temp
error: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool: can't open file: /Users/taofang/Library/Developer/Xcode/DerivedData/xxxxx/Build/Products/Debug-iphonesimulator/xxx.framework/xxx (No such file or directory)
If i use Xcode 5 to do the job, it will be fine.
Beside, I selected Device as my compile target, but why the libtool tries to open a file under iphonesimulator folder?

That means there are no header files in any of your build folders. It may be because you haven't configured your library project to export any header files.
Go to your Project Target >> Build Phases >> + sign >> Add a new build phase
You need to add a Copy files Phase that copies the headers you want to the include folder.

Instead of chmod a+x [PATH], I could resolve it with chmod 777 [PATH].

You can use the following command to recursively own all the files and folders in the path like...
chmod -R 777 ./
For more details:
Chmod 777 to a folder and all contents

Related

Xcode 10 warning: Stale file '/path/to/file' is located outside of the allowed root paths

Xcode 10 produces this warning when running xcodebuild in a run script phase of a build target. I do this to produce the binary for the other platform (simulator/real device) to lipo into a fat binary for distribution. The warning is produced for every file in the target intermediates directory, for example:
warning: Stale file '/Users/nick/Library/Developer/Xcode/DerivedData/App-ctjxvxdmomwoobfgvvasfhwvcnhy/Build/Intermediates.noindex/Library-Target.build/Debug-iphonesimulator/Sub-Library-Target.build/Objects-normal/i386/Sub-Library-Class.o' is located outside of the allowed root paths.
What are the root paths? Why is this warning produced? Is there any way I can resolve or suppress it?
I had it on Xcode 11.2
solved it by
1. Clean (Cmd+Shift+K) and then:
Cmd+Shift+R ( build for Running )
For some reason you might have copied the .framework to an external path. To solve this annoying warning you should run (as sudo) the command to delete the framework:
In your case:
sudo rm -rf /Users/nick/Library/Developer/Xcode/DerivedData/App-ctjxvxdmomwoobfgvvasfhwvcnhy/Build/Intermediates.noindex/Library-Target.build/Debug-iphonesimulator/Sub-Library-Target.build/Objects-normal/i386/Sub-Library-Class.o
If you are using Objective-C to create frameworks you may end up with those anoying warnings. The solution I've found is to add
-UseModernBuildSystem=NO
at end of every xcodebuild command in your Run Script.

"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.

PJSIP Integration proper guiding step to run in xcode 7

I had tried to compile pjsip library.but getting error. when run
$ cd /pjproject-2.5.5
$ ./configure-iphone
//error: -bash: -bash: ./configure-iphone: Permission denied
$ chmod +x configure-iphone //then i tried this
$ ./configure-iphone
//error:-bash: ./configure-iphone: /bin/bash^M: bad interpreter: No such file or directory.
Please give me proper guide line by steps to
run pjsip ios project.
To compile pjsip for iPhone
1. Download source code from one of the following link :
http://www.pjsip.org/download.htm
http://trac.pjsip.org/repos/wiki/Getting-Started/Download-Source
2. Create a new file config_site.h in the project folder /pjlib/include/pj/ with the following code:
#define PJ_CONFIG_IPHONE 1
#include <pjconfig_site_sample.h>
3. To Build PJSIP
Open terminal:
$ cd /path/to/your/pjsip/dir
$ ./configure-iphone
You may get the following problems:
a) Permission denied
Solution: preface the login with sudo
or login as super user using su command and the type following command
$ su
Password:
# chmod 777 configure-iphone
# exit
b) -bash: ./configure-iphone: /bin/bash^M: bad interpreter: No such file or directory
(This error may come because in the configure-iphone file every line may have been appended by a character $ or may be a carriage return symbol)
To check this do as:
$ vim configure-iphone
(It wil open the vim editor)
To see the last character press escape(ESC:)set list
To quit vim press Esc:q
Then Eliminate
$ tr -d '\r' <configure-iphone >FILE.new
(It will create new file with name FILE. Now after that delete the configure-iphone file and rename FILE to configure-iphone using the following commands:)
$ rm configure-iphone
$ mv FILE.new configure-iphone
(Again confirm that new created file has 777 permission if no then assign from su- super user)
$ ./configure-iphone
Again there may be error in ./configure-iphone:
Permission denied
Solution : Assign 777 permission to the whole folder.
- $ cd .. (Go to the parent folder in which the PJSIP folder lies)
- $ su (login as super user)
- # chmod 777 * (It will assign 777 permission to the whole folder and its content)
Alternatively:
- $ chmod u+x configure-iphone
Again run $ ./configure-iphone command. This time every thing should work fine.
4. To make
make dep && make clean && make
Source: http://gaurav-iphone.blogspot.com.au/2011/09/compiling-pjsip.html
To compile pjsip for iOS you need to execute following commands:
cd path_to_pjsip
./configure-iphone ( or sudo ./configure-iphone )
make dep && make clean && make ( or sudo make dep && make clean && make)
That's it, you now have pjsip compiled for armv7 architecture. You may also look in this tutorial for more details: http://www.xianwenchen.com/blog/2014/06/09/how-to-make-an-ios-voip-app-with-pjsip-part-1/
To integrate PJSIP with Xcode,follow these steps.
step 1: Download PJSIP project file(.tar.bz2 or .zip file) from this link http://pjsip.org/download.htm
step 2: Extract the files into your Required path of your MAC.
step 3: Open the project folder and you will see,there is pjlib folder is there. Go to the Path pjlib/include/pj/ and create config_site.h file and PASTE the following contents into the file.
#define PJ_CONFIG_IPHONE 1
#include <pj/config_site_sample.h>
step 4: Now save and close the file. And Open the Terminal Now.
step 5: Open your project path in the terminal by cd /your_pjsip_path/
For Example: cd /Desktop/pjsip_2.5.5/
step 6: Now build and configure project by following commands.
step 7: ./configure-iphone
step 8: make dep && make clean && make
step 9: Now you can oepn the project using xcode 7 by Go to the path /pjsip_folder/pjsip-apps/src/pjsua/ios/pjsua.xcodeproj and open with xcode.
(or)
To integrate PJSIP Library with Xcode 7, you must follow official PJSIP instructions from their official website.
Source:https://trac.pjsip.org/repos/wiki/Getting-Started/iPhone

Import xcode scheme from command line

Is any way to import an xcode scheme into a xcode project or xcode workspace from command line?
I want to automatize the archive process with a shell script and I want to verify if the scheme exist in the xcode project or xcode workspace, if the scheme doesn't exit import it from a .xcscheme file.
That is actually pretty easy to achieve. As you have figured out already, Xcode schemes are just files that reside in the xcodeproj container "file".
If you want to check if a scheme exists you just need to check if the .xcscheme file is present in either of the following locations: <your_project>.xcodeproj/xcuserdata/<your_user>.xcuserdatad/xcschemes/
<your_project>.xcodeproj/xcshareddata/xcschemes/
If not you just need to copy it there (preferably to the xcshareddata/xcschemes/ folder).
The following code should do the trick:
#!/bin/bash
# Set to your project and scheme
export PROJECT_FILE="MyProject.xcodeproj"
export SCHEME="abc.xcscheme"
# Generate path to shared schemes folder
export SCHEMES=$PROJECT_FILE/xcshareddata/xcschemes
if [ ! -f $SCHEMES/$SCHEME ]; then
# Create folder if necessary
mkdir -p $SCHEMES
# Copy scheme
cp $SCHEME $SCHEMES/$SCHEME
fi

Azure Mobile Services iOS Library fails to build with Release configuration

When archiving my iOS app the Windows Azure Mobile Services library fails to build.
The App builds fine when using Debug configuration.
While running this script:
/bin/sh -c \"/Users/user/Library/Developer/Xcode/DerivedData/myapp-bxucrfbhixkrpqfwaaovtqqpsvyd/Build/Intermediates/ArchiveIntermediates/MyApp\ (testing)/IntermediateBuildFilesPath/WindowsAzureMobileServices.build/Release-iphoneos/WindowsAzureMobileServices.build/Script-E8E37A27161FAA9600C13F00.sh\"
This turns out to be, this script form the "Build Phases" tab:
# Exit immediately on any errors
set -e
# Set some variables
OUTPUT=${BUILT_PRODUCTS_DIR}
WAMS="WindowsAzureMobileServices"
WAMS_FRAMEWORK="${WAMS}.framework"
WAMS_LIB="lib${WAMS}.a"
HEADERS="Headers"
# Create the needed directories for the framework
mkdir -p "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/A"
mkdir -p "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/A/Headers"
# Add the headers and lib to the framework
cp -a "${OUTPUT}/${HEADERS}/" "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/A/Headers"
lipo -create "${OUTPUT}/${WAMS_LIB}" -output "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/A/${WAMS}"
# Set up the links to complete the framework
ln -sf Versions/Current/Headers "${OUTPUT}/${WAMS_FRAMEWORK}/Headers"
ln -sf "Versions/Current/${WAMS}" "${OUTPUT}/${WAMS_FRAMEWORK}/${WAMS}"
ln -sf A "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/Current"
It fails with this error:
cp:
/Users/user/Library/Developer/Xcode/DerivedData/MyApp-bxucrfbhixkrpqfwaaovtqqpsvyd/Build/Intermediates/ArchiveIntermediates/MyApp
(testing)/BuildProductsPath/Release-iphoneos/Headers/: No such file or
directory
I'm assuming that the error corresponds to this line:
cp -a "${OUTPUT}/${HEADERS}/" "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/A/Headers"
I cannot see any differences in the build settings between Release and Debug.
Update
After some investigation I have determined that when Xcode archives a product it does not create the "headers" folder in ${BUILT_PRODUCTS_DIR}. It instead puts them in `/Build/Intermediates/ArchiveIntermediates/UninstalledProducts'. So the script fails.
Setting the "Skip Install" to NO for the Release build and then checking for the existence of the ${INSTALL_DIR} in the script will successfully build the library.
if [ -d "${INSTALL_DIR}" ]; then
cp -a "${INSTALL_DIR}/" "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/A/Headers"
else
cp -a "${OUTPUT}/${HEADERS}/" "${OUTPUT}/${WAMS_FRAMEWORK}/Versions/A/Headers"
fi
However, Xcode failed to build because it can't find the headers:
fatal error: 'WindowsAzureMobileServices/WindowsAzureMobileServices.h' file not found
#import <WindowsAzureMobileServices/WindowsAzureMobileServices.h>
Update 2
Setting "Skip install" to no causes archiving issues, see this question: Compile, Build or Archive problems with Xcode 4 (and dependencies)
So I have removed the script that fails in the build phases and added "${PROJECT_DIR}/../azure-mobile-services/sdk/iOS/src" to the "User Header Search Paths" list.
This is messy and not my preferred solution.

Resources