Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build with XCode 12.3? #183

Closed
zarko-tg opened this issue Dec 15, 2020 · 12 comments · Fixed by #194
Closed

Unable to build with XCode 12.3? #183

zarko-tg opened this issue Dec 15, 2020 · 12 comments · Fixed by #194
Milestone

Comments

@zarko-tg
Copy link

We're getting a full release build failure for iOS now that XCode 12.3 is out, without having made any Sentry related changes on our side.
In short the error message is:

error: Building for iOS, but the embedded framework 'Sentry.framework' was built for iOS + iOS Simulator. (in target 'App' from project 'App')

** ARCHIVE FAILED **

Target is arm64.

Env:
sentry-cordova 0.17.0

Ionic:

Ionic CLI : 6.12.3
Ionic Framework : ionic-angular 3.9.10
@ionic/app-scripts : 3.2.4

Cordova:

Cordova CLI : 10.0.0
Cordova Platforms : ios 6.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 12 other plugins)

System:

Android SDK Tools : 26.1.1 (/Users/user/Library/Android/sdk)
ios-deploy : 1.11.3
ios-sim : 8.0.2
NodeJS : v12.20.0
npm : 6.14.8
OS : macOS Big Sur
Xcode : Xcode 12.3 Build version 12C33

@kbrin423
Copy link

Same message for me:
error: Building for iOS, but the embedded framework 'Sentry.framework' was built for iOS + iOS Simulator.

Ionic CLI : 6.12.2
Ionic Framework : @ionic/angular 5.3.2

Cordova CLI : 10.0.0
Cordova Platforms : android 9.0.0, ios 5.1.1

OS : macOS Big Sur
Xcode : Xcode 12.3 Build version 12C33

@zarko-tg
Copy link
Author

@philipphofmann pardon for pinging you but could you have someone have a look at this, it's a showstopper at least for us since it breaks the whole build/release process.

@TianleZhang
Copy link

same here

@philipphofmann
Copy link
Member

Hi,
this could be related to getsentry/sentry-cocoa#881. It could be that we need to use an XCFramework, which we already do in our makefile for our watchOS sample. I just added this as a note. I'm going to come back to you later.

@wongpeiyi
Copy link

As a workaround it seems like setting Xcode -> Build Settings -> Validate Workspace -> Yes sidesteps the issue

https://stackoverflow.com/questions/65303304/xcode-12-3-building-for-ios-simulator-but-the-linked-and-embedded-framework-wa#comment115460607_65303304

@Polm90
Copy link

Polm90 commented Jan 11, 2021

As a workaround it seems like setting Xcode -> Build Settings -> Validate Workspace -> Yes sidesteps the issue

https://stackoverflow.com/questions/65303304/xcode-12-3-building-for-ios-simulator-but-the-linked-and-embedded-framework-wa#comment115460607_65303304

It works!
Thank you!

@mountpoint
Copy link

@HazAT can you fix this issue? This blocks us to integrate Sentry to our Ionic project

@kostynskyi
Copy link

@HazAT The same issue on our project. All the workarounds don’t work for me :(

@bruno-garcia bruno-garcia added this to the 1.0.0 milestone Feb 3, 2021
@mlegenhausen
Copy link
Contributor

I use this after_prepare hook to get the plugin working. This is an adaption of the in #29 proposed hook for app store build. I added the automatic adding of the VALIDATE_WORKSPACE property.

const fs = require('fs');
const path = require('path');
const xcode = require('xcode');

const shellScript = `
APP_PATH="\${TARGET_BUILD_DIR}/\${WRAPPER_NAME}"

# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"

EXTRACTED_ARCHS=()

for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done

echo "Merging extracted architectures: \${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "\${EXTRACTED_ARCHS[@]}"
rm "\${EXTRACTED_ARCHS[@]}"

echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"

done
`;

module.exports = context => {
  const projectDir = path.resolve(context.opts.projectRoot, 'platforms/ios')
  const dirContent = fs.readdirSync(projectDir)
  const matchingProjectFiles = dirContent.filter(filePath => /.*\.xcodeproj/gi.test(filePath));
  const projectPath = path.join(projectDir, matchingProjectFiles[0], 'project.pbxproj');

  const project = xcode.project(projectPath)

  project.parse(error => {
    if (error) {
      console.error('Failed to parse project', error);
      process.exit(1);
    }
    // Fix for: https://github.com/getsentry/sentry-cordova/issues/183
    project.addBuildProperty('VALIDATE_WORKSPACE', 'YES')

    const options = {
      shellPath: '/bin/sh',
      shellScript,
      inputPaths: ['"$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)"']
    };
    project.addBuildPhase(
      [],
      'PBXShellScriptBuildPhase',
      'Remove Unused Architectures',
      project.getFirstTarget().uuid,
      options
    );
    fs.writeFileSync(projectPath, project.writeSync());
  })
};

@mac89
Copy link

mac89 commented Feb 9, 2021

Using [email protected] solved this issue for me. See apache/cordova-ios#1060

@philipphofmann
Copy link
Member

Using [email protected] solved this issue for me. See apache/cordova-ios#1060

As [email protected] seems to solve this problem, we are closing this issue. Please open it again, if it doesn't work for you.

@ericmulder
Copy link

I found that if I build the app using the --device flag Sentry only build for ARM. It actually makes sense because otherwise the app builds for the simulator which is i386. So using: cordova build ios --release --device I got the correct architectures to push a build to the app store.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.