Create CocoaPod framework with Kotlin shared.framework - ios

I've created a SDK framework and added all files (Swift, Objective C and c++). Also added shared.framework which is written in Kotlin(KMM).
I linked SDK framework into dummy project and working correctly.
Now I've to deliver SDK framework to cocoapod. So for that I've created PodSpec file inside SDK framework and installed it to demo project. It installed successfully, but can't access header files (Objective C) in swift file.
Here is my PodSpec file.
Pod::Spec.new do |spec|
spec.name = "DemoSDKSwift"
spec.version = "0.0.1"
spec.summary = "A short description of DemoSDKSwift."
spec.description = "A very long description of DemoSDKSwift."
spec.homepage = "https://BITBUCKET_URL.COM/DemoSDKSwift"
spec.source = { :git => "https://BITBUCKET_URL.COM/DemoSDKSwift.git", :tag => "#{spec.version}" }
spec.license = "MIT"
spec.author = { "Author Name" => "AuthorName#streamplate.com" }
spec.source_files = "DemoSDKSwift/**/*"
spec.platform = :ios, "15.0"
spec.ios.deployment_target = '15.0'
spec.vendored_frameworks = 'Frameworks/shared.framework'
spec.libraries = 'c++', 'sqlite3', 'z', 'stdc++'
spec.pod_target_xcconfig = {
'KOTLIN_PROJECT_PATH' => ':shared',
'PRODUCT_MODULE_NAME' => 'shared',
}
end
I also have added Bridging header file but it's not working.
I tried so many solutions, but couldn't figure out. Please help to make it working.

Related

Unable to access files in custom cocoapods iOS Swift

I have implemented custom cocoapods in iOS swift but i am unable to access the file that i have developed in my framework. I have installed the framework using pod install and given the local path to that directory and it is even imported successfully. But when I try to access it, it doesn't finds the file. I have attached the images of the code files below. Please help me out, I will be grateful.
My podspec file is as follows:
Pod::Spec.new do |spec|
spec.name = "MuneebTestCocoapod"
spec.version = "1.0.0"
spec.summary = "A short description of MuneebTestCocoapod.podspec."
spec.description = "The description comes here"
spec.homepage = "http://gitlab.phonecheck.com/muneeb.rehman/muneebtestcocoapod"
spec.license = "MIT"
spec.author = { "Muneeb ur Rehman" => "muneeb.ur.rehman#upgenicsint.work" }
spec.platform = :ios, "11.0"
spec.source = { :git => "http://gitlab.phonecheck.com/muneeb.rehman/muneebtestcocoapod.git", :tag => "#{spec.version}" }
spec.source_files = "MuneebTestCocoapod/**/*.{h,m,swift}"
end
As you check MyService class is a by default internal access level. While you making pod and wants to use outside the module you should need to make your class public or open.
Also, You can't make an instance of MyService class as you added private access specifier to init.
So make it public init and public class.

Resource file in cocoapod is set to a wrong target

I have a public CocoaPod called CountrySelectorView. It's basically a small library that allows users to select countries from a list. This list of countries is included as a json file in the pod.
I released the first version (v0.1.0) a few months ago and it worked well without an issue. Today I added some new changes to the codebase and released a new version (v0.1.2).
When I install this new version now, the countries.json file is assigned a weird target.
And this affects only that json file. All other files are set to the proper target.
This is my podspec file. The only thing I changed here was the version string before publishing the new version. No changes were done to the countries.json file either apart from some minor content changes.
Pod::Spec.new do |s|
s.name = 'CountrySelectorView'
s.version = '0.1.2'
s.summary = 'CountrySelectorView lets users pick a country from a list.'
s.description = <<-DESC
CountrySelectorView lets users pick a country. You can show it either as a list where you can search or a picker view.
DESC
s.homepage = 'https://github.com/Isuru-Nanayakkara/CountrySelectorView'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Isuru-Nanayakkara' => '<my_email>' }
s.source = { :git => 'https://github.com/Isuru-Nanayakkara/CountrySelectorView.git', :tag => s.version.to_s }
s.ios.deployment_target = '11.0'
s.source_files = 'CountrySelectorView/Classes/**/*'
s.resource_bundles = {
'CountrySelectorView' => ['CountrySelectorView/Assets/countries.json']
}
s.frameworks = 'UIKit'
s.swift_version = '5.0'
end
Strange thing is when I install the old version (v0.1.0) now, this problem arises in that version as well! Prior to today, it worked fine.
Any idea what may have caused this?
Demo project

Cocoapods not showing my project as Tested

I have a project that I've added as a Cocoapod. It is covered by tests, yet the Cocoapods project page does not show the tests. Here is the link to my project page:
https://cocoapods.org/pods/SKTableViewDataSource
Note, Tested: X in the right hand column.
This is what my podspec looks like:
Pod::Spec.new do |spec|
spec.name = 'SKTableViewDataSource'
spec.version = '1.0.0'
spec.license = 'MIT'
spec.summary = 'An easy to configure data source for UITableView.'
spec.homepage = 'https://github.com/skladek/SKTableViewDataSource'
spec.authors = { 'Sean Kladek' => 'skladek#gmail.com' }
spec.source = { :git => 'https://github.com/skladek/SKTableViewDataSource.git', :tag => spec.version }
spec.ios.deployment_target = '9.0'
spec.source_files = 'Source/*.swift'
end
Do I need to add something to the podspec or elsewhere to have it recognize my tests?
From a ticket in the cocoadocs.org project:
Apparently it comes from the © character in the headers added by Xcode when creating a new Swift file, like in the following line:
// Copyright © 2017 pirishd. All rights reserved.
Removing this character in all the Swift files of the Test target makes detection work again.
https://github.com/CocoaPods/cocoadocs.org/issues/523
Removing the copyright headers from my test files worked for me.

Trying to wrap vendor framework in cocoapod but the compiler can't find headers

Hoping somebody has already solved this; I'm trying to wrap a third-party library (Airwatch) in a cocoapod for better management across our apps. I'm having a hell of a time trying to get this to work, though. I've created a pod around a static library, but this one is a dynamic framework, and I'm having a hell of a time getting it to compile. The headers from the framework just aren't accessible in the containing app....
Here's what I have tried already:
When I set vendored_libraries in podspec i can't seem to access headers with either quotes or <>. Xcode just complains as 'Not Found'
Next, I tried adding the path of the headers in the framework as source_files like so
s.source_files = 'Pod/Classes/**/*','Pod/Framework/AWSDK.framework/Versions/A/Headers/*.h'
This allows xcode to find the header for an import like:
import "AWSDKCore.h" //Documented as the framework's main header
But this throws an error for the existing imports within the original framework:
I figured this was a bad idea, but I thought I'd try naming my cocoapod the same name as the Framework (which should keep the import path). So, this throws a bunch of errors saying some enums either aren't declared or are declared twice.
If anybody has thoughts, I'd be eternally greatful...
Just for reference here's my podspec:
Pod::Spec.new do |s|
s.name = "AirwatchSDK"
s.version = "0.1.0"
s.summary = "A short description of AirwatchSDK."
s.homepage = "https://github.com/<GITHUB_USERNAME>/AirwatchSDK"
s.license = 'MIT'
s.author = { "xxxxx" => "xxxx" }
s.source = { :git => "https://github.com/<GITHUB_USERNAME>/AirwatchSDK.git", :tag => s.version.to_s }
s.platform = :ios, '8.0'
s.requires_arc = true
#s.module_name = 'AWSDK'
s.source_files = 'Pod/Classes/**/*','Pod/Framework/AWSDK.framework/Versions/A/Headers/*.h'
s.vendored_frameworks = 'Pod/Framework/AWSDK.framework'
s.frameworks = 'CFNetwork','CoreData','CoreFoundation','CoreGraphics','CoreLocation','CoreTelephony','CoreText'
s.libraries = 'stdc++','z','sqlite3','c++'
end
Since I figured out my own answer, I thought I'd post it here for the next guy...
The key, it turns out, was to not have 'source_files' (or to comment it out). I'm not sure if that is a bug or not, but my final podspec had vendored_framework set and source_files not set like so:
#can't have source files if you want to access vendor framework
#s.source_files = 'Pod/Classes/**/*'
# airwatch framework.
s.vendored_frameworks = 'AWSDK.framework'

No visible #interface in Cocoapods

I am trying to modulize my app by splitting it in different sub projects.
Inspired by this idea. So I splited my project to static libraries followed by that tutorial. I created a first library with some costume UIHelpers/Views. It has some dependencies which I defined in PodSpec file followed by AFNetworking example. (one of the dependencies is Choosy). I stored this library in bitBucket. Everything is working fine for that library(I can build it in Xcode). The problem start when I create a Model Library. I specify Git path of UIHelpers in the Model PodFile. Every time I get an error of No visible #interface for a category in Choosy (the error come from CocoaPod NOT in my project, the category is imported in the .mfile). I tried to play with link flags -ObjC,$(inhereted),-force_load included all of them.Objective-C categories in static library I cleaned the derived data.
I read the CocoaPodTroubleShoutes.
Can somebody suggest what can be tried. There is a lot of question in stuck regarding that compile error but none of them helped me.
I believe the problem somewhere in my PodSpec(cant be sure) pod lib linit I receive :- ERROR | [iOS] Choosy/Choosy/Model/ChoosyAppInfo.m:32:19: error: no visible #interface for 'UIImage' declares the selector 'applyMaskImage:completion:'
My PodSec:
Pod::Spec.new do |s|
#I tried this options:
#s.xcconfig = { 'OTHER_LDFLAGS' => $(inherited) }
#s.compiler_flags = '-ObjC'
#'-all_load'
#$(inherited)
#'-DOS_OBJECT_USE_OBJC=0', '-Wno-format'
#'-force_load'
s.prefix_header_contents = '#import <UIKit/UIKit.h>', '#import <Foundation/Foundation.h>','#import <CoreGraphics/CoreGraphics.h>','#import "ARNStyles.h"'
s.description = <<-DESC
A longer description of ARNUIHelpers in Markdown format.
DESC
s.homepage = "http://EXAMPLE/ARNUIHelpers"
s.platform = :ios, "7.0"
s.ios.deployment_target = "7.0"
s.source_files = 'UIHelpers/**/*.{h,m}'
s.requires_arc = true
s.subspec 'Choosy' do |ss|
ss.requires_arc = true
ss.compiler_flags = '-force_load'
ss.platform = :ios, "7.0"
ss.dependency 'Choosy'
# ss.xcconfig = { "FRAMEWORK_SEARCH_PATHS" => "$(PODS_ROOT)/Headers/Public/Choosy"}
# ss.ios.public_header_files = 'UIImage+ImageEffects.h'
end
s.subspec 'Dependencies' do |ss|
#ss.ios.public_header_files = 'UIImage+ImageEffects.h'
ss.requires_arc = true
ss.dependency 'FormatterKit'
end
end
In the end it was my fault. The previous developer copied those files from Choosy pod and included it manually.We still use Choosy in other places. Unfortunately the error wasn't clear enough to deduce what was wrong.

Resources