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
Related
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.
We have created a CocoaPod which is an XCFramework that has dependencies on other CocoaPods. When we run the demo example app or install the pod in a new app, it works, however this is logged to the console on launch (repeated for many classes):
objc[38875]: Class OTSubscriber is implemented in both
/Users/MyUser/Library/Developer/CoreSimulator/Devices/8DD81910-DD40-4BD7-9355-8A0C78EFD32E/data/Containers/Bundle/Application/60E8C18A-37DC-4C2B-AEB3-E88C3A7C4D96/MyCocoaPod_Example.app/Frameworks/MyFramework.framework/MyFramework
(0x10e3fd660) and
/Users/MyUser/Library/Developer/CoreSimulator/Devices/8DD81910-DD40-4BD7-9355-8A0C78EFD32E/data/Containers/Bundle/Application/60E8C18A-37DC-4C2B-AEB3-E88C3A7C4D96/MyCocoaPod_Example.app/MyCocoaPod_Example
(0x10c8abd80). One of the two will be used. Which one is undefined.
This class is from OpenTok, which is a dependency specified for the pod used in the framework. The message seems to reveal CocoaPods is installing the dependencies on the app in addition to the framework, causing this issue. The app itself shouldn't have any dependencies except this framework.
Perhaps something was done incorrectly in the pod creation process? These are the steps we took:
Create an Xcode framework project, add a Podfile listing its dependencies, build out the framework's functionality
Create an XCFramework from the framework's xcworkspace
Create the pod using pod lib create MyCocoaPod choosing iOS, Swift, include demo, none and no for testing
Update the Podspec:
Pod::Spec.new do |s|
s.name = 'MyCocoaPod'
s.version = '1.0.0'
s.summary = 'Summary'
s.description = <<-DESC
'Description'
DESC
s.homepage = 'https://myhomepage.com'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Author' => 'auther#somedomain.com' }
s.ios.deployment_target = '12.0'
s.source = { :git => 'https://github.com/user/git-repo.git', :tag => s.version.to_s }
s.vendored_frameworks = 'MyFramework.xcframework'
s.swift_version = '5.5.2'
s.dependency 'OpenTok', '2.21.3'
# Needed to pass lint validation
s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
end
Drag and drop MyFramework.xcframework into Pods/Development Pods/MyCocoPod
Update the example's Podfile to specify BUILD_LIBRARY_FOR_DISTRIBUTION = YES:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
Run pod install in Example directory - note this will cause the framework to be moved to the root level in Finder and under a Frameworks group in Xcode
Update the example app's code to import and use MyFramework
Commit, tag, and push the changes to the repo
Push the Podspec to the specs repo
Not sure if this is your case but maybe you are falling in a scenario which happened to me,
meaning a dynamic framework that depends on a static framework. In such scenario, your dynamic framework would end up embedding the static one in his resulting binary. Then, in order to import your dynamic framework in the project, you will import with the setting “Embed and sign” for example, as that’s indeed a dynamic one, along with the other static framework which your dynamic one depends on. This causes the duplicated implementation ( your app including the static dependency + the dynamic one embedding inside the same dependency.
What you could do if this is your case, is to make sure that the dynamic framework configuration is changed to be static (static xcframework to be precise) , maybe outside cocoa pod as first step if that simplifies. Code wise would be the same, but it will “link” to the dependency (OpenTok for example) rather than embedding it. As result, once imported in the app, it should be imported only once, as your custom framework links to it and does not embeds it, finally avoiding the duplicated implementation. (static frameworks are imported with “Do not embed” which means that they will be merged in compile time to the app executable)
I'm building a framework using cocoapods. Now, I have it in a private repository with a private spec repo. I want to distribute this framework not as open source, but closed source. Basically, I want to distribute only the .framework file, already compiled. This way, I will avoid to expose my source code to externals.
I don't know how to tell cocoapods to distribute the compiled file.
After compiling your framework, you'll want to create a separate, public repository to use for distribution. That is where you will place your compiled framework, podspec, license, readme files, etc.
The podspec is a bit different for distributing frameworks rather than source code. See example:
Pod::Spec.new do |s|
s.name = 'YourFrameworkName'
s.version = '1.7.0'
s.summary = 'The YourFrameworkName iOS SDK enables you to embed state-of-the-art real-time goodness into your iOS app.'
s.homepage = 'http://example.com'
s.author = { 'Name' => 'info#example.com' }
s.license = { :type => 'Custom', :file => 'LICENSE' }
s.platform = :ios
s.source = { :http => 'https://github.com/example/YourFrameworkName/releases/download/1.7.0/YourFrameworkName.zip' }
s.ios.deployment_target = '9.0'
s.ios.vendored_frameworks = 'YourFrameworkName.framework'
s.dependency 'SwiftyJSON', '3.1.4'
end
Once all that is set up, you can publish the pod spec the normal way.
Keep in mind, and this is an important consideration, that your compiled framework written in Swift will only be usable in projects that use the exact same Swift version. You will quickly run into this limitation as people start using your framework in different projects with various Swift versions.
First, you create a sample project and install the pods(the library which you want to release as SDK.framework) for the project.
Then see the below-attached image to get the .framework extension file to distribute to the public.
You can do this by pointing s.source of the podspec file to a zip file of your framework and its source. No need to expose your source in a public repository.
ex.
spec.source = { :http => 'https://bitbucket.org/publicRepo/yourframework.zip' }
We have developed a Custom framework in iOS which has multiple targets. Each target gives a different (Example SDK1,SDK2,SDK3) SDK. We have also uploaded the same on Github with below podspec.
Pod::Spec.new do |s|
#1.
s.name = "CustomFramework"
#2.
s.version = "1.0.1"
#3.
s.summary = "Sort description of 'CustomFramework' framework"
#4.
s.homepage = "http://www.customframework.com"
#5.
s.license = "MIT"
#6.
s.author = "Test Author"
#7.
s.platform = :ios, "10.0"
#8.
s.source = { :git => "https://gitlab.com/xxxx/CustomFramework.git", :tag => "1.0.1" }
#9.
s.source_files = "CustomFramework", "CustomFramework/**/*.{h,m,swift}"
end
To add this sdk in project, we have written below code in pod file.
pod 'CustomFramework',:git=>'https://gitlab.com/xxxx/CustomFramework.git'
But it always fetch the SDK which are belongs to first target (SDK1).
Is there any by which we can specify the schema name / target name (SDK1/ SDK2 / SDK3)which we required to fetch?
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'