pod spec lint error: "unexpected '#' in program" - ios

I am creating a podspec file for an open-source project I created, and I am utilizing Apple's UIImage+ImageEffects.h/.m for a blur effect, and inside there, they use the new #import Accelerate; syntax versus #import <Accelerate/Accelerate.h>. When I run pod spec lint SFSCollectionMenu.podspec, I receive the error:
ERROR | [xcodebuild] SFSCollectionMenu/UIImage+ImageEffects.h:96:1: error: unexpected '#' in program
Does the CocoaPods platform not like the new modules syntax? I'm relatively new to CocoaPods so there very well could be something I'm missing. I followed Nils Hayat's blog for creating a simple pod (which fit my scenario perfectly -- nothing outlandish), http://nilsou.com/blog/2013/07/21/how-to-open-source-objective-c-code/, and receive this error in his section about verifying the pod via lint.
Here's relevant lines from podspec file:
s.source_files = 'SFSCollectionMenuController.*{h,m}', 'SFSCircleLayout.*{h,m}', 'SFSMenuCell.*{h,m}', 'UIImage+ImageEffects.*{h,m}'
s.frameworks = 'Accelerate', 'QuartzCore', 'AVFoundation'
Thank you for any help!

I don't think Modules are turned on by default in Xcode, can you test whether adding spec.compiler_flags = "-fmodules" to turn on modules in your generated library fixes this?

Related

cocoa podspec subspec swift compatibility header file not found

Pod lib could not find mymodule-swift.h header.
One of my objc.m file imports following code.
#import <devillogin/devillogin-Swift.h>
Xcode build is success. Everything is ok.
But when I'm trying to distribute with pod, following error printed.
pod lib lint mymodule.podspec
fatal error: 'devillogin/devillogin-Swift.h' file not found
My mylib.podpec is as following
Pod::Spec.new do |s|
...
s.subspec 'DevilLogin' do |devilLogin|
devilLogin.source_files = 'devillogin/devillogin/source/**/*.*'
devilLogin.public_header_files = 'Pod/Headers/*.h'
devilLogin.dependency 'devil/DevilCore'
devilLogin.dependency 'KakaoSDK'
end
end
Is there any syntax in podspec for mylib-swift.h ?
I'm answering to myself.
I found that the issue only occur when it is in the subspec.
No problem with root podspec.
Consequently I couldn't find way to let my pod-subspec import "XXX-swift" header.
But I found workaround.
I referenced firebase frameworks which use many pod-subspecs.
https://github.com/firebase/firebase-ios-sdk
Just watched root pod spect and 1 subspec.
It distributes sub-specs as root pod spec which is success with 'XXX-swift.h' header
And each subspecs depend on it above.
There is Firebase.podspec and FirebaseDynamicLinks.podspec.
FirebaseDynamicLinks is standalone independent frameworks.
But it is actually subspec.
Firebase podspec defines subspec like followings.
This is workaround
s.subspec 'DynamicLinks' do |ss|
ss.dependency 'Firebase/CoreOnly'
ss.ios.dependency 'FirebaseDynamicLinks', '~> 7.9.0'
end
It defines DynamicLinks as subspec and define dependency on independent FirebaseDynamicLinks.
Done

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.

Cocoapod podspec validation - Unknown DSL error occured

Im trying to upload the new version of my pod to cocoapods spec repo. The current live version is 0.3.1 and it is a framework build with swift 4.2. Now i updated the library and build with Xcode 11.1 (swift 5). But while linting the podspec file, im getting an unknown DSL error in the terminal.
I have tried with changing the name of podspec and with same framework. but no use. anyone please help
pod spec lint AsistaCore.podspec --verbose
Podspec file
Pod::Spec.new do |spec|
spec.name = 'AsistaCore'
spec.version = '1.0.0'
spec.summary = 'Official Asista SDK in Swift to access Asista Platform core feature'
spec.description = <<-DESC
The Asista SDK in Swift Core framework provides:
* Create new tickets
* Update Ticket State
* Add comments to ticket
* Asset list
* Update profile
* Knowledge Base Articles
DESC
spec.homepage = 'https://asista.com/developer'
spec.license = { :type => 'MIT', :file => 'LICENSE' }
spec.authors = { 'Cherrylabs' => 'vaisakh.kp#cherrylabs.com' }
spec.documentation_url = 'https://asista.com/developer/docs/asista-sdk-for-ios'
spec.platform = :ios
spec.source = { :git => 'https://github.com/cherrylabstech/asista-sdk-ios.git', :tag => spec.version }
spec.swift_version = '5.0'
spec.ios.deployment_target = '8.0'
spec.static_framework = true
spec.ios.vendored_frameworks = 'AsistaSupport/AsistaCore.framework'
end
-> AsistaCore (1.0.0)
- ERROR | [iOS] unknown: Encountered an unknown error (Pod::DSLError
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.8.4/lib/cocoapods-core/specification.rb:808:in `rescue in _eval_podspec'
....
...
We ran into this issue when we try creating a release and publishing a library. This error occurs when you are trying to run pod spec lint or pod repo push. The error says "DSLError" and doesn't give much information on what is causing it. I found little help online and some places they say, there could be a syntax error in the podspec file. We didn't have any in our podspec. However, this answer from stackoverflow gave me some direction https://stackoverflow.com/a/64779582
It looks like while making a release for one SDK/library, the pod spec lint and pod repo push validates all the podspecs in the folder besides the ones you ran. I don't know how that works internally. You should look for the following scenarios to identify the issue:
If there are other podspecs for capabilities that have different tags(Example: ABC.podspec pointed to source tag 1.0.0-ABC and XYZ.podspec pointed to source tag 2.0.0-XYZ)
Multiple podspecs have dependencies on different versions of the same module(Example: Module1.podspec depends on Module 5 version 10.0.0 and Module2.podspec also depends on Module 5 but on the version 11.0.0).
Syntax errors in any of the podspecs
If you come across either or both 1 & 2, it could be a potential cause for the DSLError.
When you run into this issue, make sure you look for and update the following:
All podspecs to have pointed to one source tag
All dependencies on a module pointed to one version of it in each capability.
Fix the sytanx errors.
This issue will go away or reduce significantly when the SDK libraries can be separated into their repositories instead of all in one repository, or perhaps even by keeping each podspec in their own individual folder.

iOS file patterns: The `source_files` pattern did not match any file

I am trying to create a CocoaPod and when I try pod lib lint there's an error about ERROR | [iOS] file patterns: Thesource_filespattern did not match any file.
I am trying to follow BlinkingLabel pod as an example and using Gitlab for storage of my .git . I tagged it successfully 1.0.0 and it worked for it.
I used my CocoaPod in Example for Pod and its working but I got the error:
Ignoring unf_ext-0.0.7.5 because its extensions are not built. Try: gem pristine unf_ext --version 0.0.7.5
-> BlinkingLabel (1.0.0)
- ERROR | [iOS] file patterns: The `source_files` pattern did not match any file.
- NOTE | xcodebuild: note: Using new build system
- NOTE | [iOS] xcodebuild: note: Planning build
- NOTE | [iOS] xcodebuild: note: Constructing build description
- NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')
[!] BlinkingLabel did not pass validation, due to 1 error.
You can use the `--no-clean` option to inspect any issue.
My source_file prop is:
s.source_files = 'BlinkingLabel/Classes/**/*'
But I've tried it with:
s.source_files = "BlinkingLabel/**/*"
s.source_files = 'BlinkingLabel/BlinkingLabel.swift'
s.source_files = 'BlinkingLabel/Classes/**/*.{h,m,c}'
No one has worked for me in lint.
And there's a strange thing.
In the article and examples it recommended to use with BlinkingLabel/Classes/**/* but there's nothing any directory as named Classes in BlinkingLabel, I guess because of new update of CocoaPod or maybe something is different in new CocoaPod. Can you explain this?
And how to solve this problem for pod lib lint at all?
Edit: I've searched over stackoverflow but nothing work for me.
Thanks in advance.
For anyone who stuck at - ERROR | [iOS] file patterns: Thesource_filespattern did not match any file., do not use source_files like below.
s.source_files = 'BlinkingLabel/Classes/**/*'
Use it with your inner directory name and exact file type.
For example if you have a Handler.swift file it must be.
s.source_files = 'Classes/**/*.swift'
If you have any .c file in your pod project that used
s.source_files = 'Classes/**/*.c'
or you can mix it with different file types.
Further I realized that the you must not trust to Classes directory.
You can create a Sources directory and can add all your source files into it and then you can try it with
s.source_files = 'Sources/**/*.swift'
This is the exact solution for me.
I hope it helps for anyone who stuck at.
I regret to ask the question.
It worked now.
s.source_files = 'BlinkingLabel/Classes/**/*'
I've not changed anything but it worked. That's strange.
You need to make sure that you have your files and source_files is appointed to that folder, and then check lint locally
pod lib lint YPlayer.podspec
if all ok, then you can push to cocoapods
pod trunk register email#domain.com 'Your Name' --description='Senior ios developer'
pod trunk push YPlayer.podspec
if it that failed again because of source_files then you need to make new tag, and need to push podspec file and your code relatively, because pod trunk push will check your your code using tag on git not locally like pod lib lint YPlayer.podspec

Creating CocoaPod, get error I can't solve about missing file (that is there)

I am trying to create a pod (first one) for this project:
https://github.com/xeppen/GLLingoManager
I run $ pod spec lint GLLingoManager.podspec and I get an error.
-> GLLingoManager (0.1.0)
- ERROR | xcodebuild: Returned an unsuccessful exit code.
- NOTE | xcodebuild: GLLingoManager/Classes/GLLingoManager.m:10:9: fatal error: 'GLNetworkService.h' file not found
I am checking the files and all seem correct. Demo project works etc.
How can I solve this? I dont understand why it says its wrong.
If you use SDK, I think you need to create subspec and specify search paths for each of the SDK may giving issues, for example :
s.subspec "Kairos" do |ss|
ss.dependency "Kairos", "~> 2.1"
ss.xcconfig = { "FRAMEWORK_SEARCH_PATHS" => "$(PODS_ROOT)/Heyzap"}
end

Resources