Swift compilation does not use the precompile headers - swift

The problem was the swift code was getting compiled every time even with no change in the code.
Trying to figure out why precompile bridging header is not happening in my old app, whereas it happens in any new app.
I am using the latest Xcode 9.2 version.
SWIFT_PRECOMPILE_BRIDGING_HEADER - basically this doesn't seem to work even though its on in build settings.

OK precompile bridging header only precompiles the header itself. It does not precompile the swift code. The apps need both obj-c and swift and a bridging header in order for that to run. Does the old project have this?

Related

Cocoapod xcode workspace - swift and objective-c source files

First time in trying to create a cocoapod project.
I used 'pod library create name' command creating the standard template, using the swift language option.
I have added in C-files to the workspace but I don't know how to add a bridging header file so swift can import the C functions.
An attempt resulted in the compiler complaining about using a bridging header in a framework.
Is it actually possible to mix and match swift & (obj-)C files in the same cocoapod workspace/project?
TIA
Mark
Woke up next morning and found the answer.
Sorry for the traffic.
Edit the XXX-umbrella.h file.

Avoid compiling Swift files for a single target

I have a large Xcode project, with a mixed Swift and Objective C codebase. One of my targets is a QuickLook plugin, which does not use any Swift files.
When building the QuickLook target, each Swift file with references to ObjC classes (correctly bridged in the main target) report "Cannot find type in scope" errors — even though none of those Swift classes are included in the given target.
I've tried changing SWIFT_COMPILATION_MODE to singlefile for both release and debug, but it didn't help. To be absolutely sure that no Objective C classes import any Swift files in this target, I've also set up a preprocessor macro to guard the inclusion of Project-Swift.h files. I can't find a flag to completely skip Swift compilation phase when building.
Are Swift they automatically compiled no matter what I do and regardless of their target membership?
For anyone else struggling with this in the future:
When QuickLook extensions are compiled, even for the simulator, it tries to compile any other targets that might include it. I had an old build target, which was no longer maintained. At some point, the bridging header of that target had fallen behind the actual project, and for some reason, Xcode threw an error for every Swift class.
Go through all any targets that include your extension, even tests, and make sure those compile correctly, or remove those altogether.
The errors were not associated with that particular target in the logs or in the UI, which is probably an Xcode bug.

Missing Facebook SDK for Parse using Swift

This question is a lot like this one: Parse for iOS: Errors when trying to run the app except that I am using Swift in XCode Beta 4.
Essentially, when using the Parse library my app build fails, noting that I need resources from the FacebookSDK. Downloading the SDK works, but as this question on Parse's website: https://parse.com/questions/using-the-parse-ios-sdk-without-including-the-facebook-sdk notes, it adds over 1MB that I don't use.
The former question lists "Build Settings > Other Linker Flags > remove -ObjC" as a solution, but I can't figure out how to do that in this XCode version. Any help/ other solutions?
(FYI, Another solution on that page suggests creating a FBMissingSymbols.m file, but that gives me other errors because of trying to use Objective C)
A very simple solution for this is to use the CocoaPods dependency manager. If you need help setting it up, let me know. If you'd rather not, I can gladly help you get Parse set up, as I've been using it with Swift.

Building pure Swift Cocoa Touch Framework

I'm exploring Swift with Xcode-6 and so far so good although I think the new collections need a little bit of work as I've managed to break the compiler a few times.
Problem is I'm now stuck trying to create the framework package to then use in another project. The project builds without issue and all tests pass successfully. When I go to create Archive (which I assume is what is required) I receive the error:
:0: error: underlying Objective-C module 'Sample' not found
Now I assume this has something to do with the contents of my Sample.h which tells me
// In this header, you should import all the public headers of your framework using statements like #import <Sample/PublicHeader.h>
which is fine except I have only used swift enums, structs and classes for this framework so therefore no .h files exist.
Can anyone shed some light on this one as I can't find any documentation available yet?
EDIT (7/27/2018)
The information in the answer below may no longer be accurate. Your mileage may vary.
I sat down with an engineer and asked this exact question. This was their response:
Xcode 6 does not support building distributable Swift frameworks at this time and that Apple likely won't build this functionality into Xcode until its advantageous for them to do so. Right now, Frameworks are meant to be embedded in your app's project, rather than distributed. If you watch any of the session videos or see the sample projects, this is always the arrangement. Another reason is that Swift is very new and likely to change. Thus your Swift-based framework is not guaranteed to work on the platform you originally built it on.
Slight Update
The engineer mentioned that it's not impossible to make a framework for distribution, just that it's not supported.
I was able to get past the error by going to the target for the framework and on the Build Phases tab under Headers, remove the MyFramework.h file
However I was getting the "Underlying Objective-C module not found" error when I was using a framework to share code between a containing app and an app extension, both of which were pure Swift.
Assuming you are creating a truly pure Swift module, you must disable the Objective-C Compatibility Header and any generated interface headers so the compiler doesn't go off assuming it can find an Objective-C module for the framework.
Do Not remove your public framework header. You'll get a module-map warning at link time if you do.
You might find this useful: Creation of pure swift module
In short: it's possible to make static framework, but there is one issue: it doesn't work in end user' project if "ProjectName-Swift.h" header included.
But, it works fine if you use only swift.
I think it's a bug in XCode 6, or that Apple does not allow archiving the Framework from XCode while in beta.
If you compile to profile XCode generates the framework correctly. (See the Release folder created in DerivedData)

WebRTC in iPhone (gas-preprocessor issues)

I'm trying compile the lastest WebRTC version for iPhone. I not need to compile the entire solution, I only need to compile the VAD module.
To do that, I have created a Xcode project and I have tried to compile the source necessary, but I have a problem with the *.s files and its assembler.
Like in the FFMPEG library, I know that I must "translate" the assembler code to an assembler code that the gcc for iPhone understand, but I don't know how I do this manually.
I have tried to create a configure file and set in it "as=gas-preprocessor.pl" (like in FFMPEG), but does not work.
Any idea? How do I run the gas-preprocessor.pl manually?
Thanks.
I'm just finishing it on iOS and has built standalone static libraries of NS/VAD/AECM and AGC, here's some tips for you, and hope you success:
1. Source File List
for standalone VAD build, you should make sure your project has all of these files(no .s file needed), and I'm not listed the header files here, you will get some header file can not be found errors, just fixing it and things will be done.)
webrtc_vad.c
vad_core.c
vad_filterbank.c
vad_gmm.c
vad_sp.c
real_fft.c
division_operations.c
complex_bit_reverse.c
cross_correlation.c
complex_fft.c
downsample_fast.c
vector_scaling_operations.c
get_scaling_square.c
energy.c
min_max_operations.c
spl_init.c
2. Adding a macro called WEBRTC_MAC
I'm not sure why the Xcode environment does not provide this macro, but it should be defined to ensure that WEBRTC_POSIX is enabled. To define this macro, adding it to a new header file or just define it in the webrtc-header-files.
3. Following these steps to build and setup a static library of WebRTC-VAD module on iOS
notice, do not use LLVM 2.0 to compile the VAD module(use GCC or LLVM GCC). cus' it can throw you lots of errors when compiling some webrtc variable declarations.
4. Using the libwebrtc_vad.a
if you got this far, things are easy to go, just include webrtc_vad.h and using the API provided by this module. and vad is working fine in my case.
hope i helped.
try to check this link https://groups.google.com/forum/?fromgroups=#!topic/discuss-webrtc/VJg-fk2-i_0 i believe you have to set inline assembly correctly. I am also onto this so let me know if you want to switch emails or something.