How to import custom framework into project with cocapods - swift

I currently have an Framework which uses Alamofire, JWT and CryptoSwift which are installed using cocapods.
My framework sucsessfully builds when I use the 'Generic iOS device'. When I go to drag it into my Application and tell it to create a copy, it appears in the 'linked frameworks and libraries' section on the general page. The problem is, when I build my application, I get an error saying that the image is not found. To fix the issue, I removed it from the 'linked frameworks and libraries' section and added it to the 'embedded binaries part'. This however, did not fix my problem.
How can I import a custom framework made out of 3rd party frameworks installed with cocopods? When I write code using my framework, it gives me auto completion so this means that Xcode recognises that my framework is there, however it does not run it on my physical iPhone 6s

Related

Gitlab phase contains a reference to a missing file when adding framework to Xcode project

I am struggling with a problem while using Gitlab CI/CD.
I am using for my project two of my external frameworks. The project builds without errors but when running the pipeline I'm getting an error that says
This Copy Files build phase contains a reference to a missing file 'xxxxxx.framework'.
My project looks like bellow
This is en error I'm getting:
When I add framework file not the framework project then CI/CD will pass BUT then I'm getting the error when trying to archive project
Building for iOS, but the linked framework 'xxxxxx.framework' was built for iOS Simulator.
I don't know how to solve those problems to get everything work.
Thanks for any kind of help.
Regards
In case anyone is having this problem and is cloning a git repository that has submodules, be sure include the submodules when cloning.
Most probably what you will need out of these 2 options is to use the x.framework one. The error
Building for iOS, but the linked framework 'xxxxxx.framework' was built for iOS Simulator.
as it says, comes from the fact that the framework is only built for iOS Simulator.
Why is that?
Well, the iOS Simulator runs on x86_64 architecture (as OS X does), while iOS runs on arm architecture. So you'll have to compile the frameworks for both architectures. Fortunately, there is a way to do this, and basically what you need to achieve is to create a fat binary of the framework.
There is a script here from Sundeep Gupta https://gist.github.com/sundeepgupta/3ad9c6106e2cd9f51c68cf9f475191fa which can be used to compile the frameworks for both, iOS Simulator and iOS target architectures. There are also several different resources on the internet which explain what steps you need to make in order to create fat binaries.

Swift command-line app that uses ArgumentParser

I have a command line app written in Swift. It does not use the Swift package manager, and instead has a rather complex xcode project.
I want to use ArgumentParser. The documented way to do this is to import the Swift package, which Xcode 11 can do in the GUI.
The problem is that the built executable depends on the ArgumentParser framework's dylib. I need a standalone executable that doesn't depend on dynamic libraries besides those that come with Catalina.
When I use the Swift package manager to build a project that depends on ArgumentParser, it is able to do so without a dynamic library dependency. It seems to link in the swiftmodule file.
Is it possible to build a command line app using Xcode that uses ArgumentParser without requiring me to distribute the ArgumentParser dylib along with my main app binary?

Archive failed with custom framework

I have the custom framework name LogginFramework and I use it in my project. I can debug and I can call the class of LogginFramework in my simulator. Now I tried to archive my project to send to the tester, build failed and showing" Use of unresolved identifier 'CryptoHelper'" How can I solve this issue? I already added framework in Embedded binaries and "Linked framework in Libraries" My Swift 3 app rebuilds and runs successfully on all simulators except for Generic iOS Device. If I try to archive it or do a rebuild on Generic iOS Device, I get a No such module error relating to my custom frameworks.
I tried build,clean,delete drived-data but still error
Hope this will help you
Select your Project in Targets.
Then search for Skip install.
Change it into NO.
Then archive your custom framework. (make sure to use Generic
iOS Device ) as a target device.
Export it to where you want.
Then use it with your project.

Error when migrating from Swift 1.2 to Swift 2

I use Realm in my project and so far it has been great ! I have migrated from swift 1.2 to Swift 2 and now I have an error when compiling my code on the device (not on simulator).
Here is the error :
dyld: Library not loaded: #rpath/libswiftSecurity.dylib Referenced
from:
/private/var/mobile/Containers/Bundle/Application/64E2D461-F95C-4E86-B3D3-5FAAA00AF77C/myPhotoCalendar.app/Frameworks/RealmSwift.framework/RealmSwift
Reason: image not found
I really don't understand what it means. I tried some tricks but none of them worked so far. Any one could help me ?
You see this error, because you're using dynamic frameworks, but they are not copied into your app bundle. On the simulator, the dynamic linker can still find the built framework in the build products directory. But this is not present in the sandbox of the device, where your app is executed.
It seems like that's the case because the build phase "Embed Pods Frameworks" is missing from your project. Please make sure that CocoaPods is up to date. (gem update cocoapods) You might then want to use your integration by pod deintegrate and re-install from scratch again. (Alternatively, you could remove the aggregate target Pods_*.framework from the linked libraries.) That should make sure, that all build phases are re-created by CocoaPods.
For references, you should have the build phases like seen below in your project's target:
The mentioned aggregate target framework is seen in the "Link Binary With Libraries" pane as Pods.framework here. The name depends on whether or not you integrate multiple targets of your project and how they are named. So it could be also named Pods_YourApp.framework.

iPhone library: file is not of required architecture

I have searched for hours however I still have no clue what is wrong with my configuration.
My project uses a self-written libray (myLib). This library is compiled to work only for simulator and it works perfectly there.
What do have to change so it compiles for my iPhone Device as well?
This is my current warning:
ld: warning: in /.../myLib.a, file is not of required architecture
This is my configuration (of myLib.a)
I found a lot of articles explaining the reason for this error however I could not find a solution:
The simulator runs on an x86
architecture, while the device uses an
ARM architecture.
What do I have to change to get my library working on my iPhone?
Thanks
Edit:
What I did so far:
Cleaned both projects
Set library to 'Device' (3.1)
Built the library
Dragged the .a file of my library into my application
Result:
This works in simulator but setting the active sdk to device still raises a file is not of required architecture error.
I also tried mahboudz ( thanks for your support) link.
It explains howto built the project using a shell script.
However XCode keeps complaining that the library file is of the wrong architecture and the build fails.
This has to be a really stupid beginners mistake.
You need to add both .a files,the one built for the device (build/$config-iphoneos)and the one built for the sim (build/$config-iphonesimulator) to the new project. Make sure you name them differently before dropping them in. This is how admob and similar offering ship their static libs.
You need to compile your library for Intel so the Simulator can use it (which I gather you have done already), and then compile it for ARM, so it can run on the iPhone. Then you have to merge the two libraries. There are different ways to accomplish that, or make it more automatic.
Here are some links to help you:
http://blog.stormyprods.com/2008/11/using-static-libraries-with-iphone-sdk.html
http://www.clintharris.net/2009/iphone-app-shared-libraries/
I've met the same problem too. But seems you don't need to drag two .a files into the app project to solve this problem. This is what I did:
Drag the static library project into app project's framework group
"Get Info" for the target in app project
Set the direct dependency of static library
Make clean all unnecessary builds(for example the simulator build) in the static library project
Build in the app project