Library libz.tbd not found when buiding for iOS (OpenFL 3.6.1)


#1

I am using OpenFL 3.6.1, with HaxeFlixel 4.2.1, Lime 2.9.1. I recently upgraded macOS to High Sierra, and Xcode to the latest version (9.2).

When I try to build my project, the following error appears:

Ld build/G-Switch3.build/Release-iphoneos/G-Switch3.build/Objects-normal/arm64/G-Switch3 normal arm64
    cd "/Users/vasco/Desktop/G-Switch 3/export/ios"
    export IPHONEOS_DEPLOYMENT_TARGET=5.1.1
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk -L/Users/vasco/Desktop/G-Switch\ 3/export/ios/build/Release-iphoneos -L/Users/vasco/Desktop/G-Switch\ 3/export/ios/G-Switch3/lib/arm64 -F/Users/vasco/Desktop/G-Switch\ 3/export/ios/build/Release-iphoneos -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/System/Library/Frameworks -F/usr/lib/haxe/lib/extension-supersonic/git/frameworks -F/usr/lib/haxe/lib/extension-supersonic/git/frameworks/SUUnityAdsAdapter -filelist /Users/vasco/Desktop/G-Switch\ 3/export/ios/build/G-Switch3.build/Release-iphoneos/G-Switch3.build/Objects-normal/arm64/G-Switch3.LinkFileList -miphoneos-version-min=5.1.1 -dead_strip -lstd -lregexp -llime-legacy -lganalytics -liap -lSupersonicExtension -lsqlite3 -lGoogleAnalyticsServices -llibz.tbd -llibz.1.2.5.tbd -lApplicationMain -stdlib=libc++ -force_load /usr/lib/haxe/lib/admob/git/ndll/iPhone/libGoogleAdMobAds.a -ObjC -fobjc-arc -force_load /Users/vasco/Desktop/G-Switch\ 3/export/ios/G-Switch3/lib/arm64/libGoogleAnalyticsServices.a -framework UIKit -framework OpenAL -framework OpenGLES -framework QuartzCore -framework CoreAudio -framework CoreGraphics -framework AudioToolbox -framework AVFoundation -framework Foundation -framework CoreMotion -framework MediaPlayer -framework CFNetwork -framework CoreData -framework SystemConfiguration -framework StoreKit -framework Supersonic -framework AdSupport -framework AudioToolbox -framework Foundation -framework AVFoundation -framework CoreGraphics -framework CoreMedia -framework CoreVideo -framework CoreTelephony -framework EventKit -framework EventKitUI -framework MediaPlayer -framework MessageUI -framework Social -framework StoreKit -framework SystemConfiguration -framework Webkit -framework CoreMotion -framework UIKit -framework QuartzCore -framework CFNetwork -framework MobileCoreServices -framework CoreLocation -framework Security -framework SUAdColonyAdapter -framework SUAdMobAdapter -framework SUApplovinAdapter -framework SUChartboostAdapter -framework SUUnityAdsAdapter -Xlinker -dependency_info -Xlinker /Users/vasco/Desktop/G-Switch\ 3/export/ios/build/G-Switch3.build/Release-iphoneos/G-Switch3.build/Objects-normal/arm64/G-Switch3_dependency_info.dat -o /Users/vasco/Desktop/G-Switch\ 3/export/ios/build/G-Switch3.build/Release-iphoneos/G-Switch3.build/Objects-normal/arm64/G-Switch3
ld: library not found for -llibz.tbd
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **


The following build commands failed:
	Ld build/G-Switch3.build/Release-iphoneos/G-Switch3.build/Objects-normal/armv7/G-Switch3 normal armv7
	Ld build/G-Switch3.build/Release-iphoneos/G-Switch3.build/Objects-normal/arm64/G-Switch3 normal arm64
(2 failures)

I’m having difficulty finding relevant information on this error, any ideas? Thanks in advance.


#2

We used the Zlib.cpp from HXCPP on our legacy code, but newer HXCPP versions may affect how this works. It looks like it is looking for a system library.

Perhaps there’s a framework you can manually add in Xcode that might add zlib? (libz)

https://forum.unity.com/threads/xcode-api-and-tbd-files.375364/


#3

Well, I’m using an older hxcpp version (3.4.64), which has worked for me before, and has the Zlib.cpp file.

I’m not sure how I would add a framework, doesn’t the lime build need to complete in order to have a working Xcode project from where I can add frameworks? Sorry if this is basic, I’m not that experienced working with Xcode/macOS.


#4

I think this would be in Xcode, when building the application. Pretend that lime.a is already good, perhaps there is a way to update your application Xcode project to include the framework. Otherwise, it may be necessary to rebuild Lime using a newer iOS SDK?


#5

I tried adding libz.tbd to the frameworks in Xcode (which it finds by searching in “Link Binary With Libraries”), but the exact same error appears when I try to build. Is there a way to know where it’s looking for the file so I could maybe copy it there?

Regarding rebuilding Lime with a newer SDK, I’m not sure how I would do that, is the SDK I have automatically used when rebuilding Lime?


#6

Yes, it should use your own version of code, and the newest available SDK


#7

OK, I rebuilt Lime using these instructions: https://github.com/openfl/lime#building-from-source

When trying to build the game there was an error due to incompatible Lime and HaxeFlixel versions, although if I understood correctly the dev version should be using the version of Lime I was using? I “fixed” this by just commenting the line in FlxDefines.hx that was checking the Lime version, and was able to complete the build.

Then when I compile and try to run in the simulator, it always fails to run the game somehow (either “unable to attach to pid …”, “connection timed out”, “DTServiceHubClient failed to bless service hub for simulator …”, or it installs and tries to open the app, but doesn’t go beyond a black screen).

When it tries to run the app, the following appears in the Xcode output window:

Primitive not found : lime_legacy_byte_array_init__4
Error Null Function Pointer

So then I tried recompiling Lime with the -Dlegacy option, i.e. lime rebuild ios -Dlegacy, but the result seems the same (lime_legacy_byte_array_init__4 is still not found after building and running the game).


#8

Lime hasn’t had a “legacy” code path for years, but there should still be a “legacy” branch on our GIT repository, which you could try with OpenFL 3.6.1, then yes, try lime rebuild ios -Dlegacy


#9

Sorry, but I’m not sure if I’m doing this right.

I tried the command git checkout origin/legacy, which showed the following:

warning: unable to rmdir project/lib/axtls: Directory not empty
warning: unable to rmdir project/lib/efsw: Directory not empty
warning: unable to rmdir project/lib/mbedtls: Directory not empty
warning: unable to rmdir project/lib/tinyfiledialogs: Directory not empty
warning: unable to rmdir project/lib/vpx: Directory not empty
warning: unable to rmdir project/lib/webm: Directory not empty
M	project/lib/cairo
M	project/lib/curl
M	project/lib/freetype
M	project/lib/harfbuzz
M	project/lib/openal
M	project/lib/sdl
Note: checking out 'origin/legacy'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at b19a70e8... Update System.mm

But then when I try to rebuild lime it shows: Error: Could not find include file "lib/nfd/files.xml" :confused:


#10

Try git submodule init && git submodule update after change the branch, we use very different library versions now


#11

I tried it, rebuilt lime (lime rebuild ios -Dlegacy) and now when I try to build the project (lime build ios) the following error appears:

Called from ? line 1
Called from CommandLineTools.hx line 1400
Called from CommandLineTools.hx line 25
Called from a C function
Called from CommandLineTools.hx line 126
Called from CommandLineTools.hx line 619
Called from lime/project/PlatformTarget.hx line 70
Called from lime/tools/platforms/IOSPlatform.hx line 369
Called from lime/project/HXProject.hx line 244
Called from lime/project/ConfigData.hx line 35
Called from lime/tools/helpers/ObjectHelper.hx line 127
Called from lime/tools/helpers/ObjectHelper.hx line 127
Called from lime/tools/helpers/ObjectHelper.hx line 127
Called from lime/tools/helpers/ObjectHelper.hx line 76
Called from /usr/local/lib/haxe/std/neko/_std/Array.hx line 118
Uncaught exception - Invalid operation (+)

#12

This might be relevant, depending on your Haxe version:

(You can try git cherry-pick 87793d8b4c2db71979b634024b768cfab72d53bc, then lime rebuild tools, then try again)


#13

Still doesn’t work, now when I try to build the game the following appears:

/Applications/Xcode.app/Contents/Developer/usr/bin/make
Haxe device build: Release-iphoneos-v7
haxe Build.hxml -D HXCPP_ARMV7 -cpp build/Release-iphoneos-v7 
cd build/Release-iphoneos-v7; export HXCPP_NO_COLOR=1; haxelib run hxcpp Build.xml -Dios -Diphone -DHXCPP_ARMV7 -DHXCPP_CPP11  -DHXCPP_CLANG -DOBJC_ARC `cat Options.txt | while read LINE; do printf " -D$LINE"; done`
Error: This is the first time you are runing haxelib. Please run `haxelib setup` first
make: *** [build-haxe-armv7] Error 1
Command /Applications/Xcode.app/Contents/Developer/usr/bin/make failed with exit code 2

I tried running haxelib setup as the error suggests, but nothing changes.


#14

Does haxelib run hxcpp show the same message?


#15

No, it just shows:

hxcpp (Haxe C++ Runtime Support) (3.4.64)

Usage:
 haxelib run hxcpp file.xml [options]
   Build project from "file.xml".  options:
    -Dvalue -- Specify a define to use when processing other commands
    -verbose -- Print additional information (when available)
 haxelib run hxcpp file.cppia
   Run cppia script using default Cppia host
 haxelib run hxcpp file.js
    Run emscripten compiled scipt "file.js"
 haxelib run hxcpp cache [command] [project]
   Perform command on cache, either on specific project or all. commands:
    clear -- remove all files from cache
    days #days -- remove files older than "days"
    resize #megabytes -- Only keep #megabytes MB
    list -- list cache usage
    details -- list cache usage, per file

Although I’m not sure if you meant that I should build lime this way with include.xml or haxelib.xml?


#16

Oh, first time running Haxelib, not HXCPP. Sorry, my mistake. Does haxelib work? Maybe run sudo haxelib setup instead of haxelib setup?


#17

Ah, I should have remembered to try with sudo. It worked! The game finally runs in the simulator. Thank you, I really appreciate the help! I’ll finally be able to publish my game on the app store :smile: