Realm: bcsymbolmap is missing from working copy - ios

I'm trying to include Realm 2.0.3 and RealmSwift 2.0.3 iOS Swift 2.3 as dynamic framework binaries in my project. I find that they take too long to compile.
I'm able to build my project and run it in the simulator just fine, but when I archive I'm receiving this error:
This is how I'm including the frameworks (simply drag and drop into project):
Help!

Per #TiM's suggestion, in the target's Build Phases I made sure that the two dynamic frameworks are added in in these sections:
Link Binary with Library
Embed Frameworks
Dragging and dropping the frameworks in the project does NOT automatically add them to Embed Framworks

Related

Embedding XCFramework in application with project framework dependencies

I have an Xcode workspace which features a project with an iOS Application target, and another project with a Framework target. The framework target is dependent on another framework, which is integrated in the form of an xcframework:
MyApp
MyFramework
OtherFramework
Using regular OtherFramework.framework would require it to be linked to MyFramework and then embedded in MyApp even though MyApp doesn't require the framework itself. However when integrating with xcframework, this project then fails to build with a No such module 'OtherFramework' error.
Project settings:
MyFramework Project
MyApp Project
Removing OtherFramework.xcframework from the MyApp target fixes the build issue, but then causes library not loaded errors as the framework is not present in the application.
Demo project here: https://github.com/msaps/XCFramework-Link-Issue
How are you meant to link an xcframework in an application and link in a dependent framework?
Why?
pyckamil just posted this article which explains the issue in detail: Everything wrong with XCFrameworks.
It turns out Xcode has an optimisation for the ProcessXCFrameworkLibrary step which extracts the correct .framework from an .xcframework for the active build architecture. This is only run once which causes issues for additional targets that try to link the same framework.
Update
This issue is resolved in Xcode 12.0
UPDATED - Resolved in Xcode 12.0
shinsuk came up with a reliable workaround that works by adding architecture-explicit framework search paths to ensure the correct .framework within an XCFramework is found.
Details can be found in the README.
Check build settings and defining the Framework Search Paths to a folder which contains the frameworks in question. If the frameworks are placed in your project directory, simply set the framework search path to $(SRCROOT) and set it to recursive.
check the response Getting error "No such module" using Xcode, but the framework is there
IMO, It seems not xcframework issue.
Check out this answer: https://stackoverflow.com/a/59435627/2661407
Umbrella frameworks are not supported on iOS, watchOS, or tvOS.
OtherFramework.xcframework should be signed and embedded in your host app.
and add "#executable_path/Frameworks" setting into your MyFramework.framework > Build settings > Runpath Search Paths.
I had this issue as well after using xcframework instead of framework. So I changed my project structure:
The MyFramework Peoject embed OtherFramework.xcframework,Then make it exported using #_exported import OtherFramework in MyFramework Project. And the MyApp just link MyFramework but can both import/use MyFramework and OtherFramework.
BTW, It seems to custom the #rpath and manual codesign the OtherFramework.
I had an issue like that as well.
First, make sure if you have MyFramework.framework file within the same directory as MyApp.
Second, when building MyFramework.framework, make sure that OtherFramework.xcframework is as well in MyFramework's project directory.
And one more thing, check target SDK versions. They should be somewhere on the same level.
I had the same issue as you, and after seeing your pbxproj I think it can be solved the same way.
Change your framework search path to recursive (either through UI or manually editing the pbxproj "$(SRCROOT)/../Frameworks" => "$(SRCROOT)/../Frameworks/**"), like so: https://github.com/msaps/XCFramework-Link-Issue/pull/1/files

Use a custom C++ library in a Swift iOS project

I have a C++ lib as a separate project that I'm trying to use in a Swift iOS app.
The approach I'm pursuing right now is:
Compile the lib into .dylib. This happens outside of Xcode.
In Xcode, add the lib to Build Phases -> Link Binary With Libraries.
Add the (C compatible) header to Bridging-Header.h.
Now, build succeeds but it crashes on simulator (something like ".dylib not found"), because the .dylib is not added to the app package.
Unfortunately I couldn't add the .dylib to "Embedded Binaries". I guess it must be somehow packaged into a framework (no idea how)?
How to make this work? Is including the sources into the project a better approach?

Creating a custom framework which uses RealmSwift

When using realm in a simple project, I used the following steps from realm's instructions:
Download the latest release of Realm and extract the zip.
Go to your Xcode project’s “General” settings. Drag RealmSwift.framework and Realm.framework from the appropriate
Swift-versioned directory for your project in ios/, osx/, tvos/ or
watchos/ directory to the “Embedded Binaries” section. Make sure Copy
items if needed is selected (except if using Realm on multiple
platforms in your project) and click Finish.
In your unit test target’s “Build Settings”, add the parent path to RealmSwift.framework in the “Framework Search Paths” section.
If using Realm in an iOS, tvOS or watchOS project, create a new “Run Script Phase” in your app’s target’s “Build Phases” and paste the
following snippet in the script text field:
bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework/strip-frameworks.sh"
I need to create a custom framework so that I can share multiple classes between apps. These classes use the Realm and RealmSwift Framework.
So I created a custom framework and added some classes. For these classes to work however, I need to have a link to the Realm framework within my custom framework.
I'm unsure how this can be done as in step 2, it states to drag the Realm and RealmSwift frameworks into the 'embedded section' of the project's general settings. But with a framework project, there is no embedded section. There is the 'Linked Frameworks and Libraries' section. I dragged the realm and realmSwift frameworks in there instead. But the custom framework will not build and it says that no module could be found for RealmSwift.
I'm unsure in a framework project if the search paths are the same as what they would be with a regular xcode project ( i.e. $(PROJECT_DIR) ) and I'm unsure what level I should expect to see the Realm and RealmSwift frameworks in my project explorer.
It's very annoying working with framework and library, if your framework is not packed into a .framework, then you might do something like this, might work:
Create a folder for your framework, add some source files
Add a .podspec with dependencies is Realm and RealmSwift, other value then you can learn from other pod
Create a normal app project
Install your framework into that app project with cocoapods with :path point to your folder, this will install realm and realmswift along with it
Now you can code your framework with realm normally without hard linking
For cocoapods and framework related stuff, check this tutorial
For framework project, what i usually do is avoid packing third party lib/framework into my .framework, i have 2 solution for this:
Let user does the job, mean you will create completion block and let them save it to realm themselve
Only include headers of the third party lib into your project and hope it will build without source files, this only works with simple third party project that have few headers, probably not Realm

Xcode 7 is using my framework after I deleted it

I'm in the process of developing a framework. My problem is that the changes I make to my framework are not being reflected in my app. My app seems to be linked to the original framework I created and isn't updating when I update the framework. Even when I delete the framework from my project, xcode still seems to think it's there.
Setup
I created a separate xcode project intending to make an app that uses the framework. I copied the root folder of my framework project into my app project root folder and I drag and dropped the .xcodeproj into my App's xcode project. I added the framework from my nested xcode project in each of the following steps:
Build Phases>Link Binary With Libraries
Build phases>Target Dependencies
General>Embedded Binaries
I tried removing the framework from each of these locations.
I tried cleaning the framework project and App project.
I tried deleting the derived data in my app project and framework project in Window>Projects
I tried using a previous version of my app project that doesn't contain the framework in any way (not in the xcode project or root folder)
The ghost of my framework continues to haunt my project! Any help?
I suppose you must have tried deleting it from build phases as well... just in case though:
Go to Build phases -> Link Binary with libraries
Select the one you want to remove, press minus button down there.
Do it for all modules: as in Debug, Release.
You can also try deleting the older framework and emptying trash to be on the safer side.
I just made a mistake.
I was using the classes I built my framework out of rather than the framework itself. I thought deleting these classes and selecting 'Remove Reference' would stop Xcode from using them. I deleted these classes completely and Xcode told me they couldn't find the class I was looking for-- indicating it was using those files rather than the framework.
Also, in my AppDelegate I used
import "ExternalClass.h"
Which I believe is for classes that are in the project. I changed this to
import <ExternalClass/ExternalClass.h>
to import the header file from the framework instead.

Building a Swift Framework with Xcode 7 (Beta 3) to use as an Embedded Binary

Ever since Embedded Binaries were introduced in iOS 8, I have been wanting to port a lot of my common code into frameworks. I decided to wait one year before doing it and this year, with Xcode 7 Beta and iOS 9, I'm starting to do that just that.
I have started a Cocoa Touch framework project in Xcode 7 and I want to compile it into a usable framework. I can get it to compile my project into a .framework, but there's a few issues; namely, the framework doesn't appear to be importable into new projects (I will describe the steps I did for that shortly). Because of that, I'm not sure if my framework has any visible symbols.
This is what I have done to create the Framework:
Created my Framework as a Cocoa Touch Framework.
Went to my target's Build Phases, went to Headers, and added all my Swift files to the "Public" section, in hopes that will export all my simbols without having to mark them as public.
I tried to archive my project as a framework. Currently, it looks like Xcode 7 Beta 3 has a bug (going to report it later today) in which it generates corrupted archive files. For this reason I couldn't get my framework from the Organizer Window. To work around this, I changed the schema of the Run action in Xcode from Debug to Release, built it and grabbed it's generated .framework from my project's build/iphoneos-release directory. This was a quick test so I didn't need the frameworks generated for emulators.
And this is what I did to try to add the framework to a new project:
Created a "Frameworks" group (for organizational purposes) and dragged the framework there, selecting "yes" when it asked me if I want to copy the file to my project's directory.
Went to my target's settings, removed my framework from "Linked Libraries" (it was added there automatically), added it to Embedded Binaries instead. This added the framework to Linked Libraries again, so I had to remove it from there twice. Leaving the framework in Linked Libraries causes a linker error (can't find the framework - no idea why but I think it's irrelevant to my problem and something I should report to Apple as well), but once you remove it from there it seems to compile fine when you add it to Embedded Binaries.
Tried to import my framework in a file. Xcode complains there is "no such module".
Unfortunately, despite the fact that embedded frameworks have been around for around a year, I can't find much writing on the topic.
So my question is: Am I creating the framework correctly, making it possible that my framework/anything else is failing due to an Xcode 7 Beta bug? Or is there a different procedure to create a framework that I want to use as an Embedded Binary? I should probably mention that I want to make this library open source, and I think distributing a plain .framework file to the people who want to use it would be neat.
I Had the same issue on Xcode 7.
I solved it by editing the build settings of the project (the one which includes the framework).
By setting the Framework Search Paths field to $(PROJECT_DIR) or to the path to the directory that contains the .framework file it should help Xcode finding the module.

Resources