Live Rendering a custom component using IB_DESIGNABLE from a pod dependency - ios

I'm having some difficulty using IB_DESIGNABLE in a pod.
I created a custom view which I marked as IB_DESIGNABLE and made a sample project that uses it. No problems so far.
The issue happens when adding that custom view as a pod dependency. Although the project builds and runs successfully, there is an error when the storyboard that uses the custom view is opened. The Live Rendering process starts and tries to show the view live inside Interface builder but it fails with the following error:
This is too bad because we lose Live Rendering which is, in my opinion, one of the best features from Xcode 6.
Cocoapods gem version: 0.34.4
Xcode version: 6.1 (6A1052d)
I've tried with other projects that use IB_DESIGNABLE and have a podspec:
https://github.com/Eddpt/EAColourfulProgressView (Class: EAColourfulProgressView)
https://github.com/hayashi311/HRButton (Class: HRButton)
https://github.com/Estimote/iOS-Indoor-SDK (Class: ESTIndoorLocationView)
Someone else had the same issue in Estimote - Indoor Location Error but the solution described means losing Live Rendering capabilities.
Has anyone been able to use a IB_DESIGNABLE component through Cocoapods?
Error: "failed to load designables from path (null)"

This has been fixed in the latest version of Cocoapods (0.36.0.beta.1).
To install this version:
[sudo] gem install cocoapods --pre
More information about Cocoapods with frameworks here
In order to fix the Error: "failed to load designables from path (null)":
platform :ios, '7.0'
use_frameworks!
target 'test' do
pod 'EAColourfulProgressView', '~> 0.1.0'
end
target 'testTests' do
end
Add use_frameworks! to you Podfile.

When specifying your custom class in the Identity Inspector, are you specifying from which module this class should be loaded? The module should be the name of the library the class comes from.

I Resolved my problem using use_frameworks! on the PodFile, in the first Line. (don't forget the !)
IBInspectable properties must be Dynamic, so it asks for a Dynamic Linkage of the Library. By using the above line, as soon as you set the class of a control, it will build the framework and link it, resolving this binding issues. When I upgraded to beta, Parse stopped working.
Hope it helps someone.

Related

Using React Native iOS dependency in Objective-c

I currently have the following dependency in a ReactNative project's package.json:
"vital-health-react-native": "file:../packages/vital-health-react-native"
This package has a .podspec with the following dependency:
s.dependency "VitalHealthKit", "~> 0.7.7"
Because I am dealing with HealthKit and background delivery, I need to be able to call a method from this dependency inside the AppDelegate.mm.
I have tried everything to import VitalHealthKit in the .mm and even in the .h, but the dependency is never found. The spec for VitalHealthKit can be found here.
What am I missing?
I’ve not done sub-dependency imports myself but I think one would need to add the pod to the app project’s Podfile like so
pod 'VitalHealthKitRN', path: "#{path_to_packages} /packages/vital-health-react-native/VitalHealthRN.podspec"
Having done that, if one still can’t import VitalHealthKit in the app, it might be necessary to reference VitalHealthKit native pod in the Podfile directly, either in a usual way (that might create a conflict of dependency versions with the RN pod) or using a local relative path, similar to the above. Might also have to use_frameworks! if you don’t already to avoid double-linking vital health kit. Hope this helps.

Class is implemented in both when running IOS simulator

I'm using cocoapods version 1.9.1 and Xcode 11.3.1
I'm following this tutorial https://docs.snapchat.com/docs/tutorials/login-kit/ios/
I keep getting this error that says class is implemented in both when running my app on IOS simulator, the problem lies in CoreSimulator/Devices
Class SCSDKCertificateTrust is implemented in both
/Users/Developer/CoreSimulator/Devices/EB370499-8654-42DD-9FC0-
F7ACB17C0532/data/Containers/Bundle/Application/695ED9C1-3329-457C-BCED-
3670C52E4E19/Test.app/Frameworks/SCSDKLoginKit.framework/SCSDKLoginKit (0x1033dba50) and
/Users/Developer/CoreSimulator/Devices/EB370499-8654-42DD-9FC0-
F7ACB17C0532/data/Containers/Bundle/Application/695ED9C1-3329-457C-BCED-
3670C52E4E19/Test.app/Frameworks/SCSDKCoreKit.framework/SCSDKCoreKit (0x10339b098). One of
the two will be used. Which one is undefined.
My Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Test' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for Test
pod 'SnapSDK'
end
I'm not sure how to fix this problem and I have searched the net and found multiple solutions especially on SO
Class is implemented in both. One of the two will be used
Class is implemented in both, One of the two will be used. Which one is undefined
Unfortunately most of the solutions are about fixing it on .xcconfig file and remove in OTHER_LDFLAGS.
I tried those two solutions and it didn't work, could it be because of the cocoapods version?
because I tried this on my Xcode 10 version and still produced the same problem
For me:
Go to your Project in the top of the file navigator in Xcode and click Package Dependencies. Remove any dependencies that you may have installed using 'Add Package' instead of with cocoapods, or that may be causing the error.

Include of non-modular header inside framework error - how do you make transitive dependencies work with cocoapods?

I have created an open source library (https://github.com/linkedin/LayoutTest-iOS) which has two Cocoapods inside - LayoutTest and LayoutTestBase. LayoutTest depends on LayoutTestBase and one of the .h files needs to import something from LayoutTestBase. Currently, I do this using:
#import LayoutTestBase;
However, this only works if the application uses use_frameworks! in their Podfile. Some apps do not want to use this cocoapods option. Without use_frameworks!, it works if I use:
#import <LayoutTestBase/LYTLayoutPropertyTester.h> // OR
#import "LYTLayoutPropertyTester.h"
However, when using this with use_frameworks!, it gives the error: "Include of non-modular header inside framework module 'LayoutTest.LYTLayoutTestCase'"
Clearly, there should be a way of doing this import regardless of whether the user uses use_frameworks! or not in their Podfile. How can I get this library to compile and run correctly?
Research
I've looked on stackoverflow, and this seems to be the most similar question:
CocoaPods framework with dependencies - include of non-modular header inside framework module. It mentions that it's a problem with the Parse library, but doesn't mention how it needs to be fixed. Since I own the dependency, I can fix this.
I've also tried setting Allow non-modular frameworks to YES in all settings (projects, unit tests, all pods, etc), and this doesn't seem to do anything.
To Reproduce
Create a new project. Add this Podfile:
target :'{MyAppTarget}Tests' do
pod 'LayoutTest'
end
Run pod install. Try to run unit tests on the app. It will fail. Now, try changing LYTLayoutTestCase.h to use #import <LayoutTestBase/LYTLayoutPropertyTester.h>. It now works. However, if you add use_frameworks! to the Podfile, it no longer works.
I don't think this is the optimal solution but the work around I found was to do an #if __has_include and do both solutions depending on whether it was built with use_frameworks!
Here's a link to the github issue with more details: https://github.com/linkedin/LayoutTest-iOS/issues/8
If anyone knows how libraries like parse-SDK do it without these workarounds, I'm still interested.

XCode keeps forgetting imported Frameworks

I have Xcode 6.3, using Swift, importing a Parse 1.7.1 Framework as usual (dragging, copying) and I set it up in a group: Frameworks.
I compile and everything works fine for a while with it, until the compiler does not recognize this sentence anymore:
import Parse
It gives me the error:
No such module 'Parse'
A workaround is to delete the Framework and copy it again, but after a while it starts getting annoying, and I would really like to know the cause.
I only code and build in the meantime (and occasionally creating new swift files), so I can't explain why this happens.
If you're targeting iOS 8 and above, you can tell Cocoapods to use frameworks, by putting
use_frameworks!
in your Podfile, like this example:
use_frameworks!
platform :ios, '8.0'
# Parse
pod 'Parse', '~> 1.7'
I could fix the same problem by doing so.
I just fixed this same issue today with my project. I imported my obj-c framework in a swift project and it worked for a while, then xcode seemed to forget it causing the same error you have.
apple docs
I fixed it by referencing the bridging header in Build Settings.
Under Build Settings, make sure the Objective-C Bridging Header build
setting under Swift Compiler - Code Generation has a path to the
header. The path should be relative to your project, similar to the
way your Info.plist path is specified in Build Settings. In most
cases, you should not need to modify this setting.
I just typed in the name of the bridging header folderName/xxxx-BridgingHeader.h in the field that states bridging header and all was well again.

Using Cocoapods in Cocoa Touch Framework?

I'm developing a framework that requires use of AFNetworking. So I started by creating a new and shiny Cocoa Touch Framework and as usual I created a pod file with the following stuff in it:
source 'https://github.com/CocoaPods/Specs.git'
pod 'AFNetworking', '~> 2.5'
Obviously on a normal project this would create the workspace and everything would be super smooth... But since I picked Cocoa Touch Framework I am not able to import AFNetowrking.h into my ProjectName.h. The error I'm getting is:
Include of non-modular header inside framework module...
So I actually looked this up! It seemed that all I need to do is to go to my build settings and set Allow Non-modular Includes In Framework Modules to yes and my problem will be solved... but that didn't help either.
Another thing I tried doing was to also set the target membership of AFNetworking.h header file to public. But that didn't resolve the issue and I'm still getting the same error.
I'd appreciate if anyone can give me a step by step mini guide on how to do this?
It is worth mentioning that I'd like to be able to use the AFNetworking library in swift as well.
When importing a module using cocoapods in your source code you must import it like
#import <AFNetworking.h>
rather than
#import "AFNetworking.h"
Here's my pod file:
source 'https://github.com/CocoaPods/Specs.git'
pod 'AFNetworking', '~> 2.5'
use_frameworks!
You need to make sure you install the beta version of CocoaPod (0.36). The only issue with this is that you will be able to run it on iOS 7 but it will not pass the validation on apple application submission (keep that in mind).

Resources