Skip to main content
This page matches SDK 2.0.0. Auth: Auth & License. Enums: Parameter enums.

Integration

Engine creation returns nil

  • Confirm licenseToken or appId + appKey is set. Token wins if both are present.
  • Bind the app Bundle ID in the dashboard.
  • Online auth needs network to /facebetter/v2/auth.
  • Enable logs before createEngineWithConfig: and watch events 1 (license fail) and 101 (init fail).
  • CocoaPods: pod 'Facebetter', '2.0.0'. Open the .xcworkspace, not the .xcodeproj.

Missing headers or classes

  • Import #import <Facebetter/FBBeautyEffectEngine.h>.
  • For a manual .framework, set Embed & Sign.
  • Clean Build Folder and rebuild.
  • If CocoaPods scripts fail on Xcode 15+, set ENABLE_USER_SCRIPT_SANDBOXING to No.
  • Architecture must be arm64.
  • Deployment target iOS 12.0+.
  • Confirm Facebetter.framework is in Embed Frameworks.

Auth

licenseToken vs appId / appKey

If licenseToken is non-empty, the SDK verifies that token / {token} JSON / .lic locally and does not send appId / appKey. Otherwise it uses online auth. Details: Auth & License.

Event 1 or 101

License or init failed. Check Bundle ID, plan, token expiry, and logs. Creation returning a non-nil object is not enough — listen to onEngineEvent.

Beauty

Effect is too weak or too strong

  • Skin / makeup / filter: [0.0, 1.0].
  • Face reshape: [-1.0, 1.0] via setReshape:intensity: (0 is off).
  • Body reshape: [0.0, 1.0] via setBodyReshape:intensity:. Register resource_body.fbd first.
  • Intensity 0 disables that effect.
  • Skin-only: setBeautySkinOnly:.

Makeup / reshape enum values

Do not copy tables into app code comments — use Parameter enums. Objective-C names look like FBReshape_FaceThin, FBLipstickColor_Rouge.

Filters, stickers, virtual background

Filter or sticker does nothing

Pass the .fbd path or bytes:
Textures are created on the next processImage: (GL thread). Empty path / nil data returns FBErrorCode_InvalidArgument. Missing file returns FBErrorCode_IO.

Virtual background

Chroma key is the mask; fill is still blur or image:

Processing

processImage: returns nil

  • Engine is nil or init failed (-2 / event 101).
  • Invalid frame (zero size, unsupported format).
  • externalContext = YES but the current thread has no GL context.
  • Treat as process failure (FBErrorCode_Process).

Frame type

Set imageFrame.type to FBFrameTypeImage (0) or FBFrameTypeVideo (1). Do not pass a process-mode argument.

Format conversion

Use convert: and the frame accessors:
YUV: dataY / dataU / dataV / dataUV and the matching stride*.

UIImage

Camera preview

  1. Read CVPixelBuffer from AVCaptureVideoDataOutput.
  2. Build FBImageFrame with createWithNV12:... or createWithBGRA:....
  3. Set type = FBFrameTypeVideo, optional setMirror:@"horizontal".
  4. processImage: then display [output data] or [output texture].

Performance and memory

  • Use FBFrameTypeVideo for live; lower resolution if getStats.avgProcessTimeMs is high.
  • One engine, serial queue; do not process on the main thread.
  • Release frames with ARC (frame = nil). Reuse capture buffers.
  • Avoid setFilter: / setSticker: every frame.

Logging

Return codes: 0 success, -1 invalid argument, -2 not initialized. Full list: Error Handling.

Version

  • iOS 12.0+, arm64.
  • CocoaPods: pod 'Facebetter', '2.0.0'.
  • After upgrade: pod install, Clean Build Folder, re-test auth and processImage:.

Threading

  • Default engine: serial queue for all processImage: and setters that touch GL resources.
  • externalContext = YES: create + process on the GL thread.
  • Update UI on the main queue only.