How to remove some of the Swift libraries copied by Xcode? - swift

In Xcode 10, the "Copy Swift standard libraries" script is done last — after any custom build phases that may be added to the target. Hence it is not possible to create a custom build script to specifically remove Swift standard dylib files added by Xcode.
The question is, how to remove some of these standard libraries that are erroneously added by Xcode?
The reason behind it is that when Xcode 10 builds a Swift 4.2 macOS app that has a Photo Editing extension, it adds libswiftMapKit.dylib into the application bundle — even when the application does not have Maps functionality or import MapKit. This caused an App Review rejection.

To remove a Swift Standard Library, add a Post-Actions in the scheme. Most likely this would be an Archive post-action since archiving is typical prior to a release (upload to App Store or to re-sign using a Developer ID credential).
In Xcode 10 Click Edit Scheme.
In the scheme editing, expand the Archive section.
Click on Post-Actions
Enter the following bash script fragment (along with any other post-actions that you may already have)
# This variable points to the `Frameworks` folder of the final application.
full_frameworks_path="${ARCHIVE_PRODUCTS_PATH}/Applications/${FRAMEWORKS_FOLDER_PATH}"
# Specify the libraries to remove, the example below removes Swift's MapKit wrapper.
rm -f "${full_frameworks_path}/libswiftMapKit.dylib
However note that this does not solve the underlying problem of the Photos App Extension actually links to libswiftMapKit.dylib — a dependency added by Xcode 10.0 regardless whether it really uses MapKit or not.

Related

How Do I ' #import "Firebase.h ' in Xcode?

I'm manually adding some Firebase SDK's in my iOS app and have been following Firebase's provided readme to the letter. As it directs, I've already dragged all the SDKs I need into my project but there's one step I'm not understanding. It reads:
8. Drag the Firebase.h header in this directory into your project. This will
allow you to #import "Firebase.h" and start using any Firebase SDKs that you
have.
I've added the Firebase.h header file into my project but I don't know how/where to add #import "Firebase.h". Since I haven't done that, building my app produces the error: No such module 'Firebase' when I try to import Firebase in my view controllers.
For reference, I had been using cocoapods for Firebase up until the recent iOS 13.3.1 update that broke my ability to test my app on my physical device, so I'm attempting to manually add the static Firebase SDK's in the hopes that I would then be able to continue debugging on my iPhone 6s. I'm 75% of the way through my app's development and have already fully integrated Firebase so this little switch-over from pods to static SDKs is definitely annoying, but it has to be done. I removed all the Firebase pods I was using in my Podfile and am just stuck at the step bolded above... hopefully it's a simple thing and then everything will work again as I already have it completely integrated throughout my app.
If you'd like a deeper background, here's a Stack Overflow question that describes the exact initial problem I was having with debugging on my physical device with the 13.3.1 iOS update.
And here's where I asked for alternative ways to incorporate Firebase that avoids pods (in case that fixes the issue). This is where I learned about Firebase's zip binary distribution. I downloaded the zip file with the Firebase SDKs, chose the ones I need, and have been following the readme to add them to my project.
To add Firebase module support, you also need to do the subsequent instruction in the zip distribution README after dragging Firebase.h:
9. If you're using Swift, or you want to use modules, drag module.modulemap into
your project and update your User Header Search Paths to contain the
directory that contains your module map.

Do not copy swift libraries with Xcode 8?

How to not automatically embed Swift dynamic libraries in Xcode 8?
I've tried setting ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to "No" (defaults to "No" anyway) yet it still copies Swift dynamic libraries into the app bundle.
I'm creating a helper application to be embedded in the main application and the latter already has Swift libraries which the former can link to.
Swift may still be copied even for ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES set to NO. You can check if there is some Swift file in your project or any of your dependencies and remove those.

Invalid WatchKit Support - The bundle contains an invalid implementation of WatchKit

I am trying to upload my apple watch app to iTunes, every time i am uploading my binary i am getting following mail from apple team.I have done with my following checklist.
Created separate App id and profile for watchapp and extension.
I have the correct set of images for apple watch as well as iOS app.
my app was initially built with Xcode 6.2 SDK and now i am submitting with 6.3 SDK.
Don't know where i am doing wrong. can anyone with experience help me out here.
We have discovered one or more issues with your recent delivery for
"XXXXX". To process your delivery, the following issues must be
corrected:
Invalid WatchKit Support - The bundle contains an invalid
implementation of WatchKit. The app may have been built or signed with
non-compliant or pre-release tools. Visit developer.apple.com for more
information.
Once these issues have been corrected, you can then redeliver the
corrected binary.
The problem for me was that the "IOS Deployment Target" in Build Settings for my WatchKit App and my WatchKit Extension were not both the same. My extension was set to 8.3 and my WatchKit App was set to 8.2. Once I set them both to 8.2 the error went away and the WatchKit App installed just fine.
While uploading apple watch app, it need to have apple watch extension into embedded binary of iOS app. But if you are habbitat to delete derived data then xcode6 will delete that target. and when you submit it to apple it will only get ios app not apple watch app.
Adding Embedded Binaries fails in Xcode
Xcode won't link framework form separate project
App crashes on device because of missing framework, works in simulator
Overview
After deleting the "DerivedData" folder (or performing a "Product > Clean") in xcode6, I cannot add CocoaTouch frameworks from another project to the "Embedded Binary" section (under General tab).
Or, Xcode hits a linker error because it cannot find a framework that if previously could.
Other symptoms
Clicking on the + under "Embedded Binaries" shows the Framework selector but selecting a framework in different project in the workspace does nothing.
I've been tearing my hair out over this one too. Here's what I've tried:
I've generated new provisioning profiles for the app, the watchkit extension, and the watchkit app, using unique bundle identifiers for each (com.example.app, com.example.app.watchkitextension & com.example.app.watchkitapp) and a distribution certificate. Downloaded, installed, and set each target to its own provisioning profile in Build Settings > Provisioning. Tried explicitly setting signing authority AND leaving it on automatic.
I've confirmed that the xcarchive contains a WatchKitSupport directory and WK file when I Show Package Contents of the archive
I've ensured that WatchKit Extension, WatchKit app, and IOS app all have matching build and version numbers
I ran Edit > Convert > To Latest Swift Syntax... on the app, extension, and watchkit targets (no source changes were required in my case..)
I've compiled from scratch, cleaned, built, & archived, rinsed and repeated, restarted system and looped again.
In my case, none of those worked. Hope one of them helps you. And if any other kind soul out there has fixed this without going bald, share the hair, man, share the hair.

iPhone ARC & Facebook SDK

I'm getting all kinds of build errors with Facebook's SDK because my app uses ARC. I try to remove the Facebook files from the compiler to avoid this, but I get an Apple Mach-O error when I remove the Facebook.m file. If I put that back in the compile sources, I get the ARC errors.
Anyone run into this?
Do you exclude them from arc with Compiler flag
-fno-objc-arc
?
You can see a Answer here
And this is why distributing a shared library by copy and pasting files is bad. A library should be distributed as it's own Xcode projects with a static library target, so that the build setting requirements of your projects and the libraries you use can not screw up one or the other.
File a bug for the Facebook SDK here: https://github.com/facebook/facebook-ios-sdk/issues
And in the mean time add the -fno-objc-arc flag to the implementation files in the Facebook SDK. You can do this by;
Select your application target
Go to the Build Phases tab
Add for each file under the Compile Sources section.
The new SDK does not explicitly support ARC out of the box, but there is a shell scrip to build a static library that can be used within your ARC project. Just navigate to your local git repo and run
% ~/facebook-ios-sdk/scripts/build_facebook_ios_sdk_static_lib.sh
This will create the static library under the /lib/facebook-ios-sdk folder (e.g. ~/facebook-ios-sdk/lib/facebook-ios-sdk). You may then drag the facebook-ios-sdk folder into the app Xcode project to include the iOS Facebook SDK static library.
there are actually very few changes needed to make the Facebook iOS sdk compatible with ARC. I have made the changes in my code , but , I do not know who to send it back to the community, any pointers ?
here is a post I made to explain how to use it with ARC the simple way on Xcode 4.2:
http://nabtech.wordpress.com/2012/02/02/facebook-ios-sdk-and-arc/

Building the Objective-C XML-RPC Framework for iOS

I'm fairly new to the iOS SDK and Xcode and I stumbled across this XML-RPC framework https://github.com/eczarny/xmlrpc that I'd really like to use in one of my projects. I downloaded the sources, the initial target was set to Mac OS, so I changed that to iOS 4.3 but got the following dependency error:
target specifies product type 'com.apple.product-type.framework', but there's no such product type for the 'iphoneos' platform
So I removed all the targets and added a new one from scratch using the Cocoa Touch Static Library, and it seems like it's been built just fine. Now my question is whether this is the correct way to build that library for iOS development, and where do I take it from here? I can't find the .framework directory anywhere (the install dir was set to "#executable_path/../Frameworks") so I can't embed it in my iOS project. How exactly does this go? Thanks!
Thanks for your help and sorry if this is too "newbish". Cheers!
If you're using Xcode 4.x open the Organizer, select the Projects tab and then down the left hand side you should see an entry relating to the XML-RPC project. Select that and under the Derived Data heading you'll see a path which if you follow using finder should lead you to the folder containing the static library you've built.