XCode Swift package manager error behind proxy - ios

We use Swift package manager embedded in XCode for the dependencies in our project. Everything works fine when using it on the local machine. However when I try to build the project on our ci slaves I get the following error (when run from both XCode and the console) :
xcodebuild -resolvePackageDependencies
Resolve Package Graph
Fetching https://github.com/hmlongco/Resolver.git
xcodebuild: error: Could not resolve package dependencies:
An unknown error occurred
The difference between running it locally and on the ci slave is that the ci machines are configured behind a proxy. We already whitelisted all the URLs that were accessed when running this command, however the problem still persists. I couldn't find any detailed log about this error.
From examining the network packages sent when I run the command we can still see that some app is trying to access the direct URL instead of going through the proxy and here timeout is received. We only use public packages on github and there isn't any authentication needed.
From other side if the project is set up the old way using Package.swift and we run:
swift package resolve the dependencies are successfully resolved without errors.
I have already gone through the following but there wasn't any helpful solution:
Configuration for enterprise networks
XCode proxy settings
SPM in real life projects
Same issue on developer forum
SSH error resolving dependencies - no ssh dependencies
Also there isn't any documentation about how resolving the packages through XCode is different than using 'swift package'.
Currently I'm not sure whether it's possible to configure something so XCode uses the proxy settings for SPM or the Xcode SPM through proxy is just not supported. Any ideas? Any help is appreciated!

From what I just found, at least for Xcode 12.4, there's -scmProvider option for xcodebuild:
-scmProvider which implementation to use for Git operations (system/xcode)
If I guess it correctly, -scmProvider system would force xcodebuild use "system" git. That, in turn, in my case, makes it respect the git config settings I have, particularly proxies.
Hence, answering the original question, it's probably worth trying
xcodebuild -resolvePackageDependencies -scmProvider system
(as long as Git config is properly set up)

Turns out there was an easy fix if we just configure the proxy for using it with git:
Getting Git to work with a proxy server - fails with "Request timed out"

Related

Swift Package Manager Dependency Mirroring

I have a project and:
the company I'm working with is self-hosting their git
the CI can communicate only with company's network
That being said, if I want to install any dependency, I have to ask their dev ops to mirror the target repository and only then I can use it.
The problem arises when I want to implement Crashlytics which has a lot of dependencies. When I import the Firebase, it's fetched from the mirrored repo correctly, but it's dependencies are still being fetched from the original URLs (which makes perfect sense).
The question is - How do I tell Swift Package Manager to swap each URL with mirrors? I have all the dependencies mirrored. I only need to tell SPM to use it.
I have found this proposal which was implemented in Swift 5, but when I go to root of my project and run:
$ swift package config set-mirror --package-url <original URL> --mirror-url <mirror URL>
I get this error:
error: root manifest not found
Any ideas how to do this correctly? Thank you
EDIT:
As Florian correctly pointed out, the proposal works from the package's repository, not my projects! So:
I do clone mirrored repo in my project's root
I run set of commands to set mirror url for each dependency:
swift package config set-mirror \
--original-url https://github.com/google/GoogleAppMeasurement.git \
--mirror-url <company's url>/mirrors/githubcom-google-GoogleAppMeasurement
I go back to projects root and run:
xcodebuild -resolvePackageDependencies -project MyProject.xcodeproj -scheme MyAppScheme
But it's still fetching from original urls, not the mirrors!
Having an Xcode project makes this task basically impossible (at the time of writing). Xcode's integration with SPM works fine for most things, but is not (yet?) at par with what SPM can do in pure SPM packages.
The problem is, that swift package config is always only local to the package and does not have any effect on projects / packages that depend on the package. And with Xcode currently having no counterpart to swift package config, it's not possible to do this at the moment.
What you could do, however, is to clone all your dependencies locally and then reference them as local packages from Xcode (simply dragging the package folder into the open Xcode project will do so). Xcode will be smart enough to take the dependencies from the local local checkout (or at least it was smart enough last time I tried this).
Let's hope for a future Xcode version with full SPM support!

Cocoapods cannot install Trunk

I'm trying to develop a React Native mobile app for iOS on Windows 10. Using the react native cli, I've generated a RN iOS project with the standard file structure, including a "Podfile" file with the default RN pods.
However, when I try to use "pod install" in order to add other pods of my own, I get the following error code:
[!] CDN: trunk URL couldn't be downloaded: https://cdn.cocoapods.org/CocoaPods-version.yml Response: SSL peer certificate or SSH remote key was not OK
I've been googling this error but I've run into a dead end. I've tried using pod update, I've changed my cURL version, I've gone over the setup instructions for Ruby, curl, and others, and I'm at a loss. What can I do?
Note: I haven't run the app yet, and am trying to install the react-native-mapbox-gl pod first, but I can't even properly install Trunk.
cURL Version:7.70.0
CocoaPods Version: 1.9.3
You won't be able to develop for iOS on Windows – because the iOS SDK and build tools are only available on macOS. No way to legally do it without an access to an Apple computer.
You can try Expo though – it doesn't require macOS for development, but keep in mind that you will be limited to the APIs Expo provides.
As for the actual error – it seems that the CocoaPods rubygem has not been tested on Windows at all, and is likely invoking curl in a way that doesn't account for Windows's SSL certificate management system.

Visual Studio App Center Private Cocoapod

My iOS project includes some private pods. I have gone through the steps on my local machine (as well as team members) to use private pods outlined here.
How do I add the same process for VS App Center to update and retrieve the repo?
Currently, I get this in the build output:
[command]/usr/local/bin/pod install --repo-update
Updating local specs repositories
Cloning spec repo fooBar from git#github.com:fooBar/Podspec.git
[!] Unable to add a source with url git#github.fooBar/Podspec.git named fooBar.
You can try adding it manually in ~/.cocoapods/repos or via pod repo add.
[error]/usr/local/bin/pod failed with return code: 1
[error]The 'pod' command failed with error: /usr/local/bin/pod failed with return code: 1
Recently I was trying the same and it looks like it's impossible to achieve what you want in way you want.
TL;DR:
Use Carthage for your private dependencies and GIT LFS to store compiled dependency frameworks.
I've used GIT LFS to store Carthage/Build directory (that's actually all you need to compile your app).
I'm still using Cocoapods in my project to maintain public dependencies (somehow it's required in my project).
Why this way?
Because I've found this in AppCenter's docs:
Is your app fairly simple, without many customizations, and is the build pretty straightforward?
In App Center, if your app follows the usual standard layout on the respective platform and does not rely on a lot of external build steps, App Center finds the app automatically in your repository and builds it right away.
(see: Choose the right service for app builds)
So I realised that I really should use the simplest way to build the app on AppCenter. Hope that helps, even thought the answer came after such a long time :)

Xcode Bot CI | Unable to find matching destination

I have setup an Xcode server and using Xcode Bots to do CI in my machine. (Same is used for development.)
Creating a bot for a project, works fine. However, if I add the same project to the workspace, (I have shared the scheme - [which is set to the workspace container] so that is not the issue.) I am getting the below error.
xcodebuild: error: Unable to find a destination matching the provided
destination specifier:
The git currently resides on the Xcode server.
(Followed the steps here)
Also noticed that, once I clone the repository and open the .xcworkspace, the project and the scheme is not displayed.
I suspect this to be the issue. However, not able to find a way to fix this. Any help is greatly appreciated. Thanks!
[Using Xcode version: 7.3.1 on OS X El Capitan v: 10.11.4]

Cordova / Crosswalk Could not resolve all dependencies for configuration ':_armv7DebugCompile'

cordova-plugin-crosswalk-webview seems to be broken out-of-the-box. Tested with cordova 5.1.1 and 6.1.1 on OSX.
Solutions from Crosswalk Could not resolve all dependencies for configuration ':_armv7DebugCompile' and Could not resolve all dependencies for configuration ':_armv7DebugCompile' did not work out.
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
null
org.xwalk:xwalk_core_library_beta:18+
Download https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_library_beta/18.48.477.13/xwalk_core_library_beta-18.48.477.13.pom
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_armv7DebugCompile'.
> Could not resolve org.xwalk:xwalk_core_library_beta:18+.
Required by:
:android:unspecified
> Failed to move file '/private/var/folders/jr/3q77kjzd3yqfw_cllng_7c8c0000gn/T/gradle_download7281456311478481267bin'
I checked e.g. the following: Android Support Repository andGoogle
Repositoryand evenLocal Maven repository for Support` are
installed
Not working with cordova 5.1.? and 6.1.1 and various versions of
crosswalk
PATH and ANDROID_HOME are set
What do I miss?
I see that you use default crosswalk version, so no need install in local. It's available in https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_library_beta/18.48.477.13/.
From the log, it seems that 18.48.477.13 version is not found via network. It may be proxy issue, such as JAVA_OPTS, Gradle, Maven. You can check for whether need them.
Or you can share your steps, let me have a try, the build steps for cordova-plugin-crosswalk-webview work well on my OSX.
We found the problem and the solution.
For some reason the following folders / file were owned by root, not my user such that building xwalk was prevented systemwide because of missing permissions.
Simply move the following to somewhere (delete also works) with sudo:
/Users/palinka/.gradle/caches/modules-2/metadata-2.14/descriptors/org.xwalk
/Users/palinka/.gradle/caches/modules-2/metadata-2.14/module-artifacts.bin
/Users/palinka/.gradle/caches/modules-2/files-2.1/org.xwalk
We got additional debug output by compling with
gradle cdvBuildDebug -P android.useDeprecatedNdk=true --debug
in platforms/android.

Resources