文章40 | 阅读 19074 | 点赞0
#import <Foundation/Foundation.h>
//! Project version number for MyDynamicFramework.
FOUNDATION_EXPORT double MyDynamicFrameworkVersionNumber;
//! Project version string for MyDynamicFramework.
FOUNDATION_EXPORT const unsigned char MyDynamicFrameworkVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <MyDynamicFramework/PublicHeader.h>
#import "Person.h"
lipo -info /Users/ydw/Library/Developer/Xcode/DerivedData/MyDynamicFramework-cnfmjshbkauwwshdqagjwrgypile/Build/Products/Debug-iphoneos/MyDynamicFramework.framework/MyDynamicFramework
Architectures in the fat file: /Users/ydw/Library/Developer/Xcode/DerivedData/MyDynamicFramework-cnfmjshbkauwwshdqagjwrgypile/Build/Products/Debug-iphoneos/MyDynamicFramework.framework/MyDynamicFramework are: arm7、arm64
arm64:iPhone6s | iphone6s plus|iPhone6| iPhone6 plus|iPhone5S | iPad Air| iPad mini2(iPad mini with Retina Display)
armv7s:iPhone5|iPhone5C|iPad4(iPad with Retina Display)
armv7:iPhone4|iPhone4S|iPad|iPad2|iPad3(The New iPad)|iPad mini|iPod Touch 3G|iPod Touch4
i386: iPhone5 | iPhone 4s | iPhone 4及前代产品的模拟器
x86_64: iPhone5s | iPhone 6 | ... | iPhone8的模拟器
示例1:
Architectures 为armv7、arm64
Valid Architectures 为armv7、armv7s、arm64
Build Active Architecture Only 为 debug:YES release:NO
链接设备:iPhone 6s (arm64架构的设备)
编译(command + shift + B,保证Build Active Architecture Only 为 debug:YES 生效)
结果:编译成功,生成的动态库支持的指令集为arm64
示例2:
Architectures 为armv7、arm64
Valid Architectures 为 armv7s
Build Active Architecture Only 为 debug:YES release:NO
链接设备:iPhone 6s (arm64架构的设备)
编译(command + shift + B,保证Build Active Architecture Only 为 debug:YES 生效)
结果:编译失败,因为当前是debug模式,在该模式下Build Active Architecture Only 为YES,表示只编译支持该指令集的动态库,
但是由于Architectures和Build Active Architecture Only的交集中并不存在arm64,故三者的交集为空,故编译失败,无法生成动态库。
示例3:
Architectures 为armv7、arm64
Valid Architectures 为armv7、armv7s、arm64
Build Active Architecture Only 为 debug:NO release:NO
链接设备:iPhone 6s (arm64架构的设备)
编译(command + shift + B,保证Build Active Architecture Only 为 debug:YES 生效)
结果:编译成功,因为当前是debug模式,在该模式下Build Active Architecture Only 为NO,
表示可以编译的结果可能为当前连接的设备所支持的指令集以及其向下兼容的指令集(armv64、armv7s、armv7),其和另外两个编译选项的交集为armv7,故所生成的动态库支持的指令集为armv7
lipo -create /Users/ydw/Library/Developer/Xcode/DerivedData/MyDynamicFramework-cnfmjshbkauwwshdqagjwrgypile/Build/Products/Debug-iphoneos/MyDynamicFramework.framework/MyDynamicFramework /Users/ydw/Library/Developer/Xcode/DerivedData/MyDynamicFramework-cnfmjshbkauwwshdqagjwrgypile/Build/Products/Debug-iphonesimulator/MyDynamicFramework.framework/MyDynamicFramework -output MyDynamic
if [ "${ACTION}" = "build" ]
then
INSTALL_DIR=${SRCROOT}/Products/${PROJECT_NAME}.framework
DEVICE_DIR=${BUILD_ROOT}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework
SIMULATOR_DIR=${BUILD_ROOT}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework
if [ -d "${INSTALL_DIR}" ]
then
rm -rf "${INSTALL_DIR}"
fi
mkdir -p "${INSTALL_DIR}"
cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/"
#ditto "${DEVICE_DIR}/Headers" "${INSTALL_DIR}/Headers"
# 使用lipo命令将其合并成一个通用framework
# 最后将生成的通用framework放置在工程根目录下新建的Products目录下
lipo -create "${DEVICE_DIR}/${PROJECT_NAME}" "${SIMULATOR_DIR}/${PROJECT_NAME}" -output "${INSTALL_DIR}/${PROJECT_NAME}"
#open "${DEVICE_DIR}"
#open "${SRCROOT}/Products"
fi
lipo -info /Users/ydw/Desktop/MyDynamicFramework/Products/MyDynamicFramework.framework/MyDynamicFramework
Architectures in the fat file: /Users/ydw/Desktop/Products/MyDynamicFramework.framework/MyDynamicFramework are: i386 x86_64 armv7 arm64
#import <MyDynamicFramework/MyDynamicFramework.h>
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
ViewController *vc = [[ViewController alloc] init];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
[self.window makeKeyAndVisible];
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = vc;
[Person logMessage:@"framework test"];
return YES;
}
+ [Person logMessage:] -framework test
UByjBj: 2021-08-28 12:39:52 +0000
AORja]: 2021-08-28 12:39:54 +0000
- (UIViewController *)loadFrameworkNamed:(NSString *)bundleName {
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = nil;
if ([paths count] != 0) {
documentDirectory = [paths objectAtIndex:0];
}
NSFileManager *manager = [NSFileManager defaultManager];
NSString *bundlePath = [documentDirectory stringByAppendingPathComponent:[bundleName stringByAppendingString:@".framework"]];
// Check if new bundle exists
if (![manager fileExistsAtPath:bundlePath]) {
NSLog(@"No framework update");
bundlePath = [[NSBundle mainBundle]
pathForResource:bundleName ofType:@"framework"];
// Check if default bundle exists
if (![manager fileExistsAtPath:bundlePath]) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oooops" message:@"Framework not found" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alertView show];
return nil;
}
}
// Load bundle
NSError *error = nil;
NSBundle *frameworkBundle = [NSBundle bundleWithPath:bundlePath];
if (frameworkBundle && [frameworkBundle loadAndReturnError:&error]) {
NSLog(@"Load framework successfully");
}else {
NSLog(@"Failed to load framework with err: %@",error);
return nil;
}
// Load class
Class PublicAPIClass = NSClassFromString(@"PublicAPI");
if (!PublicAPIClass) {
NSLog(@"Unable to load class");
return nil;
}
NSObject *publicAPIObject = [PublicAPIClass new];
return [publicAPIObject performSelector:@selector(mainViewController)];
}
Class XXX is implemented in both XXX and XXX. One of the two will be used. Which one is undefined.
Error Domain=NSCocoaErrorDomain Code=3588 "The bundle “YourFramework” couldn’t be loaded." (dlopen(/var/mobile/Containers/Bundle/Application/5691FB75-408A-4D9A-9347-BC7B90D343C1/YourApp.app/YourFramework.framework/YourFramework, 265): Symbol not found: _OBJC_CLASS_$_BorderedView
Referenced from: /var/mobile/Containers/Bundle/Application/5691FB75-408A-4D9A-9347-BC7B90D343C1/YourApp.app/YourFramework.framework/YourFramework
Expected in: flat namespace
in /var/mobile/Containers/Bundle/Application/5691FB75-408A-4D9A-9347-BC7B90D343C1/YourApp.app/YourFramework.framework/YourFramework) UserInfo=0x174276900 {NSLocalizedFailureReason=The bundle couldn’t be loaded., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/var/mobile/Containers/Bundle/Application/5691FB75-408A-4D9A-9347-BC7B90D343C1/YourApp.app/YourFramework.framework/YourFramework, NSDebugDescription=dlopen(/var/mobile/Containers/Bundle/Application/5691FB75-408A-4D9A-9347-BC7B90D343C1/YourApp.app/YourFramework.framework/YourFramework, 265): Symbol not found: _OBJC_CLASS_$_BorderedView
Referenced from: /var/mobile/Containers/Bundle/Application/5691FB75-408A-4D9A-9347-BC7B90D343C1/YourApp.app/YourFramework.framework/YourFramework
Expected in: flat namespace
in /var/mobile/Containers/Bundle/Application/5691FB75-408A-4D9A-9347-BC7B90D343C1/YourApp.app/YourFramework.framework/YourFramework, NSBundlePath=/var/mobile/Containers/Bundle/Application/5691FB75-408A-4D9A-9
UIImage *image = [UIImage imageNamed:@"YourFramework.framework/imageName"]
dlopen(/path/to/framework, 9): no suitable image found. Did find:
/path/to/framework: mach-o, but wrong architecture
lipo -info /path/to/MyFramework.framework/MyFramework
Error loading /path/to/framework: dlopen(/path/to/framework, 265): no suitable image found. Did find:
/path/to/framework: mmap() error 1
[deny-mmap] mapped file has no team identifier and is not a platform binary:
/private/var/mobile/Containers/Bundle/Application/5D8FB2F7-1083-4564-94B2-0CB7DC75C9D1/YourAppNameHere.app/Frameworks/YourFramework.framework/YourFramework
codesign -dv /path/to/YourApp.app
Executable=/path/to/YourApp.app/YourApp
Identifier=com.company.yourapp
Format=bundle with Mach-O thin (armv7)
CodeDirectory v=20100 size=221748 flags=0x0(none) hashes=11079+5 location=embedded
Signature size=4321
Signed Time=2018年10月21日 下午10:18:36
Info.plist entries=42
TeamIdentifier=not set
Sealed Resources version=2 rules=12 files=2451
Internal requirements count=1 size=188
To correct this problem, you will need to sign your app using code signing certificates with the Subject Organizational Unit (OU) set to your Team ID. All Enterprise and standard iOS developer certificates that are created after iOS 8 was released have the new Team ID field in the proper place to allow Swift language apps to run.
If you are an in-house Enterprise developer you will need to be careful that you do not revoke a distribution certificate that was used to sign an app any one of your Enterprise employees is still using as any apps that were signed with that enterprise distribution certificate will stop working immediately.
You are responsible for managing your team’s certificates and provisioning profiles. Apple Developer Enterprise Program certificates expire after three years and provisioning profiles expire after one year.
Before a distribution certificate expires, create an additional distribution certificate, described in Creating Additional Enterprise Distribution Certificates. You cannot renew an expired certificate. Instead, replace the expired certificate with the new certificate, described in Replacing Expired Certificates.
If a distribution provisioning profile expires, verify that you have a valid distribution certificate and renew the provisioning profile, described in Renewing Expired Provisioning Profiles.
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/Forever_wj/article/details/119962887
内容来源于网络,如有侵权,请联系作者删除!