Realm manual install issues on iOS - ios

I followed the instructions on the doc page to get the manual install working. And it is working, however, when I tried to push to my repo, the repo rejected my push. I checked why this might be, and I found that there was a large file, 46 MB or so. This file is located at ios/Realm.framework/Realm
What is this file? And why is it 45,6 MB?
Why is the OSX Realm.framework only 2,8 MB while the iOS Realm.framework is 45 MB + ?

From the FAQ section of Realm docs:
How big is the Realm library?
Once your app is built for release, Realm should only add around 1MB to its size. The releases we distribute are significantly larger (~37MB for iOS & ~2.4MB for OSX) because they include support for more architectures (ARM, ARM64, x86 for the simulator) and some debug symbols, which will all be stripped by Xcode automatically when you build your app.
If you'd like to avoid bundling binary dependencies in your git repo, you should build Realm and other dependencies from source either manually (drag Realm.xcodeproj in your project) or with a tool like CocoaPods or Carthage, all of which are covered in the Installation section of Realm's docs.

Related

How to manually download GitHub iOS code and have it work in XCode 11.7?

INTRO
Greetings!
I have recently been granted access to a proprietary (that is, private) GitHub repository for iOS development. I'm on a Mac (OS 10.15.6 Catalina, the latest MacOS as of this writing) with the latest non-beta XCode version installed today (11.7) as well as the latest iOS emulator as of this writing (iOS 13.7). I am new at using Macs, at XCode, and working with this project, and the author of this GitHub code hasn't been available to help me work with his code. (I am well familiar with downloading files from GitHub and the Internet in general.)
I know this GitHub repo has XCode inside because there's an XCode file, Pods.xcodeproj. There are also many other files, including .xcconfig files.
It may be a hardware problem. This Mac's technical specs were minimalistic: It has less than 4 gig of physical RAM and a recently-obtained hard disk space upgrade to put it around 70 gig of total space, or enough to work with Android Studio and XCode. (A sample project failed to run in the simulator due to having too little RAM.)
Thus, what's wrong and how should it be fixed?
Thankee!
ERROR MESSAGE
Build target hornet of project hornet with configuration Release
error: /Users/Liam/Desktop/HORNET/9-1-20/ios/Pods/Target Support Files/Pods-hornet/Pods-hornet.release.xcconfig: unable to open file (in target "hornet" in project "hornet") (in target 'hornet' from project 'hornet')
error: /Users/Liam/Desktop/HORNET/9-1-20/ios/Pods/Target Support Files/Pods-hornet/Pods-hornet.release.xcconfig: unable to open file (in target "hornet" in project "hornet") (in target 'hornet' from project 'hornet')
error: /Users/Liam/Desktop/HORNET/9-1-20/ios/Pods/Target Support Files/Pods-hornet/Pods-hornet.release.xcconfig: unable to open file (in target "hornet" in project "hornet") (in target 'hornet' from project 'hornet')
error: /Users/Liam/Desktop/HORNET/9-1-20/ios/Pods/Target Support Files/Pods-hornet/Pods-hornet.release.xcconfig: unable to open file (in target "hornet" in project "hornet") (in target 'hornet' from project 'hornet')
The presence of the Pods path suggests the project is using CocoaPods. If so,
If you haven’t already, install CocoaPods.
Once that’s installed on your computer, go to the project root folder in Terminal and run pod install to download the pods.
In Xcode, open the .xcworkspace, not the .xcodeproj.
But 4gb of RAM may simply be too modest to use Xcode at all. If you can’t create and run a simple test project in Xcode, you certainly won’t be able to open a bigger project. My recollection was a 8gb minimum, but even that will struggle. 16gb is pretty decent and if you can afford more, so much the better.

Module compiled with Swift 4.2.1 cannot be imported by the Swift 5.0 compiler

I am trying to implement integration of third party app into project as per instruciton https://github.com/Paytm-Payments/Paytm_iOS_App_Kit/tree/master/Swift/BitCodeDisabled/PaytmNativeSDK
I see the following error in build
Module compiled with Swift 4.2.1 cannot be imported by the Swift 5.0
compiler
I have tried toolchains https://medium.com/xcblog/switching-swift-versions-inside-xcode-using-toolchains-755b28831c43
The error changes to Reason: Incompatible library version: PaytmNativeSDK requires version 1.0.0 or later, but libswiftCore.dylib provides version 0.0.0
How do i setup XCode or the Library to make it work . There is no chance of the vendor updating the library for Swift 5.0 and make it available on POD.
For Carthage users: After upgrading to Xcode 10.2, I ran into this same issue with a framework that I had been importing using Carthage.
I resolved it by rebuilding the framework:
carthage update --no-use-binaries --platform iOS
The correct solution is download Xcode 10.1, and wait for Apple patch the bug fix.
Don't waste time on fix third-party bug.
The problem of my project is we are using Alamofire which is failed to update by Carthage.
The provider of this library should rebuild it with BUILD_LIBRARY_FOR_DISTRIBUTION = YES; (available in Xcode 11.3 in Build Settings -> Build Options). Already asked to do it in the corresponding GitHub issue. After that PaytmNativeSDK will be compatible with every next Swift version.
It looks like the issue has been fixed in 804152caae76245d96548eb74ea87a6150239407.
I wanted to use Swift 4.2 (which Xcode 10.2 should still support, I've set it in Swift Language Version), but it still gave me an error about the Swift 5.0 compiler. So after trying to clear everything like build folder, derived data and stuff, I came to the conclusion that it does not work on Xcode 10.2.
I reverted back to Xcode 10.1 which you can download here. This works. So until Apple fixes this bug I am forced to stay on Xcode 10.1.
The developers of the framework need to provide an update, which is built in Xcode 10.2.
Explanation for framework developers:
Even if you created the framework in Xcode 10.2 or with the default version used by CI, your users may still encounter such an error. You should make sure that Xcode 10.2 is your default command line tool. You can check it in terminal with the command xcodebuild -version.
Default version can be adjusted in Xcode -> Preferences -> Locations -> Command Line Tools.
This will happen if you have external libraries in your project thats still built using 4.2 compiler, whereas the new Xcode tries building your project in 5.0 compiler.
In my case, I had few libraries imported using Carthage. Luckily the libraries that I have used have released an updates in the past few days making it compatible with Swift 5.0 compilers. If those external libraries haven't updated it to support Swift 5.0 you may be out of luck for now.
On the way you might still face few issues and here are some best practices to avoid further issues.
Remove the cartfile.resolved and Carthage folder completely
Ensure you remove any copy of the libraries added to your project earlier.
Remove the embedded libraries and Linked frameworks and libraries from your Targets> Yourapp > General .
Product > Clean build folder
Update the Cart file and fetch the new sources using the Carthage update command
Now import the libraries back to your project.
Hopefully it works.
My problem with Carthage was related to the xcode phase that copys binaries in
"carthage copy-frameworks" phase.
I've a slightly different solution to the one commented in https://stackoverflow.com/a/55362536/721929, because that solution also updates dependencies versions in some cases.
So, I just executed "carthage build". I also include a cache clean for Carthage, to fix possible errors in subtasks (in my case, failing in git clone with "exit code 1")
rm -rf ~/Library/Caches/org.carthage.CarthageKit
carthage build --no-use-binaries --platform iOS --verbose
Just remove all the *.framework folders, fetch and generate then just Import the new framework folders to your project.
That's what helped me.
For Instance:

Is it possible to distribute binary ios framework using carthage

Please bear with me because I spent considerable amount of time on this. I am also relatively a beginner with swift and iOS.
What I did
- built a framework using cocoa touch
- clean, build and it succeeds without a problem.
- made the scheme shared
- did carthage build --no-skip-current
- did carthage archive
- copied only the zip file to a fresh new directory and uploaded with release in git.
- In a different project tried to pull the framework using carthage
and I get the error Dependency "xxx-ios" has no shared framework schemes then I copied the scheme directly and pushed it in the git along the zip. nothing. Tried without the zip together with the scheme. nothing.
Then I created a fresh framework and I did carthage build --no-skip-current and I uploaded the whole thing in the project folder to git. That pulls properly with carthage. Then I removed some part of that folder so that the scheme inside .xcodeproj and the carthage build folder remain, then I get a different error. At this point it got me thinking if carthage does support binary framework distribution.
In my company, they want it so that I don't expose the code - so I am trying to distribute built binary of the framework.
I would really appreciate any help or guides of what different things I could try to single out the problem. Thanks.
Edit
someone had almost exactly the same issue as mine in their issues here but a couple of conversations later it is closed without a solution.
It sounds like you're using a github dependency in your Cartfile and attaching a binary of your framework to the GitHub Release. But you don't have any code in the repository, so Carthage is complaining because it can't actually build it.
That's as designed—Carthage doesn't support distributing binary-only frameworks that way. Binaries attached to GitHub Releases are only meant as a way to speed up builds.
However, Carthage does have a mechanism for binary-only dependencies: binary dependencies.

In iOS, should I be committing files with a `.a` file extension to my mercurial repository?

I am fairly new to iOS development. I am using the iOS Admob SDK. When I tried to commit my changes to Mercurial I received the following message:
<working_dir>/GoogleMobileAdsSdkiOS-6.12.0/libGoogleAdMobAds.a: up to 39 MB of RAM may be required to manage this file
(use 'hg revert <working_dir>/GoogleMobileAdsSdkiOS-6.12.0/libGoogleAdMobAds.a' to cancel the pending addition)
Should I be committing files ending in .a to the repository or should I include it to .hgignore?
IMO you should use Cocoapods and do not commit vendor libraries in your repository instead just push Podfile (if needed Podfile.lock) into your repo.
Read more about Cocoapods here -
http://cocoapods.org/
For AdMob SDK here is how you can install it using Cocoapod - https://developers.google.com/mobile-ads-sdk/docs/admob/ios/quick-start#streamlined_using_cocoapods

How to separate the SDK from the Xcode and SDK bundle downloaded from Apple developer portal

I downloaded Xcode 4 and iOS SDK 4.3 bundle from https://developer.apple.com/downloads/index.action#. It's a dmg file and I am wondering if there is a way to find out where the iOS SDK is in the dmg file and copy it down to local disk? Anyone has tried that before?
Yes, I have tried that when I was trying to build an unofficial iOS toolchain on Linux (with success, by the way).
You have to mount the DMG - the best option for that is double-clicking the DMG in Finder or typing
hdiutil attach filename.dmg
to a command line.
When you have mounted the file, you'll see a bunch of directories - I don't remember to the exact path, but there should be a directory named Packages. In there, you'll find a dozen of files with the extension .pkg. Actually, these are XAR archives which contain GZip archives, which in turn contain cpio archives.
After having extracted the ones you feel logical (look for iPhoneOS4.3.sdk.pkg and the compilers [clang, GCC] as well), you will have the essential components of the iOS SDK, namely: the toolchain (containing the clang and GCC compilers and the necessary tools, including an assembler, linker and the GNU debugger, GDB) and the headers, frameworks and libraries (for example, UIKit, Foundation, libSystem, libsqlite3).
From now on, you shall be able to write simple makefiles and compile iOS apps without the need for using Xcode.

Resources