Azure DevOps Pipeline iOS Error - Kotlin multiplatform - ios

I'm trying to build a CI/CD pipeline for my KMM project at Azure DevOps. I added the pipelines for iOS and Android. But I'm facing an error for iOS pipeline during executing the Xcode#5 task.
FYI :- I'm currently using a library called "SwiftUIFormValidator" for textField validations.
Error:- ▸
Running script '[CP-User] Build shared'
▸ Processing SwiftUIFormValidator-Info.plist
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution [CP-User]\ Build\ shared /Users/runner/Library/Developer/Xcode/DerivedData/iosApp-dongzyrxhgtfzxexzqjllvyjwgcu/Build/Intermediates.noindex/Pods.build/Release-iphoneos/shared.build/Script-4552119A071AC6BAB7327E6434237EC3.sh (in target 'shared' from project 'Pods')
My shared build.gradle file code:-
kotlin {
android()
iosX64()
cocoapods {
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
ios.deploymentTarget = "14.1"
podfile = project.file("../iosApp/Podfile")
framework {
baseName = "shared"
}
}
Here's my pod file:-
target 'iosApp' do
source 'https://cdn.cocoapods.org'
use_frameworks!
platform :ios, '14.1'
pod 'shared', :path => '../shared'
pod 'SwiftUIFormValidator'
end
Can anyone help me where I'm doing wrong? . Thank you.

Related

How to remove file reference from Runner.xcodeproj

I have a ruby code that uses xcodeproject that adds my Google-Info.plist to Runner.xcodeproj as a reference. However I want to remove the older reference because I get following error:
Xcode's output:
↳
error: Multiple commands produce '/Users/figengungor/Documents/projects/app_gmo/base/build/ios/Release-iphoneos/Runner.app/GoogleService-Info.plist':
1) Target 'Runner' (project 'Runner') has copy command from '/Users/figengungor/Documents/Base Firebase Files/GoogleService-Info.plist' to
'/Users/figengungor/Documents/projects/app_gmo/base/build/ios/Release-iphoneos/Runner.app/GoogleService-Info.plist'
2) Target 'Runner' (project 'Runner') has copy command from '/Users/figengungor/Documents/projects/app_gmo/base/ios/GoogleService-Info.plist' to
'/Users/figengungor/Documents/projects/app_gmo/base/build/ios/Release-iphoneos/Runner.app/GoogleService-Info.plist'
Here’s how I add the Google-Info.plist reference:
require 'xcodeproj'
project = Xcodeproj::Project.open(ARGV[0])
main_target = project.targets.first
gsi_reference = project.main_group['Runner'].new_file(ARGV[1])
main_target.add_file_references([gsi_reference])
project.save
Here’s the me trying to delete but not being successful code(I’m not familiar with Ruby, tried to follow documentation):
old_gsi_reference = project.main_group['Runner'].find_file_by_path('/Users/figengungor/Documents/Base Firebase Files/GoogleService-Info.plist')
old_gsi_reference.remove_from_project()
Does anyone have experience with xcodeproject and can help me out?

Azure pipeline fails during xcode build for iOS project

Trying to build iOS project with xcode build. Using -
Xcode 12.4
Agent Specification - macOS-10.15
Workspace or project path - Project.xcworkspace
Configuration - Release (Tried with Debug also, it gives more error)
Scheme -valid name
SDK - iphoneos
Now After xcode build using Azure pipeline give following error.
We can build this xcode on locally and Gitlab too. But same code is failing on Azure Devops.
Kindly help.
2021-05-12T13:00:30.6465950Z ❌ /Users/runner/work/1/s/Project/Framework/csdk_common.framework/Modules/module.modulemap:2:19: umbrella header 'csdk_common.h' not found
2021-05-12T13:00:30.6466920Z
2021-05-12T13:00:30.6468430Z umbrella header "csdk_common.h"
2021-05-12T13:00:30.6471390Z ^
2021-05-12T13:00:30.6471830Z
2021-05-12T13:00:30.6472160Z
2021-05-12T13:00:30.6472470Z
2021-05-12T13:00:30.6473810Z ❌ /Users/runner/work/1/s/Project/TTS/main_internal.swift:2:8: could not build Objective-C module 'csdk_common'
2021-05-12T13:00:30.6474420Z
2021-05-12T13:00:30.6475000Z import csdk_common
2021-05-12T13:00:30.6475580Z ^
2021-05-12T13:00:30.6475930Z
2021-05-12T13:00:30.6476250Z
2021-05-12T13:00:30.6730310Z ** BUILD FAILED **
2021-05-12T13:00:30.6731680Z
2021-05-12T13:00:30.6732100Z
2021-05-12T13:00:30.6732840Z The following build commands failed:
2021-05-12T13:00:30.6733510Z CompileSwift normal arm64
2021-05-12T13:00:30.6740330Z CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
2021-05-12T13:00:30.6746120Z (2 failures)
2021-05-12T13:00:30.7025590Z ##[error]Error: /usr/bin/xcodebuild failed with return code: 65
2021-05-12T13:00:30.7365340Z ##[section]Finishing: Xcode build
Please check the repos branch, and make sure you have added this under framework header file. Maybe you did not push the right project and necessary part into the azure devops repos.
#import "xxx\csdk_common.h"
More info you could check this issue and that.

Importing GoogleWebRTC pod fails: module 'GoogleWebRTC' not found

I am currently working on a Kotlin multiplatform and am trying to interface with the GoogleWebRTC pod.
The pod exists, I was able to import it in a separate project (without Kotlin multiplatform). I can see the .framework is created in my build directory, however when doing a gradle sync or building from Xcode, I get the following error:
Exception in thread "main" java.lang.Error: /var/folders/hv/9cx28nxx4gz9hj_m86bp5rx40000gn/T/tmp362966650322311128.m:1:9: fatal error: module 'GoogleWebRTC' not found
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:152)
at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:67)
at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:13)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:499)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:264)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:72)
at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:19)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:37)
Execution failed for task ':shared:cinteropGoogleWebRTCIosArm64'.
> Process 'command '/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
AFNetworking seems to work fine, but adding the WebRTC pod seems to break the project.
Am I missing a limitation of Kotlin multiplatform or something?
This is my build.gradle.kts:
cocoapods {
// Configure fields required by CocoaPods.
summary = "Some description for a Kotlin/Native module"
homepage = "Link to a Kotlin/Native module homepage"
// You can change the name of the produced framework.
// By default, it is the name of the Gradle project.
frameworkName = "shared"
ios.deploymentTarget = "10.0"
pod("GoogleWebRTC", "~> 1.1")
pod("AFNetworking", "~> 4.0.0")
}
I was able to reproduce this issue but I didn't figure out the reason why.
It seems a there's something wrong with GoogleWebRTC pod and the Kotlin-native/cocoapods integration.
I've opened an issue here.
We have an official help.
It seems that the frameworks name is different from the pod name. So a possible solution could be that:
kotlin {
cocoapods {
[...]
pod("GoogleWebRTC", moduleName = "WebRTC", version = "~> 1.1")
[...]
}
[...]
}
I tried it and it works.

Conflict between location and url_launcher plugin

I'm developing an app which finds points of interest around the location of the user. To get the location of the user I use the location plugin which works quite nicely.
The next thing I'd like to implement is a button to open the default mapping application to navigate the user to the POI. I went at it using the url_launcher plugin and the geo: url scheme for android and the maps: scheme for iOS.
Independent of each other both plugins work as expected. Once I had both plugins in my project the problems started. Using the default setup of flutter create I get the following error:
Launching lib/main.dart on iPhone 6 in debug mode...
Running pod install...
CocoaPods' output:
↳
Preparing
Analyzing dependencies
Inspecting targets to integrate
Using `ARCHS` setting to build architectures of target `Pods-Runner`: (`arm64`)
Finding Podfile changes
- Flutter
- location
- url_launcher
Fetching external sources
-> Fetching podspec for `Flutter` from `/Users/rainerwittmann/Flutter/flutter/bin/cache/artifacts/engine/ios`
-> Fetching podspec for `location` from `/Users/rainerwittmann/.pub-cache/hosted/pub.dartlang.org/location-1.0.2/ios`
-> Fetching podspec for `url_launcher` from `/Users/rainerwittmann/.pub-cache/hosted/pub.dartlang.org/url_launcher-0.4.2+1/ios`
Resolving dependencies of `Podfile`
Comparing resolved specification to the sandbox manifest
- Flutter
- location
- url_launcher
Downloading dependencies
-> Using Flutter (1.0.0)
-> Using location (0.0.1)
-> Using url_launcher (0.0.1)
- Running pre install hooks
[!] Pods written in Swift can only be integrated as frameworks; add `use_frameworks!` to your Podfile or target to opt into using it. The Swift Pod being used is: location
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.1.1/lib/cocoapods/installer.rb:448:in `block (2 levels) in verify_framework_usage'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.1.1/lib/cocoapods/installer.rb:443:in `each'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.1.1/lib/cocoapods/installer.rb:443:in `block in verify_framework_usage'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.1.1/lib/cocoapods/installer.rb:440:in `each'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.1.1/lib/cocoapods/installer.rb:440:in `verify_framework_usage'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.1.1/lib/cocoapods/installer.rb:114:in `install!'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.1.1/lib/cocoapods/command/install.rb:37:in `run'
/Library/Ruby/Gems/2.0.0/gems/claide-1.0.1/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.1.1/lib/cocoapods/command.rb:50:in `run'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.1.1/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
Error running pod install
Error launching application on iPhone 6.
So far so good. Adding use_frameworks! to my podfile, as suggested by the error message resulted in another error:
Launching lib/main.dart on iPhone 6 in debug mode...
Running pod install...
Running Xcode build...
Failed to build iOS app
Error output from Xcode build:
↳
** CLEAN FAILED **
The following build commands failed:
Check dependencies
(1 failure)
** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)
Xcode's output:
↳
Build settings from command line:
ARCHS = x86_64
BUILD_DIR = /Users/rainerwittmann/Flutter/zapfsuche/build/ios
ONLY_ACTIVE_ARCH = YES
SDKROOT = iphonesimulator10.3
=== CLEAN TARGET location OF PROJECT Pods WITH CONFIGURATION Release ===
Check dependencies
“Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
=== CLEAN TARGET url_launcher OF PROJECT Pods WITH CONFIGURATION Release ===
Check dependencies
=== BUILD TARGET url_launcher OF PROJECT Pods WITH CONFIGURATION Release ===
Check dependencies
=== BUILD TARGET location OF PROJECT Pods WITH CONFIGURATION Release ===
Check dependencies
“Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
Could not build the application for the simulator.
Error launching application on iPhone 6.
Unfortunately I have no idea how to proceed from here. Can somebody help me sort this out?
Note
This problem only exists on iOS. Both plugins work like a charm on android.
Swift plugins require use_frameworks! and that isn't fully supported yet.
I'm currently working on it. Thanks for your patience!
Edit Podfile
Add/uncomment after "target 'Runner' do" line number ~35
use_frameworks!
Then add this line after line number ~67
config.build_settings['SWIFT_VERSION'] = '4.0'
Example:
target 'Runner' do
** use_frameworks! **
........ ......
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
** config.build_settings['SWIFT_VERSION'] = '4.0' **
end
end
end
delete your Podfile.lock and try.

Swift compiler error: Header not found

I started a "Cocoa Touch Static Project" with a Cocoa Pods dependance.
Podfile:
platform :ios, '8.4'
inhibit_all_warnings!
target 'project' do
pod 'libPusher', '~> 1.6'
end
target 'project' do
end
A workspace has been created by the command "pod install".
Then I created un swift project on this workspace and I created a Bridge header between this swift project and my Objective-C library project.
My swift project configuration:
//:configuration = Debug
SWIFT_OBJC_BRIDGING_HEADER = demo/demo-Bridging-Header.h
//:configuration = Release
SWIFT_OBJC_BRIDGING_HEADER = demo/demo-Bridging-Header.h
When I compile my swift project, I obtain this error:
demo-Bridging-Header.h:5:9: In file included from /Users/XYZ/Projets/iOS/project/library/demo/demo/demo-Bridging-Header.h:5:
project.h:10:9: 'Pusher/PTPusherDelegate.h' file not found
Failed to import bridging header '/Users/XYZ/Projets/iOS/project/project/demo/demo/demo-Bridging-Header.h'
Do you know why the swift compiler doesn't found header file and how can I fix it?
• Did you run pod install ?
Installing SocketRocket (0.3.1-beta2)
Installing libPusher (1.6)
• Did you open demo.xcworkspace (close Xcode project, open Xcode workspace)
If so, were is the correct demo-Bridging-Header.h content:
#import "Pusher.h"
#import "Pusher/PTPusherDelegate.h"

Resources