I am trying to build the facebook-ios-sdk as part of my project build phases.
In short, the script checks for the build folder, and if it does not exist runs scripts/build_framework.sh
When executing the build phase script I get the following error:
Check dependencies [BEROR]CodeSign error: code signing is required for
product type 'Static Library' in SDK 'Simulator - iOS 6.0'
The build works as expected when running from the terminal.
The closest SO answer I saw was this, but it appears to be for an older version, and the link to the tutorial provided is no longer valid.
XCode is setting a lot of environment variables, and these must be interfering with the script. If you knew which environment variables were the culprit, you could clear them before running your script, but there are dozens and I didn't want to spend the time figuring that out.
Instead, I decided to run the script without XCODE's environment variables. If you run the script this way, you will only get the PATH environment variable in your new shell. This seems to fix things for me:
env -i PATH=$PATH ./Submodules/facebook-ios-sdk/scripts/build_framework.sh
Related
I created a Go(lang) project in Visual Studio Code. I created a main.go file that I will compile to WebAssembly, and another main.go that I will run as a server (to serve my Web Assembly glue file).
For reference, I'm following the tutorial here: https://golangbot.com/webassembly-using-go/
In a Visual Studio Code terminal, I do the following:
[cd to my wasm source folder with the first main.go]
${env:GOOS} = "js"
${env:GOARCH} = "wasm"
go build -o ../../assets/json.wasm
[cd to my server folder with the other main.go]
go run main.go
[I get the following error]
exec: "C:\Users\...\AppData\Local\Temp\go-build3258126417\b001\exe\main": file does not exist
I was able to run this server prior to the build. What's going on?
This should have just run. But now I'm not able to run the server. I get that strange "file does not exist" error.
I spent a lot of time trying to figure this out and finally got it! Here's the deal:
Either or both of the GOOS and GOARCH environment variables that are required by the build go command (for webassembly) seem to conflict with the go run command. I don't know why. I discovered this in a backwards kind of way.
(TLDR: use different terminals to build and run and don't set these environment variables globally -- set them prior to every build. Use the Terminal>Split Terminal to maintain the build settings between tests! ).
Using the Visual Studio Code Powershell terminal, I set these 2 variables (or so I thought) and then ran the build. Then I ran the server to try to see the fruits of my labor and got a strange error in the Chrome console (something about expecting one magic word but receiving another). It turns out this error is fairly generic and after some googling, determined it probably meant something happened with my build. After trying a few more times unsuccessfully to build, I decided to set the environment variables in windows (as SYSTEM variables) so that I didn't have to keep setting them when I did my build.
I built again (still no build errors), but then when I went to run the server, I got the
exec: "C:\Users...\AppData\Local\Temp\go-build3258126417\b001\exe\main": file does not exist
error. At this point, I couldn't run any of my Go servers in any project. Since the only "global" thing I'd done was set those 2 environment variables, I decided to remove them. I could now run my Go servers. But I still couldn't execute my builds in the browser. What's going on??
I figured that since setting the global environment variables had an effect (albeit, a negative effect) whereas I hadn't experienced that issue when manually setting them directly in the terminal prior to each build, then maybe there was something wrong with the way I was setting the variables (I don't use Powershell very often).
After more googling and some experimentation, I discovered the "correct" way to set these variables in the terminal (noted in my original question). So manually setting them (the right way) prior to the build fixed the build issue (it wasn't building correctly since those variables weren't being set properly).
Now I knew the variable were getting set properly because now I was getting that error when I set them manually prior to the build. So now what?
I killed the terminal after build, and then started a new terminal, and the run was successful.
So bottom line: the GOOS and GOARCH environment variables should not be set when running a server, so don't start a server in the same terminal that you used to build the web assembly code!
In xcode 10.2, there is a run-script build phase. I have a script to copy a framework to a specific pod in DerivedData/somename-someguid/products/etc...
However, it seems that the script is not running first based on the print statements and it fails to find the file. If I manually copy the file there first, I can see the output of my script in the build log and it succeeds.
I tried dragging it up in the build-phase panel. I also tried adding it to the copy-file section, but copy does not understand how to embed with the correct pod.
Is there a way to specify the order of running these scripts? Is there a pre-everything section I don't know about?
Of course, it turns out I had the run script phase on the main app project instead of the pod project targets not realizing it built the pods first. So adding it there fixes it. Saving other noobs from this mistake by leaving the question up....
I need to run a custom shell script on the clean step in Xcode (Xcode 9 to be exact). I have a set of makefiles that build my dependencies, initially I was calling this script in the run script phase, but then the outputs of these makefiles never get cleaned. So I though that if I handled the Xcode environemnt variable ${ACTION} in this script then it could also clean them. The issue is - the script is not called on clean.
There were several posts regarding this so here is what I've tried:
Making an additional aggregate target. I added the target and put a script that handles ${ACTION} from the build environment, but that script is never executed upon clean. When cleaning there is only a Clean.remove clean line in build log.
Making an external build system target (some older posts stated an external script target, but I could not find that in Xcode 9). This then allows me to execute a custom script (if I replace the default /usr/bin/make command to my script), but in this case the ${ACTION} environment variable is not set (I verified this in the build output, it always has export ACTION= in it), thus I cannot distinguish between clean and build phases.
Regarding the aggregate target, it has the output files property, if I specify them - could that make Xcode clean them?
A bit of a zombie, but closest to the issue that I am seeing. This appears to be a bug in the new build system. Using the old build system, the action is set. Two options here:
Use the Legacy build system.
Use separate external targets that call your script and manually pass the action parameter required and swap schemes manually as needed.
As you can see near the screenshot Logs infos pic, the .sh Script can run normal inside terminal, but failed to run via Xcode custom behavior, Is there missing some configuration? I've Googled a lot of infos. still can't solve it. I really need someone's help. Thanks
XCode version: Version 8.3.2 (8E2002)
Add a New Run Script Phase in your projects Build Phases to run a Shell script. You do not need to open -a Terminal:
Update:
How I understand your comment, your actual question is how to get the Xcode project directory. Xcode provides a enviromental variable for this, ${PROJECT_DIR}:
prints:
You can find a list of Xcodes enviromental variables in this repo and helpful information in Apples documentation.
I'm working on a project in Xamarin.iOS, and it happens to go through a build server (running on a Mac).
The build seems to commonly fail, but even with the --verbose or -v it seems to Silently fail. For example, right now, it seems to fail after optimizing the graphics for iOS. The last line of the build says Build complete -- 0 errors, 0 warnings. But then I get a Build step 'Execute shell' marked build as failure from Jenkins. I know that this is a failure in the mdtool build, because I have had a successful build before, and I know there are several more steps before it actually succeeds.
The next step in the successful process should be Compiling to native code, but for some reason it fails before getting to that, or at least outputting it to the console.
Thanks in advance for the help!
There's a few places in the mdtool build logic that didn't properly catch exceptions when executing shell programs which I (hopefully) fixed for Xamarin Studio 4.0.2.
Without seeing the full build log it's hard to say for sure, but it might be that whatever shell command that it is trying to execute either doesn't exist or isn't marked with execute permissions.
The programs that I can think of off the top of my head that mdtool will invoke for the iOS builds are:
pngcrush (optimizes .png files)
plutil (optimizes .plist and .strings files)
codesign (although this one gets called after compiling to native code)
and of course, mtouch which is what is used to compile IL to native code. The mtouch command is part of Xamarin.iOS while the other 3 utilities are part of Mac OS X (or Xcode).
The solution for the other person with a similar problem that I helped debug a week or 2 ago was because he had modified his PATH environment that launchd launched apps with to not include /usr/bin and so mdtool couldn't find the utility programs listed above.
I'm not very familiar with Jenkins (I know we use it at Xamarin, but I'm not part of the team that does), so make sure that the PATH environment that it launches mdtool under is setup to include /usr/bin.
Hope that helps.