iOS Build Environment Help Center

About Unity Ads 4.4.0 requiring Swift

append delete Pierre-Marie Baty

Hello all

A user notified me that Unity is migrating their Ads SDK to Swift :

https://docs.unity.com/ads/InstallingTheiOSSDK.html

Starting in SDK version 4.4.0, Unity Ads has been optimized by using the Swift programming language.

That was unexpected...

At the moment, the builder doesn't support cross-building Swift code for ARM/iOS on Windows. Some preliminary work was done for that some time ago, but that was stopped considering that it affected only CocoaPods plugins of which pre-compiled versions were always available, providing a convenient (and recommended) workaround.

The thing to do at the moment, is to use a version of the Unity Ads SDK prior to 4.4, and not upgrade to 4.4+ before Swift support is added to the builder.

I hope it won't be too much of an inconvenience.

:: @Pierre-Marie Baty added on 23 Nov ’22 · 10:47

To make it 100% clear this is just about *Unity Ads*. The Unity Engine itself contains no Swift files and the builder toolchain remains totally able to build Xcode projects generated by it.

Reply RSS

Replies

append delete #1. billygunn

Hey Pierre,

I am also running into this issue at the moment and I am using an older version of Unity Ads. Are you trying to find a work around?

append delete #2. Pierre-Marie Baty

Yes I am. It is #1 on my todo list.

append delete #3. Raffles

Hi Pierre,

I'm using the newest version of your builder, 3.57, which now has Swift support right? However I am unable to build with UnityAds 4.4.2 and Unity 2021.

I receive this message:
https://pmbaty.com/paste/?103d25f2610037e5#HQmG4zjj1BrPcRuueLRJmpEArSJEYigDycyLRhVipFCG

Is this to be expected for now, or are there any manual steps that need to be done in order to build successfully?

Cheers.

append delete #4. Pierre-Marie Baty

Interesting. Normally that library should have been created in your SDK. You should have a file called "libSwiftCompatibility56.dylib" in your SDK directory, and it is created by the 2nd step of the migration assistant. The code that creates it is the following:

% Migration assistant (step 2, PC).cmd

		echo void _swift_FORCE_LOAD_$_swiftCompatibility56^(void^){}> "%TEMP%\swiftCompatibility56stub.c"
		set LIPO_FLAGS=
		for %%a in (arm64 arm64e) do (
			"%*\Toolchain\clang.exe" -target %%a-apple-ios7.0 -o "%TEMP%\swiftCompatibility56stub.%%a.o" -c "%TEMP%\swiftCompatibility56stub.c"
			"%*\Toolchain\ar.exe" qs "%TEMP%\libswiftCompatibility56stub.%%a.a" "%TEMP%\swiftCompatibility56stub.%%a.o" > nul 2>&1
			set LIPO_FLAGS=!LIPO_FLAGS! -arch %%a "%TEMP%\libswiftCompatibility56stub.%%a.a"
		)
		"%*\Toolchain\lipo.exe" -create -output "%*\SDK\libswiftCompatibility56.a" !LIPO_FLAGS!
		del /f /q "%TEMP%\libswiftCompatibility56stub.*" > nul 2>&1
%

This means, I bet, that you migrated your SDK using an outdated assistant. Am I right ?

append delete #5. Raffles

Indeed you are correct, I upgraded to the current version, but without updating the SDK/running the assistant again. I didn't factor in the need for updated dependencies in the SDK as well as the updated core program, I'll recreate it and hopefully that works ;)

Edit - it worked, actually the first time I was able to compile with Unity 2021.

PS - lol.

echo "Your Xcode version must be ages old !?"
echo "Please download and install a RECENT version of Xcode that has an iOS"

Cheers.

:: @Raffles added on 30 May ’23 · 20:42

Thanks for the quick reply btw, and it's great that the builder now supports Swift, as it seems it's becoming more essential to.

Cheers.

append delete #6. Pierre-Marie Baty

Glad to hear it worked. Actually Swift support still has a limitation, but you’re not affected : mixed language targets (i.e. mixing Swift and Objective-C code in the same framework) are not yet supported. This is what I’m working on at the moment.

append delete #7. Raffles

OK sure, and are there some common libraries that mix Swift and Objective-C, that I need to be aware of to steer clear of?

append delete #8. Pierre-Marie Baty

The Facebook SDK is the prime example I can think of. But there’s still the possibility to build a project that uses it by linking against its precompiled frameworks.

Reply

(Leave this as-is, it’s a trap!)

There is no need to “register”, just enter the same name + password of your choice every time.

Pro tip: Use markup to add links, quotes and more.

Moderators: Pierre-Marie Baty