I had added the ChartViewDelegate to my program and set the 'chartView.delegate = slef',but the delegate method still can not be called.What should I do?
Xcode 8.2
Charts 3.0.1
OC
Related
Edit:
This problem occurs after XCode 12 Beta5. Xcode doesn't allow different modules to define same names (Probably for public classes & protocols). Alamofire and Kingfisher appears to define SessionDelegate at the same time. I'm still trying to find a solution..
I'm implementing iOS 14 Widgets in our application. I have started working with XCode 12 Beta 2 and everthing was compiling fine. When I have updated XCode to XCode 12 Beta 6, I faced with following error:
'SessionDelegate' has different definitions in different modules;
first difference is definition in module 'Kingfisher.Swift' found end
of class
I'm also attaching the screenshot of the file with error.
Is there any way to edit header files to have different names for SessionDelegate for Alamofire or Kingfisher? Is there any workaround to overcome this issue?
Here are things I have tried so far:
I have updated both Alamofire and Kingfisher to latest version
I have cleaned Podfile.lock and all pods as well as Derived Data
I tried to compile with Legacy Build System
You can try SWIFT_INSTALL_OBJC_HEADER = NO, it works for me
At this moment (Xcode 12.0 or Xcode 12.2b2), the only possible solution is to rename the Objective-C interface and avoid conflicts. This could be done by one of:
Rename conflicting class entirely, update all places where it's used (e.g. replace SessionDelegate by KingfisherSessionDelegate)
Add #objc(...) attribute to a Swift class, which will update the Obj-C interface in a generated ...-Swift.h file and avoid the names conflict.
// SessionDelegate.swift
#objc(KFSessionDelegate)
class SessionDelegate: NSObject { ... }
// Kingfisher-Swift.h
#interface KFSessionDelegate : NSObject
...
#end
This solution is already included in the Kingfisher 5.15.4 release and could be applied to any other libraries and your own frameworks.
Also, the thread on Apple forums: https://developer.apple.com/forums/thread/658012
The error is saying that you have multiple classes with the same name SessionDelegate in different modules. This error is related to Xcode 12.
For now, a quick solution is to install the module with CocoaPods (if you're using Carthage) and if needed, rename the SessionDelegate interface.
If you guys need a temporary solution, here is how for Cocoapods users:
Clone the Kingfisher library to the same folder level with your project. You can get it from Github
Open Kingfisher.xcworkspace in XCode and rename SessionDelegate.swift file under Sources/Netowking to KingFisherSessionDelegate and change the class name as well accordingly.
Rename the usages of SessionDelegate to KingfisherSessionDelegate which is only available in Sources/Networking/ImageDownloader.swift as of Kingfisher version 5.15.0
Add local path in your Podfile
pod 'Kingfisher', :path => '../Kingfisher'
I too had the same issue, sam's solution worked for me but with one change. There are 2 pods with the same definition so i changed the value of SWIFT_INSTALL_OBJC_HEADER to NO for both the pods. After doing it i was getting import error in one of the pod. So then i changed SWIFT_INSTALL_OBJC_HEADER to YES for that particular pod which was having the import error and kept the other pods SWIFT_INSTALL_OBJC_HEADER to NO. This worked for me.
for me worked when I update the 'SWIFT_INSTALL_OBJC_HEADER' key in podfile
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if target.name == 'Alamofire'
target.build_configurations.each do |config|
config.build_settings['SWIFT_INSTALL_OBJC_HEADER'] = 'No'
end
end
end
end
end
I am currently creating a Swift Package. By default, the package generated by Xcode contains the XCTestManifests file with the following code:
#if !canImport(ObjectiveC)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(TestPkgTests.allTests),
]
}
#endif
As you can see, this is the function that returns all test cases. However, I am curious when it will be called and in what case the condition !CanImport (ObjectiveC) will be satisfied.
This is needed for running tests on platforms other than macOS.
On macOS the test runner relies on the ObjectiveC runtime which is absent on other platforms, hence canImport(ObjectiveC) is false. The allTests() function is called from LinuxMain.swift file, you can generate it on macOS by running swift test --generate-linuxmain.
In newer SwiftPM releases there is an alternative option for running tests on those platforms: swift test --enable-test-discovery. You can read more about it here: https://forums.swift.org/t/pitch-enable-test-discovery-by-default/36619
Swift 5.4: Automatic Test Discovery Included
Swift 5.4 (April 26, 2021 release) includes test discovery by default.
Automatic test discovery is now the default on all platforms
swift test --enable-test-discovery is no longer needed.
The Swift 5.4+ swift package init template does not generate allTests and XCTestManifests.swift.
I have my custom framework, let's call it TestFramework, and project, in which I want to include that framework, lets call it TestProject.
TestFramework use libraries, such as Alamofire, which I added to TestFramework using Carthage. When I added TestFramework to TestProject, the project wouldn't compile until I added Alamofire (and the other libraries that exist in TestFramework) using Cocoapods to TestProject. This worked until I updated Xcode to version 10. Now, when I try to access libraries methods in TestFramework, I get this:
No error description provided, and I am using latest version of Alamofire.
I am sorry for such simple question, but I've searched everywhere and read through the paper-onboarding documentation but still can't find a solution to this problem.
I am building a simple iOS app project using the paper-onboarding library, by following this YT tutorial. I keep receiving the error: No such module 'PaperOnboarding'
import UIKit
import PaperOnboarding // <<<ERROR HERE>>>
class OnboardingView: PaperOnboarding {
/*
// Only override draw() if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func draw(_ rect: CGRect) {
// Drawing code
}
*/
}
I'm not sure how to solve this, could someone shed some light on this?
Xcode: Version 9.3
Cocoapod: Version 1.4.0
Paper-onboarding: Version 4.0.2
This error has nothing to do with the library. It's definitely an error on your part or on the configuration of your project.
How are you adding the library to your project?
If you're adding using CocaPods:
Make sure you do pod install or pod update
After that always open the .xcworkspace file in your project and not the .xcodeproj
If you are opening the correct file:
Check the POD project and the target for the pod you added and in the build settings, make sure Swift Version matches your project version.
Clean your project and run
Close and re-open XCode
but it could be several other things. But make sure all the configuration is correct.
Some Pods require you to use the use frameworks! statement in the Podfile.
I created a Swift library with swift package init --type library and generated an Xcode project with swift package generate-xcodeproj.
Now I'm trying to run the Test scheme in Xcode. It prints following error:
Module '<title>' was not compiled for testing
However when I run swift build and swift test in terminal, it works fine.
I have ENABLE_TESTABILITY set to YES in all of the targets. I didn't change anything in the project except this. How can I make Xcode perform unit testing?
You need to set the "Enable Testability" to Yes in build setting over your "Main Target"
I was having this issue today, it seems like #testable cannot be used with projects generated by Swift Package Manager.
Removing #testable from my import statements solved this issue. Of course, this means we can only test the public interface of our modules.
Xcode -> Product -> Scheme -> Edit Scheme
Select the Info tab.
Set the following -
Build Configuration: Debug
Add a check mark to Debug executable
Tested with Xcode 12.4(12D4e) and iOS 14.1 deployment target.