Github Actions for project with Swift Package Manager dependency - ios

I'm trying to get Github Actions for project with Swift Package Manager dependency working.
I keep getting this error: xcodebuild: error: Could not resolve package dependencies:15 The server SSH fingerprint failed to verify.
... when Actions runs and Resolve Package Graph fetching the dependency in my project that uses Swift Package Manager.
My step it is failing on:
- name: Build and Test
run: |
xcodebuild clean test -project xyz.xcodeproj -scheme xyz -destination "platform=iOS Simulator,OS=13.3,name=iPhone 8" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO
I've tried adding for ip in $(dig #8.8.8.8 github.com +short); do ssh-keyscan github.com,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts per Xcode 11 resolving packages fails with SSH fingerprint but still can't get it to work, I might be putting it in the wrong place or doing it wrong.
Has anyone got this working that can help me?

I had the same problem and decided to use packages with https urls instead of ssh and it worked fine. If you don't need to access private repos then this is a viable solution.

Related

xcodebuild: error: 'APP.xcworkspace' does not exist

I am trying to set up CI with gitlab. When I try to build locally, I get this error : xcodebuild: error: 'APP.xcworkspace' does not exist.
"APP" not being the real name. I am also using CocoaPods.
This happens after I run this command in terminal:
gitlab-ci-multi-runner exec shell build_project
I have checked and the file does exist in the same folder I call the command.
This is my .gitlab-ci.yml file:
stages:
- build
build_project:
stage: build
script:
- xcodebuild clean -workspace APP.xcworkspace -scheme APP | xcpretty
- xcodebuild test -workspace APP.xcworkspace -scheme APP -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.2' | xcpretty -s
tags:
- v0.0.1
Xcode version: 8.2.1
Cocoapods version: 1.2.0
Gitlab-runner version : 1.11.0
Alex
On React Native I've solved this issue by running command inside /ios folder.
I have solved this now!!
I just had to update the cocoapods repo, se this link:
https://github.com/CocoaPods/CocoaPods/issues/5077
Looks like your specs repo was edited at some point, and now git can't update it. I'd recommend deleting and re-creating your Specs repo: pod repo remove master and running pod setup
In my case i had project with same folder name("Project") ending with 1 , 2 ,3 ,4 (total 5 folders). when i was trying to install cocoapods in "Project 4" Directory it was getting installed in "Project" instead it should be for "Project 4".
I could find Xcworkspace in the folder "Project"
Hence i need to delete other folders with same name and then install pods in "Project" folder
To share a scheme in Xcode:
Choose Product > Scheme > Manage Schemes.
Share your scheme:
Click on the Close button.

Error running xcodebuild parallel jobs with same Cocoa Pod in frameworks & app

We have an Xcode workspace (for an iOS app) which consists of multiple frameworks and a reference application which links to and uses the frameworks and the frameworks themselves as well as the reference application use the same pod (or pods).
I've created a simple application that exhibits the same error, it's up on Github (https://github.com/hds/ios-app-with-sdks). I'll just explain everything in terms on the sample application, as it should be easier to follow that way.
The project dependancy chart looks like this:
AppWithSDKs
|- TheSDK
| |- ReactiveCocoa
|- OtherSDK
| |- ReactiveCocoa
|- ReactiveCocoa
ReactiveCocoa is one of the pods that I'm using in multiple places, so I've used in in the sample project as well. I don't think that ReactiveCocoa has anything to do with this error.
Building this project from the command line with xcodebuild produces a variety of errors, always related to the pod used in multiple parts of project. The most common error is in the code signing step, but I get errors related to setting file permissions and ownership as well. The errors always complain about the file that is to be signed (or have its permissions set) not being present.
The build command is:
xcodebuild -verbose -workspace AppWithSDK.xcworkspace -scheme AppWithSDK -sdk iphoneos8.4 -derivedDataPath Build -configuration Release archive -archivePath Build/Products/
An example of an error that I've seen is:
/usr/sbin/chown -RH <user>:<group> /path/to/project/AppWithSDK/Build/Build/Intermediates/ArchiveIntermediates/AppWithSDK/IntermediateBuildFilesPath/UninstalledProducts/ReactiveCocoa.framework
chown: /path/to/project/AppWithSDK/Build/Build/Intermediates/ArchiveIntermediates/AppWithSDK/IntermediateBuildFilesPath/UninstalledProducts/ReactiveCocoa.framework/Headers/UITextView+RACSignalSupport.h: No such file or directory
Command /usr/sbin/chown failed with exit code 1
The suspicion is that xcodebuild is doing something in parallel that shouldn't be performed in parallel, but I don't know what that is. If we run xcodebuild with -jobs 1 then there are no errors. The project also builds fine when it's compiled from the Xcode app.
Obviously the problem isn't a showstopper at the moment, but if we have to build in serial on the command line, it's going to make our Jenkins builds much slower.
Thanks in advance for any guidance or help.

Teamcity Step tests (Command Line) failed when testing an iOS app

I am trying to run tests automatically using Teamcity, but it seems that when the agent is compiling the project, it is not done correctly because when I run the command like for running test, I am getting the following error:
fatal error: 'Pushwoosh/PushNotificationManager.h' file not found
#import <Pushwoosh/PushNotificationManager.h>
[16:48:51][Step 2/2] ^
[16:48:51][Step 2/2] 1 error generated.
However, when I run manually the same commands I get no errors, but my test running. The application that I want to run was written in objective-c, and the command lines I am using are the following:
$ git clone REPOSITORY_URL (runs sucessfully)
$ pod install (runs sucessfully)
$ xctool -workspace Supermaxi.xcworkspace -scheme Supermaxi test -only FunctionalTests:TestCase000_Registration/test00_WrongEmail -sdk iphonesimulator (fails and I get the previous described error)
After being helped by I friend of mine, we found the solution to this issue in this link.
It turns out that the main problem was, as the link states, that CocoaPods uses symbolic links in it’s directory structure, and TeamCity can have trouble copying symbolic links in the VCS checkout to build agent, so I had to set the Version Control Settings of Teamcity as it is explained in the previous link.
Therefore, I have just changed the VCS checkout mode from Automatically on server to Automatically on agent (if supported by VCS roots). After that I run the agent again, and it worked properly.

xcodebuild linker failing when custom output directory provided

I have a problem using xcodebuild to build the iOS app to custom directory.
Everything works well if I am building using command:
xcodebuild -workspace MyWorkspace.xcworkspace -scheme MyAppScheme -sdk iphoneos -configuration Release ONLY_ACTIVE_ARCH=NO
...but I would like the .app and .dSYM files to be saved in a specific directory (./build for example). So, I tried adding:
CONFIGURATION_BUILD_DIR=./build
or
OBJROOT=./build SYMROOT=./build
as a xcodebuild parameters. Then I've got this error (output comes from xctool as it's more readable, but the same error occurs when using xcodebuild):
✗ Link MyApp
(...)
ld: library not found for -lPods-MyApp-SomePodName
clang: error: linker command failed with exit code 1 (use -v to see invocation)
As I am using Cocoapods, my workspace contains app's project and "Pods" project. I tried using xcodebuild on several other projects that uses Cocoapods and I am always getting this error (SomePodName differs depending on project's dependencies) when trying to provide custom output directory. Please note, that it works without an issue when CONFIGURATION_BUILD_DIR, OBJROOT and SYMROOT parameters are skipped.
I wonder if anything changed recently, because I am pretty sure that I was able to build to custom directory using xcodebuild in the past. Currently, Travis-CI is still able to do it without an issue, but I have no luck when trying on my local machines.
Perhaps providing CONFIGURATION_BUILD_DIR, OBJROOT or SYMROOT is not the perfect way for specifying custom output directory. I am not sure if the problem is connected directly to Cocoapods, but the errors are always connected with some pod library.
Any hints will be appreciated.
My environment:
OS X 10.10.3
Xcode 6.3
xctool 0.2.3
cocoapods 0.36.3
Update: Problem solved
It looks like xcodebuild requires absolute path for CONFIGURATION_BUILD_DIR, OBJROOT and SYMROOT parameters.
Providing absolute path solved the problem:
CONFIGURATION_BUILD_DIR=/Users/me/Dev/MyApp/build

Batch Build and Archive of iOS apps via Terminal

I am trying to simplify the build->archive->submit process for iOS app publishing.
We have over 50 mobile apps that have nearly identical framework, but with different artwork and configuration settings.
I normally would load each project in xcode 4.2 and build->archive->submit the usual way with the xcode GUI, but we are up over 50 apps now and this process is very tiresome any time we push out an update.
That being said, I am trying to speed up this process with using a shell function.
I did plenty of research and found that xcodebuild (See Reid's answer) should work, however the Archive option is not working as I get the following error:
unsupported build action 'archive'
So I wrote the following:
# $1 should be a date like: 2012-07-17
# $2 should be a time like: 10.31AM
# $mybase will be the current directory at the time the function was called
# so make sure to cd into the folder containing the xcode project folders first
function xcodeArchive {
mkdir ~/Library/Developer/Xcode/Archives/$1
mybase=$PWD
for x in `ls`
do
mkdir ~/Library/Developer/Xcode/Archives/$1/$x
mkdir ~/Library/Developer/Xcode/Archives/$1/$x/dSYMs
mkdir ~/Library/Developer/Xcode/Archives/$1/$x/Products
mkdir ~/Library/Developer/Xcode/Archives/$1/$x/Products/Applications
cd $mybase/$x
xcodebuild
#read -p "Press [Enter] to continue"
cd $mybase/$x
cp $x/$x-Info.plist ~/Library/Developer/Xcode/Archives/$1/$x/Info.plist
cp -r build/Release-iphoneos/$x.app.dSYM ~/Library/Developer/Xcode/Archives/$1/$x/dSYMs/$x.app.dSYM
cp -r build/Release-iphoneos/$x.app ~/Library/Developer/Xcode/Archives/$1/$x/Products/Applications/$x.app
cd ~/Library/Developer/Xcode/Archives/$1/
mv $x $x\ $1\ $2.xcarchive
cd $mybase
done
}
export -f xcodeArchive
I put this in my .bash_profile and everything runs correctly as I would expect, except I'm not copying the correct "Info.plist" and I can't figure out where to copy it from or how to generate it. So now I am stuck.
Xcode will recognize the archives, but it lists them under "Unknown Schema" and "Unnamed Archive" in the organizer.
Any help regarding now to get the correct Info.plist is greatly appreciated.
I also welcome recommendations on how to improve the script and/or a more efficient way to batch build+archive these iOS apps.
Note:
I am unable to upgrade beyond Xcode 4.2 as that requires (as I understand it) OS X 10.7+ which I am not able to obtain yet (company computer).
I am still very much a bash/shell novice, so I apologize for any ugly code/practice above.
Also, this is for official app submission, not for ad-hoc or anything like that.
Thanks again for your help.
I had the same issue with the archive command, and found this question via Google. It would fail with this build command:
xcodebuild -verbose -project $ProductName.xcodeproj -target $ProductName -configuration Release -sdk $SDK clean archive CONFIGURATION_BUILD_DIR="$PROJECT_PATH/build" PROVISIONING_PROFILE="${DIST_PROVISONING_PROFILE}"
Yet, it would succeed with this build command:
xcodebuild -verbose -project $ProductName.xcodeproj -scheme $ProductName -configuration Release -sdk $SDK clean archive CONFIGURATION_BUILD_DIR="$PROJECT_PATH/build" PROVISIONING_PROFILE="${DIST_PROVISONING_PROFILE}"
The only difference is specifying the scheme in lieu of the target to build. If there is a sensible reason for this behavior, I'd enjoy hearing it.
I'm running XCode 4.5.1 on Mac OS X 10.7.5
OK I found a solution that will work. After doing a lot more searching and a lot of guess and check, I found I can still use the "archive" option with xcodebuild, I just have to specify a workspace and scheme and apparently I wasn't doing that correctly before as it now works.
So, for anyone looking for a similar solution (to batch archive xcode projects), here is my function:
# $mybase will be the current directory at the time the function was called
# so make sure to cd into the folder containing the xcode project folders first
function xcodeArchive {
mybase=$PWD
for x in `ls`
do
cd $mybase/$x
xcodebuild -workspace $x.xcodeproj/project.xcworkspace -scheme $x archive
cd $mybase
done
}
export -f xcodeArchive

Resources