question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to launch iOS application in swift with carthage frameworks

See original GitHub issue

Hi there,

I’ve been quite impressed by how fast buck builds iOS (and Android) applications, and decided to take the plunge. I’ve been working on deintegrating cocoapods and moving everything to use Carthage/static frameworks. I’m facing a launch error though when I try to run buck install where the application builds and starts to run but then immediately closes without any sort of error.

This is what happens when I run it screen shot 2017-05-11 at 14 44 07

The application appears in my simulator, and then opens and closes. Clicking on the icon after that has the effect (opens then closes)

My .BUCK file looks like that:

# iOS

apple_asset_catalog(
  name = 'JarvisAssets',
  app_icon = 'AppIcon',
  dirs = ['jarvis/Assets.xcassets'],
)

apple_resource(
  name = 'JarvisResources',
  dirs = [],
  files = glob(['jarvis/*.png','jarvis/*.storyboard', 'jarvis/*.xib', 'jarvis/Fonts/*.ttf', 'jarvis/Geomanist OTF/*.otf']),
)

apple_binary(
  name = 'JarvisBinary',
  configs = {
    'Development': {
    'PRODUCT_NAME' : 'Jarvis',
    'PRODUCT_MODULE_NAME' : 'jarvis',
    'CLANG_ENABLE_MODULES' : 'YES',
    'PROVISIONING_PROFILE_SPECIFIER' : '',
    'DEVELOPMENT_TEAM' : 'xxx',
    'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES' : 'YES',
    'PRODUCT_BUNDLE_IDENTIFIER' : 'xxx',
    'ONLY_ACTIVE_ARCH' : 'YES',
    'CODE_SIGN_ENTITLEMENTS' : 'jarvis/jarvis.entitlements',
    'SWIFT_OPTIMIZATION_LEVEL' : '-Onone',
    'GCC_OPTIMIZATION_LEVEL' : '0',
    'VALIDATE_PRODUCT' : 'NO',
    },
  },
  preprocessor_flags = [
    '-fobjc-arc',
    '-fno-objc-arc-exceptions',
    '-Qunused-arguments',
  ],
  srcs = glob([
    'jarvis/**/*.m',
    'jarvis/**/*.mm',
    'jarvis/**/*.swift',
  ]),
  headers = glob([
    'jarvis/**/*.h',
  ]),
  bridging_header = 'jarvis/Jarvis-Bridging-Header.h',
  frameworks = [
    '$SDKROOT/System/Library/Frameworks/SystemConfiguration.framework',
    '$SDKROOT/System/Library/Frameworks/OpenGLES.framework',
    '$SDKROOT/System/Library/Frameworks/AVFoundation.framework',
    '$SDKROOT/System/Library/Frameworks/Foundation.framework',
    '$SDKROOT/System/Library/Frameworks/UIKit.framework',
    '$SDKROOT/System/Library/Frameworks/CoreMotion.framework',
    '$SDKROOT/System/Library/Frameworks/CoreLocation.framework',
    '$SDKROOT/System/Library/Frameworks/MobileCoreServices.framework',
    '$SDKROOT/System/Library/Frameworks/CoreMedia.framework',
    '$SDKROOT/System/Library/Frameworks/CFNetwork.framework',
  ],
  visibility = ['PUBLIC'],
  deps = [
    ':JarvisAssets',
    ':JarvisResources',
    ':Fabric',
    ':Answers',
    ':Nimble',
    ':Quick',
    ':Sentry',
    ':Crash',
    ':AppleCalendar',
    ':CryptoSwift',
    ':JWT',
    ':KeychainAccess',
    ':Alamofire',
    ':AlamofireObjectMapper',
    ':Charts',
    ':EPSignature',
    ':IQKeyboardManager',
    ':IQKeyboardManagerSwift',
    ':ObjectMapper',
    ':calabash',
    ':ZDCChat',
    ':ZDCChatAPI',
  ],
)


apple_bundle(
  name = 'Jarvis',
  binary = ':JarvisBinary',
  extension = 'app',
  info_plist = 'jarvis/Info.plist',
)

apple_package(
  name = 'JarvisPackage',
  bundle = ':Jarvis',
)

prebuilt_apple_framework(
    name = 'Fabric',
    preferred_linkage = 'shared',
    framework = 'Fabric.framework',
)

prebuilt_apple_framework(
    name = 'Answers',
    preferred_linkage = 'shared',
    framework = 'Answers.framework',
)

prebuilt_apple_framework(
    name = 'Nimble',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/Nimble.framework',
)

prebuilt_apple_framework(
    name = 'Quick',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/Quick.framework',
)

prebuilt_apple_framework(
    name = 'Sentry',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/Sentry.framework',
)

prebuilt_apple_framework(
    name = 'Crash',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/KSCrash.framework',
)

prebuilt_apple_framework(
    name = 'AppleCalendar',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/JTAppleCalendar.framework',
)

prebuilt_apple_framework(
    name = 'CryptoSwift',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/CryptoSwift.framework',
)

prebuilt_apple_framework(
    name = 'JWT',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/JWT.framework',
)

prebuilt_apple_framework(
    name = 'KeychainAccess',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/KeychainAccess.framework',
)

prebuilt_apple_framework(
    name = 'Alamofire',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/Alamofire.framework',
)

prebuilt_apple_framework(
    name = 'AlamofireObjectMapper',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/AlamofireObjectMapper.framework',
)

prebuilt_apple_framework(
    name = 'Charts',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/Charts.framework',
)

prebuilt_apple_framework(
    name = 'EPSignature',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/EPSignature.framework',
)

prebuilt_apple_framework(
    name = 'IQKeyboardManager',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/IQKeyboardManager.framework',
)

prebuilt_apple_framework(
    name = 'IQKeyboardManagerSwift',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/IQKeyboardManagerSwift.framework',
)

prebuilt_apple_framework(
    name = 'ObjectMapper',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/ObjectMapper.framework',
)

prebuilt_apple_framework(
    name = 'calabash',
    preferred_linkage = 'shared',
    framework = 'calabash.framework',
)

prebuilt_apple_framework(
    name = 'ZDCChat',
    preferred_linkage = 'shared',
    framework = 'ZDCChat/ZDCChat.framework',
)

prebuilt_apple_framework(
    name = 'ZDCChatAPI',
    preferred_linkage = 'shared',
    framework = 'ZDCChat/ZDCChatAPI.framework',
)

and my .buckconfig is as follows:

[cache]
    mode = dir
    dir_max_size = 512MB

[cxx]
    cflags = -std=gnu11
    cxxflags = -std=c++14 -stdlib=libc++
    default_platform = iphonesimulator-x86_64
    combined_preprocess_and_compile = true

[project]
  ide = xcode
  ignore = \
    .git, \
    .hg, \
    .buckd

[swift]
  version = 3.0

iOS Simulator Log:

May 11 15:05:03 hostname assertiond[21905]: Submitted job with label: UIKitApplication:xxx[0xe80a][21905]
May 11 15:05:03 hostname SpringBoard[21899]: [xxx] Bootstrap complete with label: UIKitApplication: xxx[0xe80a][21905]
May 11 15:05:03 hostname com.apple.CoreSimulator.SimDevice.3F116BC8-F7F1-4AC5-AC54-F1A7E7EDF8FE.launchd_sim[21875] (UIKitApplication: xxx[0xe80a][21905][47621]): Service exited due to Abort trap: 6
May 11 15:05:03 hostname assertiond[21905]: Deleted job with label: UIKitApplication: xxx[0xe80a][21905]

Would love to get some clue as to why I’m having this issue. Been pouring over documentation and issues but have so far been unable to figure out what’s wrong. Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
yidingcommented, Sep 19, 2019

@acecilia I don’t work on buck anymore, but see my previous comment for an explanation why transitive prebuilt_apple_framework deps are not automatically copied into the bundle: https://github.com/facebook/buck/issues/1339#issuecomment-302251485

1reaction
gabrielzanonicommented, Mar 2, 2018

@nikhilsh There is a “hack” you need to do. You have to copy the carthage frameworks you’re using to a folder called Frameworks and use it as a apple_resource in you apple_bundle.

In your case, it would be something like this:

apple_asset_catalog(
  name = 'JarvisAssets',
  app_icon = 'AppIcon',
  dirs = ['jarvis/Assets.xcassets'],
)

apple_resource(
  name = 'JarvisResources',
  dirs = [],
  files = glob(['jarvis/*.png','jarvis/*.storyboard', 'jarvis/*.xib', 'jarvis/Fonts/*.ttf', 'jarvis/Geomanist OTF/*.otf']),
)

apple_binary(
  name = 'JarvisBinary',
  configs = {
    'Development': {
    'PRODUCT_NAME' : 'Jarvis',
    'PRODUCT_MODULE_NAME' : 'jarvis',
    'CLANG_ENABLE_MODULES' : 'YES',
    'PROVISIONING_PROFILE_SPECIFIER' : '',
    'DEVELOPMENT_TEAM' : 'xxx',
    'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES' : 'YES',
    'PRODUCT_BUNDLE_IDENTIFIER' : 'xxx',
    'ONLY_ACTIVE_ARCH' : 'YES',
    'CODE_SIGN_ENTITLEMENTS' : 'jarvis/jarvis.entitlements',
    'SWIFT_OPTIMIZATION_LEVEL' : '-Onone',
    'GCC_OPTIMIZATION_LEVEL' : '0',
    'VALIDATE_PRODUCT' : 'NO',
    },
  },
  preprocessor_flags = [
    '-fobjc-arc',
    '-fno-objc-arc-exceptions',
    '-Qunused-arguments',
  ],
  srcs = glob([
    'jarvis/**/*.m',
    'jarvis/**/*.mm',
    'jarvis/**/*.swift',
  ]),
  headers = glob([
    'jarvis/**/*.h',
  ]),
  bridging_header = 'jarvis/Jarvis-Bridging-Header.h',
  frameworks = [
    '$SDKROOT/System/Library/Frameworks/SystemConfiguration.framework',
    '$SDKROOT/System/Library/Frameworks/OpenGLES.framework',
    '$SDKROOT/System/Library/Frameworks/AVFoundation.framework',
    '$SDKROOT/System/Library/Frameworks/Foundation.framework',
    '$SDKROOT/System/Library/Frameworks/UIKit.framework',
    '$SDKROOT/System/Library/Frameworks/CoreMotion.framework',
    '$SDKROOT/System/Library/Frameworks/CoreLocation.framework',
    '$SDKROOT/System/Library/Frameworks/MobileCoreServices.framework',
    '$SDKROOT/System/Library/Frameworks/CoreMedia.framework',
    '$SDKROOT/System/Library/Frameworks/CFNetwork.framework',
  ],
  visibility = ['PUBLIC'],
  deps = [
    ':JarvisAssets',
    ':JarvisResources',
    ':Fabric',
    ':Answers',
    ':Nimble',
    ':Quick',
    ':Sentry',
    ':Crash',
    ':AppleCalendar',
    ':CryptoSwift',
    ':JWT',
    ':KeychainAccess',
    ':Alamofire',
    ':AlamofireObjectMapper',
    ':Charts',
    ':EPSignature',
    ':IQKeyboardManager',
    ':IQKeyboardManagerSwift',
    ':ObjectMapper',
    ':calabash',
    ':ZDCChat',
    ':ZDCChatAPI',
  ],
)


apple_bundle(
  name = 'Jarvis',
  binary = ':JarvisBinary',
  extension = 'app',
  deps = ['CarthageFrameworks'],
  info_plist = 'jarvis/Info.plist',
)

apple_resource(
  name = 'CarthageFrameworks',
  dirs = ['Frameworks'] # here you put all your carthage frameworks
)

apple_package(
  name = 'JarvisPackage',
  bundle = ':Jarvis',
)

prebuilt_apple_framework(
    name = 'Fabric',
    preferred_linkage = 'shared',
    framework = 'Fabric.framework',
)

prebuilt_apple_framework(
    name = 'Answers',
    preferred_linkage = 'shared',
    framework = 'Answers.framework',
)

prebuilt_apple_framework(
    name = 'Nimble',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/Nimble.framework',
)

prebuilt_apple_framework(
    name = 'Quick',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/Quick.framework',
)

prebuilt_apple_framework(
    name = 'Sentry',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/Sentry.framework',
)

prebuilt_apple_framework(
    name = 'Crash',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/KSCrash.framework',
)

prebuilt_apple_framework(
    name = 'AppleCalendar',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/JTAppleCalendar.framework',
)

prebuilt_apple_framework(
    name = 'CryptoSwift',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/CryptoSwift.framework',
)

prebuilt_apple_framework(
    name = 'JWT',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/JWT.framework',
)

prebuilt_apple_framework(
    name = 'KeychainAccess',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/KeychainAccess.framework',
)

prebuilt_apple_framework(
    name = 'Alamofire',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/Alamofire.framework',
)

prebuilt_apple_framework(
    name = 'AlamofireObjectMapper',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/AlamofireObjectMapper.framework',
)

prebuilt_apple_framework(
    name = 'Charts',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/Charts.framework',
)

prebuilt_apple_framework(
    name = 'EPSignature',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/EPSignature.framework',
)

prebuilt_apple_framework(
    name = 'IQKeyboardManager',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/IQKeyboardManager.framework',
)

prebuilt_apple_framework(
    name = 'IQKeyboardManagerSwift',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/IQKeyboardManagerSwift.framework',
)

prebuilt_apple_framework(
    name = 'ObjectMapper',
    preferred_linkage = 'shared',
    framework = 'Carthage/Build/iOS/ObjectMapper.framework',
)

prebuilt_apple_framework(
    name = 'calabash',
    preferred_linkage = 'shared',
    framework = 'calabash.framework',
)

prebuilt_apple_framework(
    name = 'ZDCChat',
    preferred_linkage = 'shared',
    framework = 'ZDCChat/ZDCChat.framework',
)

prebuilt_apple_framework(
    name = 'ZDCChatAPI',
    preferred_linkage = 'shared',
    framework = 'ZDCChat/ZDCChatAPI.framework',
)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot compile app with Carthage dependencies after Xcode ...
OK, I managed to compile my project. Steps to do: Remove ../Carthage/Build folder; Run xcodebuild -version and check is it the newest one....
Read more >
App Won't Compile with Embedded Third Party Framework
So, I'm getting this error when trying to run the app. "Build succeeds" but the app won't run and Xcode spits out an...
Read more >
Oh dear! Build errors? - LoopDocs - GitHub Pages
Fix 95% of errors¶ · Open your project in Xcode as normal. · On the far right, next to the name Full Path...
Read more >
Carthage - Swift Package Index
Carthage builds your dependencies and provides you with binary frameworks, but you retain full control over your project structure and setup. Carthage does...
Read more >
[iOS] How Carthage Works: Migrate from CocoaPods to ...
Carthage is too vulnerable to Xcode/Swift updates and it becomes a disaster every time we failed to compile the app just because we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found