Objective-C Xamarin Binding not working on device - ios

Hello Guys I'm trying to make a Binding for our Objective-C SDK, I follow the steps in the Xamarin walkthrough it works on simulator but not on device, what could be the problem knowing that I'm using Xcode 6.4, I also use a Fat library (one that contains the builds for i386 and armv7 architectures).
I've tried cleaning and rebuilding the project, and also added the -v-v-v as additional builds parameters but nothing!!! All i'm getting is this error message :
Failed to load Aot Module

On Xamarin forums they say that it gonna work if you just clean the solution. So if it doesn't help, try removing all the "bin" and "obj" folders in all the projects and build again. If even that doesn't work you should probably consider it as a bug and write to their support.

Related

dyld: Library not loaded: #rpath/libswiftSwiftOnoneSupport.dylib

I've built a Swift framework and now I'm trying to start building a Swift iOS application that will use that framework. I'm getting this error:
dyld: Library not loaded: #rpath/libswiftSwiftOnoneSupport.dylib
Referenced from: /Users/tdean/Library/Developer/Xcode/DerivedData/NFLApplication-ejmafvjrlqgjaabggwvadjarjjlg/Build/Products/Debug-iphonesimulator/NFLStatsModel.framework/NFLStatsModel
Reason: image not found
I've scoured SO and found similar reports and tried the fixes listed there, including:
Clearing out my DerivedData folder
Restarting Xcode and the iPhone simulator
Ensuring that Always Embed Swift Standard Libraries = YES is set, both in my framework and my application's build settings
Ensuring that Enable Bitcode=NO is set, both in my framework and my application's build settings
Ensuring that Runpath Search Paths is set to #executable_path/Frameworks, both in my framework and my application's build settings
Copied all the libswift files from my Xcode installation into a local copy within my project, and added a custom build phase to copy those files into the frameworks folder.
In every case, I get the same error when I try to run my application.
Xcode Version 8.1 (8B62)
Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)
I eventually got this working using a mix of fixes. I'm not sure if all of them are needed, but I'm documenting what seemed to work for me here, just in case anyone else can benefit by what I've found.
I have set Always Embed Swift Standard Libraries to a value of YES in the build settings tab for both my Swift framework and in the Swift application that uses the framework.
I have added Foundation.framework to the Linked Frameworks and Libraries section of the general tab for both my Swift framework and in the Swift application that uses the framework.
I have added Foundation.framework to the Embedded Binaries section of the general tab for the Swift application that uses the framework.
With all 3 of these settings in place, I am able to build and run my application without encountering this error.
This might not be the case for everyone, but I solved it by actually writing some code in the main target.
I had an empty project consisting of a framework and a test target, and when running tests I was getting this error. Apparently Swift is pretty smart to detect that you don't actually need this library and does not link to libswiftSwiftOnoneSupport.dylib.
The fix is just to add some code, I just added:
class Test {
func a() { print ("something") }
}
and libswiftSwiftOnoneSupport.dylib got linked.
After several days of being stuck with this issue I finally found something that worked for me; hopefully this will help others too.
Turns out that specifically using print() anywhere in the code will somehow force libswiftSwiftOnoneSupport.dylib to be loaded and the issue will go away.
I'm using Xcode 10.1, Swift 4.2 and the pod that was giving me this issue was Nimble.
BTW, I am aware of #S2dent's suggestion to "just add some code" but in my case my framework already had several different classes so it didn't help me.
How are you installing your dependencies?
I had a similar issue:
dyld: Library not loaded: #rpath/libswiftSwiftOnoneSupport.dylib
Referenced from: <internal framework>
Reason: image not found
It turned out to be related to Swift whole-module optimization.
Using Carthage as a dependency manager, they were being compiled for Release, and thus compiled with whole-module optimization, which Xcode suggested I turn on. Running the app on the simulator compiles it for Debug. I'm guessing that dynamic frameworks cannot be at a different level of optimization from the app running it.
The solution was to explicitly specify the configuration I wanted Carthage to build for. (carthage bootstrap --configuration Debug) Oh, and cleaning my build folder, of course.
I had the same issue, adding the library (my own build one) to Linked Frameworks and Libraries in General tab of the app solved the issue.
You can also provide an Host Application to your test target if you don't want to add Foundation.framework to Linked Frameworks or Embedded Binaries
You can solve this by setting "Always Embed Swift Standard Libraries" to "Yes" in the Build Settings of your target.
It is an dynamic linker error which links binary in load or runtime
[#rpath]

Undefined symbols for architecture x86_64 with known good framework.

XCode 7.2.1
iOS 9.2 SDK
I compiled Mobile VLC Kit into a .framework for all architectures quite some time ago and have been successfully using it in one project with no issues. Now I want to use it in a new project and I'm unable to build due to error "Undefined symbols for architecture x86_64" referencing pretty much every function in VLC.
This is a mixed swift/objective C project however I'm not referencing VLCKit from the swift side. The only think referencing VLC is legacy objective C code that has been working fine with this framework in another project.
Target memberships are correct.
Framework search paths are set and verified correct
Build Active Architecture only yes/no doesn't make any difference
32bit Simulator (iPhone 4S) and 64bit Simulator (iPhone6) show same problem.
Problem seems to happen wherever I import the framework, even if I'm not calling any methods on it. Even if I remove the Objective C classes that use VLC Kit and ONLY impo
I tried copying the framework into the project rather than referencing it but it doesn't make a difference.
Compared settings from previous project and I can't see any difference.
Framework is in "Link Binaries with Libraries" list.
I'm at a loss here.
I just spent a ton of time with the same error. It all boiled down to not having a Host Application set for my Unit Test and "Allow testing Host Application APIs" wasn't checked. Once I set it like in the image, it finally stopped producing errors. Hopefully this is the solution for you as well.

Xcode - debugging library built outside project

I have a C library whose code resides in say /repos1/clib. I build that from the command line using the latest iOS sdk to create clib.a (including a debug build for the simulator) which I copy to an iOS project say in /repos2/proj.
I have been using this setup for several years. The old C library very occasionally might require some debugging and I was pleased by the fact that Xcode simply stepped into the library code that was outside the project (inside repos1) without having to do any setup - it just worked.
But this was up until a few Xcode versions ago. I am not sure exactly when it changed - perhaps when they moved from gcc to llvm? - since I very seldom needed to debug the C code, but for a while now I only get dissasembly when I try to debug the C library from the iOS project (including at least references to the C file name & line number). For the few times I need to debug it is very inconvenient (I create a temp project that includes the C code).
So, any idea why it worked before and doesn't now? Where should I look? Could it be the way I build the C library, maybe there was a flag in gcc I was using that does not have an equivalent in llvm (I can find and post the old build command I was using if it is relevant)? Is the issue in Xcode and there is a way to tell it where to look for the sources?
Thanks!
Edit: To make it clear, I can add the C library either as the source or as a subproject in Xcode, however for reasons that are out of scope this is not helpful for this specific project. So, can it work like it used to with older Xcode versions? If not, it would still be interesting to know why not.
The recommended approach is to create a library project in Xcode, one for iOS (there is a template for it), then when you get that to build add that project to your app, make sure the lib is a dependency and gets linked. There are many tutorials on the web how to do this.
Then as iOS evolves and new architectures (armv7s) arrive you simply update both projects.
I was struggling with the same issue.
I tried resetting in library/application project all options related to symbol stripping and copy application project to same truecrypt drive as library project but it didn't help.
In my case it appeared it was an app project issue. Same library could be debugged in another app project with source code so that was a clue.
I had more than one version of the same library in app project and set only target membership to choose which should be used. Not sure if that could affect my app project somehow.
Nevertheless after deleting all libraries and copying them to app project again I was able to debug libraries with access to source code.

iOS project builds for armv6 when armv7 is specified (target is iOS 5.1)

I get a long list of errors that spit out (for every source file I have) linker errors to the .o files (stemming from said sources). The error for every one basically resolves to this:
CompiledSource.o, file was built for i386 which is not the architecture being linked (armv7)
Except that the issue is actually warning, technically. However, at the end of compilation/linking phase the project refuses to build with a simple Linker command failed with exit code 1 error.
I've been spending the past 2 hours trying to figure this one out.
In Targets->ProjectName->Architectures->Valid Architectures I have both armv6 and armv7 selected. I ALSO have my build target set for iOS 5.1.
In my Targets->ProjectName->Build Phases->Copy Bundle Resources, I have all of my resources added (I assume this is where resources such as image and nib/xib files are added).
Is there anything I can do about this? I've tried cleaning the project, removing all files from DataDerived folder in XCode root, and even cleaning out /var/folders. Admittedly, this project hasn't been touched since at the very latest 2011.
I should note that I'm pretty new to iOS stuff (as well as Xcode). Unfortunately, this project is under an NDA as well so I can't reveal too much info. However, if anyone has any questions I will answer the best I can.
Are you sure its an iOS application? Because that sounds like its linked to a custom framework that got build for i386 (OSX-intel) which would probably never work on iOS.
Did you try to Product->Clean? or [alt] Product->Clean Build Folder ?
Maybe have a look at some example code from apple and see how these iOS projects are struktured.

iOS framework project breakpoints not working

I've created an iOS framework project using the famous (and excellent) iOS Universal Framework Xcode template.
But now I've encountered an annoying problem that I can't seem to fix which is that I have an iOS application project that references the framework project and when I run that and have breakpoints set in the framework they don't get it. It seems GDB doesn't have the debug symbols for the framework.
I've made sure that debug symbols are not stripped from the framework and the type is set to "DWARF with dSYM file".
Anyone have any ideas what might be wrong and how to fix it?
My setup:
Xcode 4.2.1
iOS SDK 5.0
I ran into this issue while linking a dynamic framework to a test application in Xcode 7. I was able to avoid the error by ensuring the following in the build settings of my dynamic framework:
"Generate Debug Symbol" - 'Yes'
"Strip Debug Symbols During Copy" - 'No'
Several things comes to my mind regarding your problem. Give them a try and see which ones work for you:
Make sure to have the "Other Linker Flags" on the "Linking" section of the framework's "Build" Info.
Make sure that you have the framework's built in the correct configuration (ie, if you compiled the framework's in Release and are using it with your project set to Debug you might get issues)
Make sure you added the correct framework .a file to your project (actually two issues here: you can have added the Release version - so no debug symbols in there - AND you have to make sure that your projec is not pointing to some old build version)
Check that both the framework's and your project have the "Level of Debug Symbols" on the "Code Generation" section of the "Build" Info set to "All Symbols [full, -gstabs+ -fno-eliminate-unused-debug-symbols]"
If all alse fails try to empty the XCode caches and remove the framework reference from your project. Then clean and rebuild the framework (all configs: device-debug, device-release, simulator-debug, simulator-release, ...) and add it again to you project. Clean and rebuild your project and cross your fingers... :-)
I have also experienced this issue. One way that I have been able to work around this by merging both projects into a single workspace.
Instructions on how to do this can be found at http://developer.apple.com/library/ios/#recipes/xcode_help-structure_navigator/articles/adding_a_project_to_a_workspace.html.
NOTE: I have also experienced a bug adding projects to workspaces where there appears to be no files in the recently added project to the workspace. I have found this is easily remedied by restarting Xcode after all of the projects have been added to the workspace.

Resources