Xcode 6 Continuous Integration Bot - Crashlytics failing on build / upload script - xcode

Trying to incorporate Continuous Integration into my Xcode builds.
I have setup OS X Server on my MacBook and everything seems to work fine except for the actual submit/upload script for Crashlytics.
I am getting this error in the 'Trigger' log:
/var/folders/1d/5y5tn0hd1qj01wbxgd3sxrs4000086/T/EFFB7FF5-CFF5-41CF-8AEB-D8813069D831-16127-000004A29A1D79A7: line 2: /Crashlytics.framework/submit: No such file or directory
Couple things to note:
I am able to manually archive/distribute my builds through Crashlytics without any problems.
Crashlytics is installed via PODS and my Run Script looks like this (with my real keys obviously):
${PODS_ROOT}/Crashlytics.framework/submit MYAPIKEY MYCLIENTKEY -emails myEmail#myEmail.com -notesPath ~/Notes/ReleaseNotes.txt -groupAliases myGroupAlias -notifications YES

${PODS_ROOT} is not available to the post trigger action.
You should use
${XCS_SOURCE_DIR}/*RepoName*/Pods/Crashlytics/Crashlytics.framework/submit etc
Where *RepoName* is the name of your repo. Sadly, I haven't been able to find a env variable for it or something.

Related

Google Fabric in Xcode 10 beta

I installed Xcode 10 Beta 6 and I am updating everything and in this process I have run into a small issue with Fabric. Fabric's website has special instructions for Xcode 10 that says:
When I am in Xcode 10 I go to Build Phases an on the Run Script that has my Fabric key there is a + sign under the section Input Fields
When I click the + it automatically generates $(SRCROOT)/newInputFile where newInputFile is automatically highlighted.
I'm not understanding Fabric's instructions. Do I copy the $(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH) after $(SRCROOT)/ Do I replace INFOPLIST_PATH with the file path to my info.plist?
I've tried all these options but Fabric is still crashing in Xcode 10. I know it is Fabric because I've commented out Fabric.with([Crashlytics.self]) in my App Delegate's didFinishLaunchingWithOptions
For Xcode 10 only, user's who face issue in final setup of fabric is your project.
From Xcode 10 you need to make one more setup in Build Phase's Input Files field.
Simply You need to copy this $(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH) and paste to Build Phase's Input Files field under Run Script as display in below image.
Read more on this link : https://fabric.io/kits/ios/crashlytics/install
I had same problem, if your info.plist is in your root directory like this:
yo should change $(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH) like this:
I did exactly what was recommend by Mahdi RB. Also followed the steps on official manual guide, didn't work.
When I build using XCode I see it processes about 2k tasks. The fabric builds usually works when I start the machine, open xcode and execute archive. After that the build starts to break most of the time. I'm using the latest fabric & crashlytics downloaded on 03/OCT/18. It's really weird as it works for my other projects, it's just this one that fails. This started with XCode 10 - Version 10.0 (10A255). It was working with previous XCode 9.
This is some proof of what I'm talking:
My workaround was to add this command before calling the fabric command. E.g
sleep 15
"${PROJECT_DIR}/Fabric.framework/run" aaaaa aaaa
I noticed on my mac console app loads of this error, not sure if it's related:
IBAgent-iOS - assertion failed - libxpc.dylib - and some numbers here.
Error on XCode
2018-10-03 13:53:58.698 uploadDSYM[46168:550157] Fabric.framework/run 1.7.2 (210)
2018-10-03 13:53:58.704 uploadDSYM[46168:550157] Using API Key: "123"
2018-10-03 13:53:58.704 uploadDSYM[46168:550157] Launched uploader in validation mode
error: Fabric: Info.plist Error
Unable to process Info.plist at path /Users/someuser/Library/Developer/Xcode/DerivedData/SampleApp-amwweapikvrbgafmmnyeyorkiufq/Build/Intermediates.noindex/ArchiveIntermediates/SampleApp/BuildProductsPath/Release-iphoneos/SampleApp.app/Info.plist
This could be a timing issue, make sure the Fabric run script build phase is the last build phase and no other scripts have moved Inspector.app from the location Xcode generated it. You can also add '$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)' as an "Input Files" dependency for your Fabric run script build phase.
I tried to open that plist link, it points to a shortcut, and that shortcut points to a real file. Not sure why that is failing. My guess it has something to do with files not being present at the time the script is executed. The delay fixes the issue. I hope this can help.
I removed the original app names for privacy.
fabric info.plist error can be solved by changing the Xcode workspace settings-->build settings--> legacy build system
Go into Build settings of the your target. Find "Debug Information Format". Set this from "DWARF" in both debug and release to "DWARF with dSYM File"
source
I solved this issue by moving the "Run Script" to the bottom of the build phases. Of course I changed to "DWARF with dSYM File" and $(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH).
Add script run phase at end of build phases.
Set Shell for script phase to /bin/bash.
Set input files to:
(1) $(PROJECT_DIR)/$(INFOPLIST_FILE).
(2) $(PROJECT_DIR)/Scripts/set_bundle_build_number.sh
Change path to path of script so changes you make to the script
cause a re-run.
(3) $(TARGET_BUILD_DIR)/$(INFOPLIST_PATH)
Fixes XCode 10 issues of duplicate output phases.
Check image for more reference
The solution for me was to replace the round brackets with curly brackets like this
${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}
You can check if the path actually exists if you call echo $(BUILT_PRODUCTS_DIR) in the script phase. Using round brackets gave me following info in the Xcode build console "BUILT_PRODUCTS_DIR: command not found"
Replacing the round brackets with curly brackets will print the actuall path and therefore the script finally worked for me.
None of the above works for me. If someone using Cocoapods, do these steps.
Add $(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH) to Input Files on Run Script section.
Replace ./Fabric.framework/run to "${PODS_ROOT}/Fabric/run" in Run Script box.
Go to Build Settings, search for Debug Information, Change it to DWARF with dSYM File.
It worked for me, at least.
For me changing the build system to "Legacy Build system" fixed the archiving error.
To change the build system go to File -> Workspace Settings, and change the build system from default "New Build system" to "Legacy Build system".

Run Script with xCode Server Bot

I am running a on-commit Bot to build, analyze, unit tes and archive my App and it works perfectly.
I have a script (*.sh) in my porject that I want to run at the end of a success analysis. I am using xcode 7.3 now and i tried the following:
In the trigger section call ./myscript.sh, but the bot could not find it.
I tried to add $SCROOT, still no luck
I tried to copy the script to bin but since the bot runs under that __xcbuild user it did not see it, and I do not want to mess with adding permission to /bin and /usr/bin
All I want is to run a script against the code the that the bot just pulled on success.
The source used by Xcode CI will be under a cache folder stored in an environment variable called:
$XCS_SOURCE_DIR
Your file should be somewhere under that path

Xcode Server - Bot Integration does not create IPA file

In summary of integration I see a link to ipa file
Environment: xcode7, mac os server 5.0.4
I can't find ipa file after success integration in post integration script.
Log from post build script:
submit Crashlytics: Crashlytics.framework/submit 1.3.5 (15)
submit Crashlytics: No file found at path /Library/Developer/XcodeServer/Integrations/Integration-54550b26ed9ba94f644c10b0691a1634/CIT.ipa
I try used the env var, like this -ipaPath "${XCS_OUTPUT_DIR}/${XCS_PRODUCT}" and got the next error
submit Crashlytics: Crashlytics.framework/submit 1.3.5 (15)
submit Crashlytics: Path must be to an .ipa file. To create an .ipa distribute an archive (ad-hoc) using Xcode.
Try this
"${XCS_OUTPUT_DIR}/ExportedProduct/Apps/${XCS_BOT_NAME}.ipa"
It's the only thing working for me.
According to this wwdc 2015 presentation, XCS_PRODUCT should produce:
Path to an .ipa or .app, if the bot produced one
But it's not working right now...
In the latest Xcode Server 5.1 version just use
"${XCS_PRODUCT}"
In Mac Server 5.2 + XCode 8.2, you have to use
"${XCS_PRODUCT}"
The path is temporary path. It will get deleted once integration complete which means finish the last post-script. So you won't be able to find anything in that path after bot completion.

Copying a file before integration using an Xcode Server bot

I'm setting up a continuous integration (CI) server for our iOS app using Xcode Server. The problem is we have a plist, cred.plist for each person with their credentials and test environment details that is ignored by git and the application will not compile and run without it. There is a file cred_dist.plist that is used to update cred.plist that will work for our CI purposes and I would like to rename/copy it before integration and name it "cred.plist". Both files in the project are in the root directory.
I have tried adding scripts to the CI target and to the bot itself to no avail. Below is an example of an attempt from the bot "Before Integration" script section as well as the error message I receive. I have tried nearly every directory variable I could find including the XCS_ prefix ones, just a slash, and no prefix.
The bot successfully pulls the code from our repo and builds up to the point that the plist is required, then errors.
Any suggestions or help would be greatly appreciated! Thanks!
Script:
#! /bin/bash
cp -a $(TMPDIR)/cred_dist.plist $(TMPDIR)/cred.plist
Error:
Assertion: Reading data: The file cred.plist” couldn’t be opened because there is no such file.
File: MyProject/cred.plist:(null)
After a bit of digging, trial and error, and testing, I believe I have arrived at a solution. The problem is that the XCS_ prefix variable that is closest is XCS_SOURCE_DIR, but that points to where the project is cloned... This means that the path should actually be ${XCS_SOURCE_DIR}/myproject/cred_dist.plist. Below is the script I'm using to perform this task; it runs before the integration - hopefully it will be helpful to someone!
#! /bin/bash
cp -a ${XCS_SOURCE_DIR}/myproject/cred_dist.plist ${XCS_SOURCE_DIR}/myproject/cred.plist

Changing the user executing the build script in Atlassian Bamboo

Here is my problem:
I have a python build script building a .air package and deploying it on a server. If I run this script from a cmd.exe window, there is no problem, the files are correctly created and deployed.
But I would like to use Bamboo to be able to build my app everytime I commit/push changes. I configured it but have a serious problem: the .air package is created but the deployment (with a fabric script) doesn't finish... I noticed that the process is launched by 'Administrator' in a cmd.exe and by SYSTEM trough Bamboo. I think that this is the problem (maybe SYSTEM cannot find the ssh host or whatever), so I wanted to know if someone knows how to change the user executing the script to 'Administrator'.
Yes, you can change the user that your bamboo server runs as. I recently posted an answer with details on how do just that in Windows Mercurial global keychain . All the documentation for the windows stuff in the wrapper file can found at http://wrapper.tanukisoftware.com/doc/english/props-nt.html .

Resources