Error when migrating from Swift 1.2 to Swift 2 - swift

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.

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.

Duplicate symbols for architecture arm64 after installing AppDynamics pod

I'm using Xcode 11.3, my app is in Swift. When I add AppDynamics pod to my project and try to build, I get "1222 duplicate symbols for architecture arm64" error. All duplicates are in several .a static libraries that are unrelated to AppDynamics and that are all linked in "Link Binary With Libraries" in Build Phases (there are other .framework-s here too but they don't cause any issue). I tried all the standard things like cleaning build folder, deleting derived data, restarting computer, building with Xcode 11.2 version, playing with -ObjC flag, but none of this helped. Since there are so many duplicates, changing those static libraries is not an option as it has been suggested in some threads. Project also has other pods added that all worked fine.
I see that there were other similar questions, but I could not find an answer that worked in my case, I've been stuck on this for more than a day already. Does anyone have some other suggestion what I could try? I would like to understand why this is happening?

Cocos2d-x project's 2nd rebuild onwards gives an error 'Xcode cannor run using selected device'

Fresh cocos2d-x project build using Xcode runs normally on iOS simulator/device, but after making changes to cpp source files, rebuild fails with error-
Xcode cannor run using selected device. Choose a destination with a supported architecture in order to run on this device.
The only way to make it work is delete build binaries (i.e. delete XCode>Derived Data folder), and take fresh build after restarting Xcode.
Can someone please help me resolve this issue?
Additional Details:
This error is related to mismatching device architecture and armv6 armv7 flags. But first build works fine, and stops working after second build onwards, that means this is not a possible issue.
If the project is not using cocos2d-x (i.e. plain Objective-C project), then there is no such error after second build.
Compiler selected: Apple LLVM Compiler 4.2
Thanks in advance!
Following my comment you should make sure you use the latest templates for creating cocos2d projects. Some templates will only work for a specific Xcode version so make sure you use the right templates for your xcode version (There are some for xcode 3.x and others for xcode 4.x)
Change Valid architecture to armv7 and armv7s. Remove armv6. See image for more information.

still dyld: Library not loaded

I am integrating Facebook in my application. As required frameworks I added to the project.
But the app crashes without loading even first screen.
dyld: Library not loaded: /System/Library/Frameworks/AdSupport.framework/AdSupport
Referenced from: /var/mobile/Applications/8E09C9AA-CA81-4C26-AEED-B2C632B60A54/Gridlocked.app/Gridlocked
Reason: image not found
I use Xcode 4.5 and my iPad runs iOS 5.1 The app runs fine on the simulator (both 6.0 & 5.1), but when I connect the iPad and change the deployment target to 5.1 (as without this the device is not shown to run), the app crashes.
Found out the solution to the problem.
The problem was setting the added frameworks as required instead of optional
GO TO Project-> Targets-> Build Phases-> Link Binary with Libraries
There, set the status of added frameworks to Optional
This solved my problem.
It may happen because of framework compilation. I worked out it
App target -> Build Phases -> Embed Frameworks.
So mark copy only when installing on. Clean the project and run it!
You need to add this Framework to Xcode.
Right-click on "Frameworks" > Choose Add > Existing Frameworks
Locate "AVFoundation" then choose Add.
If you want to add it manually, choose the other button and navigate to:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/System/Library/Frameworks/AVFoundation.framework/
Replace the iPhone SDK version with whatever you are building against.
Perhaps also see this answer: Missing AVFoundation.framework
Also, sometimes you just need to close Xcode, then clean and rebuild.
also see dyld: Library not loaded: AVFoundation.framework Reason: image not found
I had the same problem. i keep all .dylib in system root directory usr/lib it working fine. At the run time .o file not get .dylib file path then it gives an error.

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