How to use a dynamic framework in a framework? - ios

I am building my framework FooFramework that uses WebRTC framework. After I used the WebRTC framework(https://github.com/zevarito/PodRTC) in my pod as a dynamic framework. My demo app FooDemoApp that uses FooFramework crashes as it runs with not- my-own provision profile on a device. The error message is dyld: Library not loaded... Reason: no suitable image found. Did find... code signing blocked mmap()
I think the problem is that Apple seems doens't allow nested framework. The WebRTC will be signed with my teamIdentifier, but the teamIdentifier is not set on my framework. I wonder what's the proper way except for re-code sign WebRTC?
FooDemoApp would not crash before I added the PodRTC in FooFramework when I run it using not my provision profile on a device.
The relationships between the framework are like this:
FooFramework(before built) includes: PodRTC(not code signed) as a Cocoapod
FooDemoApp(after built FooFramework) includes: my code-signed built FooFramework(code signed with Identifier:io.allen.ALSDK, no team identifier set), which includes code-signed PodRTC(code signed with Identifier:org.webrtc.WebRTC, team identifier PodRTCTeam)
So I have two questions:
How to use PodRTC without crashing on a different provision profile?
Why my demo app wouldn't crash before while it's running with a different provision profile?

Related

iOS Embedded Framework with Embedded Framework

I'm working on a framework which embeds another framework (from CocoaPods) for error logging on iOS. This is working very well, and I can embed such a framework in an iOS application for testing, codesign everything, and debug on my own device easily. Unfortunately, when attempting to upload such an application to Apple for distribution, I get an error message as such:
Invalid Bundle. The bundle at '<myapp>.app/Frameworks/<myframework>.framework' contains disallowed file 'Frameworks'. With error code STATE_ERROR.VALIDATION_ERROR.90206 for id ***
I'm not sure if this message indicates that I'm not allowed to embed a framework in another framework or what. It seems the automatic codesigning Xcode is doing is not recursing to the deepest embedded framework upload (I have a script to manually sign everything on build). Does anyone have experience with an error like this or know where to look? It seems others have asked questions about embedding frameworks in other frameworks before, but most of these are how to get linking to work or how to properly reference these nested frameworks. My issue is specifically if I am allowed to upload such things to test flight/the app store, and how to do so if it is possible. Most people having this issue seem to have disabled swift support, but none of the projects I'm using have swift code.
Nested bundle cannot include a framework. You can check this apple document.
iOS and tvOS support frameworks and Swift system libraries at the topmost app level; a nested bundle, like an app extension, can’t include a framework.
And there is a warning block that worth being noticed:
If you put content in the wrong location, you may encounter hard-to-debug code signing and distribution problems. These problems aren’t always immediately obvious. For example, when building a Mac app, incorrectly placed code might work during day-to-day development, but might cause problems during notarization.
So that is the reason everything seems normal while running in debug mode but failed at distribution.

Issue with Creating Card Connect SDK Xamarin binding Library for iOS

I created a Xamarin Binding Library project to map the card connect sdk for ios and was successful in it. But when I try to create a sample project to test the function its giving me the following error.
Could not create an native instance of the type 'CardConnect.CCCPaymentRequest': the native class hasn't been loaded. It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.
You can find the Objective C & Swift sample and documentation in the
link below https://developer.cardconnect.com/mobile-sdks#iOS
I've shared the binding library project and the necessary SDK framework in Github
I am posting the solution I got after multiple communications with card connect team and microsoft support team.
The working solution is updated in Github: Card Connect SDK Binding
There are couple of points to be noted while anyone is going to utilize this,
Specifying the properties of the native library, you need to set the
below items
Force Load : selected
Linker flags: -lxml2
Smart Link : selected
Setting the Additional mtouch flag where you use it, follow the below steps,
=> choose “options” at the bottom
=> find “iOS Build”
=> find a text input box called “Additional mtouch arguments”, then add the follow script “--optimize=-remove-dynamic-registrar”
Adding the merchant id in the Entitements.plist where you use the card connect library.
Note: You can test the sample using apple pay sandbox account for that you need an apple developer account & apple itunes/appstoreconnect account, with that you need to create the certificate mentioning the apple pay capability and create a provisioning profile with that certificate and
the devices you intend to test. Then sign your test application with the provisioning profile and load it in your iOS device either via Diawi.com or any other testing service. You should be good to verify your solution.

Missing dylibs from Framework location

After successfully building and archiving app, I'm trying to upload it to iTunes Connect, using Xcode Organizer.
The application successfully passes the validation and it uploading to iTunes Connect.
But then iTunes Connect sends me mail:
We identified one or more issues with a recent delivery for your app, "[APP_NAME]". Please correct the following issues, then upload again.
Invalid Swift Support - The expected dylibs are missing from the app’s
Framework location, such as /Payload/[APP_NAME].app/Frameworks.
All the Frameworks and Libraries are linked to project.
Since app works on React Native and uses some Swift Libraries, I setted these values:
For main project: Always Embed Swift Standard Libraries = Yes
For custom framework: Always Embed Swift Standard Libraries = No
What I'm doing wrong? If app building and working on simulator.
P.S.: Also, i use these libraries: Google Signin and FacebookSDK, and they are both linked.

dlopen() returns null when dynamic library is codesigned using distribution certification on iOS

Hi I am working on iOS app using dynamic library.
Here is the problem I am encounting recently.
I apply dynamic library which consists of nativce fuctions.
It is ok when I use dlopen() to load dynamic library with codesigning developer certificaton.
However, dlopen() returns null which means 'loading library failed' using dynamic library with codesigning distribution certification to verify the app is ok on release mode.
Is there any problem during testing process?
Please advise me on right direction.

iOS App Enterprise Deployment: Provisioning Profile for Libraries

We are currently trying to deploy a new version of an iOS Enterprise App via Mobile Device Management after some changes in architecture.
The same app has succesfully been deployed a couple of times in the past, but we recently added a library to the app (in order to reuse some of our code in different places).
The app runs fine when started from Debugger, but crashes immediatly after start when signed and deployed via Mobile Device Management. iOS Crashlog reveals that the library we added does exist but is not loaded.
The error message reads:
Dyld Error Message:
Library not loaded: #rpath/MYAPPLib.framework/MYAPPLib
Referenced from: /private/var/mobile/Containers/Bundle/Application/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/MYAPP_iOS.app/MYAPP_iOS
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/MYAPP_iOS.app/Frameworks/MYAPPLib.framework/MYAPPLib: mmap() error 1 at address=0xXXXXXXXX, size=0xXXXXXXXX segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/MYAPP_iOS.app/Frameworks/MYAPPLib.framework/MYAPPLib
(The bundle identifier and application name have been changed)
We suspect that this might be a signing issue. After archiving the product and exporting ("Save for Enterprise Deployment"), we noticed that no Provisioning Profile is selected for said library (see screenshot below)
Long story short, the question is:
Is it necessary for a library in an iOS App to have a Provisioning Profile? If so, how can I assign one?
All right, so we are still not sure what exactly the problem was. But we can say that the error was resolved by issuing a new developer certificate. So if you are facing the same problem, maybe you want to try this as well.
From the console seems that the app does not find the framework file.
Make sure in your Build Settings you set the Runpath Search Paths to #executable_path/Frameworks
Make sure in Build Phases to have your Framework under Embed Frameworks.
Add your framework under Link Binary With Libraries.
If your framework is developed under same project make sure you make sure you have it under Copy File under Build Phases.

Resources